[r64]: / branches / 13-jobs / cforge / cforge / Package / CFORGE / Scripts / commit.py  Maximize  Restore  History

Download this file

52 lines (39 with data), 1.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import sys, os
import cds_script
import ui
import pysvn
import ntpath


# This is a cforge command (script file)
# this will be run as ironpython script.
# the filename of this script is automatically the corresponding cforge command 
# with some magic functions you can easily integrate it nicely into cforge tool

# cforge_usage: 
# here you can return an array of all possible arguments and options that can 
# be passed to this command script
def cforge_usage():
    help = [ 
	    ["<path to CODESYS project>", "---"]
    ]

    return help


def do(folder, username, password, message):
	scriptpath = os.path.abspath(os.path.dirname(sys.argv[0]))
	scriptname = os.path.join(scriptpath, "action.svn.commit.py")
	scriptargs = "%s %s %s %s" % (username, password, folder, message)

	cds_script.RunCodesysWithScript(scriptname, scriptargs, False)

# call main
if __name__ == "__main__":
	if len(sys.argv) <= 1:
		print("Oh, there are no arguments. Perhaps you forgot something?")
		sys.exit()
	folder = sys.argv[1]

	# if folder can't be found, try to interpret it as a repo
	# name, relatively to the workspace folder
	if not os.path.isdir(folder):
		config = ui.GetSettings()
		workspace, file = ntpath.split(config['folder'])
		folder = os.path.join(workspace, folder)

	print("commiting folder: %s" % folder)

	stat = pysvn.svn_get_stat(folder)
	config = ui.Dialog("Commit", Credentials=True, Info=True, InfoText=stat, Message=True)

	if config != None:
		do(folder, config["user"], config["pass"], config["msg"])