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 52 53 54 55 56 | # imports import sys import os from System.Diagnostics import Process from System.Net import WebClient # This is a cforge command (script file) # this will open the CODESYS PackageManager to list all installed packages # 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 = [ ["", "no parameters required"] ] return help if len(sys.argv) > 1: print("Oh, there are arguments... didnt expect them") # common paths workingdir = os.path.dirname(sys.argv[0]) cdsdir = os.path.abspath(os.path.join(workingdir, os.path.pardir, os.path.pardir)) print(cdsdir) # profile stuff profiledir=os.path.join(cdsdir,"Profiles") print(profiledir) lastprofile="" for file in os.listdir(profiledir): if file.endswith(".profile"): lastprofile = file.replace(".profile","") print(lastprofile) # exe codesys_exe = os.path.join(cdsdir, "Common", "CODESYS.exe") packageman_exe = os.path.join(cdsdir, "Common", "PackageManager.exe") workdir = os.path.join(cdsdir, "Common") #Process.Start(localname) p = Process() p.StartInfo.WorkingDirectory=workdir p.StartInfo.FileName = packageman_exe p.StartInfo.Arguments = "--profile='" + lastprofile + "'" p.Start() p.WaitForExit() |