--- a +++ b/trunk/cforge/cforge/Package/CFORGE/Scripts/action.svn.commit.py @@ -0,0 +1,47 @@ +# Example Batch: +# set WD=%~d0%~p0 +# set USER=<username> +# set PASS=<password> +# set URL=https://forge.codesys.com/svn/drv,gpio-mod,code/trunk/GPIOMods +# "C:\Program Files (x86)\3S CODESYS-V3.5.12.0\CODESYS\Common\CODESYS.exe" --profile="CODESYS V3.5 SP12" --runscript="%WD%\action.svn.checkout.py" --scriptargs="%URL% %USER% %PASS% %WD%" --noUI + +import sys +import os.path +import pysvn + +if len(sys.argv) <= 1: + print("usage: <user> <pass> <working dir>") + sys.exit() + +if len(sys.argv) > 2: + username = sys.argv[1] + password = sys.argv[2] + +if len(sys.argv) > 3: + path = sys.argv[3] + +if len(sys.argv) > 4: + message = sys.argv[4] + +def set_username(req): + req.username = username + req.password = password + req.save = True # Optional + +svn.auth_username_password += set_username +# checkout plain SVN files +pysvn.svn_commit_non_codesys(username, password, path, message) + +# iterate over all projects and libraries +for root, dirs, files in os.walk(path): + for file in files: + if file.endswith(".project") or file.endswith(".library"): + filepath = os.path.join(root, file) + proj = projects.open(filepath) + proj.svn.commit(message) + proj.save() + proj.close() + +system.exit() + +