def app_launch(executable, teardown=None, params='', _assert=False, **kw): """ App Launch | <executable> [ | params | <cmdline parameters string> ] [ | flags and params ] Launches an app. The first parameter is a path to the app's executable. Optional 'suite_teardown' or 'test_teardown' flags force to kill the app at the end of the suite or of the test, respectively (if still running). A 'params' named parameter is also optional, should be followed by a parameters string (all args in one). :return: An application object or None in case of failure if "assert" flag is not present. """ pi = ProcessStartInfo(executable, params) workdir = kw.get('workdir', '') if workdir!='': pi.WorkingDirectory=workdir logging.info(workdir) try: app = Application.Launch(pi) except: if _assert: logging.error('Failed to launch an executable') raise logging.warning('Failed to launch an executable') return None if teardown == 'test': CONTROLLED_APPS[-1].append(app) elif teardown == 'suite': SUITE_CONTROLLED_APPS[-2].append(app) return app
def ExecProcess(file, arg=""): from System.Diagnostics import ProcessStartInfo, Process processStartInfo = ProcessStartInfo(file, arg) processStartInfo.UseShellExecute = True processStartInfo.CreateNoWindow = True process = Process.Start(processStartInfo)
def popen(executable, arguments): global process # XXX: keep it alive processStartInfo = ProcessStartInfo(executable, arguments) processStartInfo.UseShellExecute = False processStartInfo.CreateNoWindow = True processStartInfo.RedirectStandardOutput = True process = Process.Start(processStartInfo) return file(process.StandardOutput.BaseStream, "r")
def run_cmd(command): # os.system(command) pinfo = ProcessStartInfo() pinfo.FileName = "cmd.exe" pinfo.WindowStyle = ProcessWindowStyle.Hidden pinfo.Arguments = "/C" + command cmd = Process.Start(pinfo) cmd.WaitForExit()
def onEdit(sender, args): global program path = sender.Tag def onStart(state): Process.Start(state) psi = ProcessStartInfo() if String.IsNullOrEmpty(program): psi.FileName = path else: psi.FileName = program psi.Arguments = path Task.Factory.StartNew(onStart, psi)
def launch_application(self, sut_path, args=None): """Launches an application. ``sut_path`` is the absolute path to the application to launch. ``args`` is a string of arguments to use when starting the application (optional). Examples: | Launch Application | C:/path/to/MyApp.exe | | # Launch without arguments | | Launch Application | C:/path/to/MyApp.exe | /o log.txt | # Launch with arguments | """ if args is not None: process_start_info = ProcessStartInfo(sut_path) process_start_info.Arguments = args self.state.app = Application.Launch(process_start_info) else: self.state.app = Application.Launch(sut_path)
def start_imaging(path): psInfo = ProcessStartInfo() psInfo.FileName = path + "Imaging.exe" psInfo.Arguments = "Rowthon 1" psInfo.CreateNoWindow = False psInfo.UseShellExecute = False psInfo.RedirectStandardOutput = True p = Process.Start(psInfo)
def StartCmdProcess(commandLine): # NOTE: do not call Process.WaitForExit() until redirected streams have been entirely read from / closed. # doing so can lead to a deadlock when the child process is waiting on being able to write to output / error # stream and the parent process is waiting for the child to exit! See Microsoft's documentation for more info. # NOTE: if redirecting both output and error streams, one should be read asynchronously to avoid a deadlock where # the child process is waiting to write to one of the streams and the parent is waiting for data from the other # stream. See Microsoft's documentation for more info. psi = ProcessStartInfo('cmd.exe', '/U /S /C " ' + commandLine + ' "') psi.UseShellExecute = False psi.CreateNoWindow = True psi.RedirectStandardInput = False psi.RedirectStandardError = False # See notes above if enabling this alongside redirect output stream. psi.RedirectStandardOutput = True psi.StandardOutputEncoding = Encoding.Unicode p = Process.Start(psi) return p
def StartRevitProcess(revitVersion, initEnvironmentVariables): revitExecutableFilePath = RevitVersion.GetRevitExecutableFilePath(revitVersion) psi = ProcessStartInfo(revitExecutableFilePath) psi.UseShellExecute = False psi.RedirectStandardError = True psi.RedirectStandardOutput = True psi.WorkingDirectory = RevitVersion.GetRevitExecutableFolderPath(revitVersion) initEnvironmentVariables(psi.EnvironmentVariables) revitProcess = Process.Start(psi) return revitProcess
def RunICM(Adapter): """ <Script> <Author>ANK</Author> <Description>run an ICM model</Description> <Parameters> <Parameter name="Adapter" type="IRuntimeAdapter">handle to the adapter</Parameter> </Parameters> </Script> """ tsMgr = app.Modules.Get("Time series Manager") # get the adapter root folder rootfolder = Adapter.RootFolderPath # convert dfs0-input files to Dummy_Inflow.csv # open dummy inflow and read all lines inflowPath = Path.Combine(rootfolder, "MODEL_SETUP\\import\\Dummy Inflow.csv") inflowLines = File.ReadAllLines(inflowPath) # read dfs0-files one by one l=8 tslist = [] while inflowLines[l].split(",")[0]!="P_DATETIME" : tsname = inflowLines[l].split(",")[0] tsFile = Path.Combine(rootfolder, "INPUT_DATA", tsname+".dfs0") tslist.extend(TsUtilities.ReadFromDFS0(tsMgr, tsFile)) l = l + 1; # make new lines newLines = [] i=0 while True: if i==6: # replace startdate line = tslist[0].Start.ToString("dd/MM/yyyy HH:mm:ss") + inflowLines[i][19:] else: line = inflowLines[i] newLines.append(line) if inflowLines[i].split(",")[0]=="P_DATETIME" : break; i = i + 1; # continue with timesteps for t in range(tslist[0].Count): line = tslist[0].Get(t).XValue.ToString("dd/MM/yyyy HH:mm:ss") for ds in tslist: line += "," + ds.Get(t).YValue.ToString(CultureInfo.InvariantCulture) newLines.append(line) # rewrite the input file File.WriteAllLines(inflowPath, newLines) # run the adapter bat-file startInfo = ProcessStartInfo() startInfo.CreateNoWindow = False; startInfo.UseShellExecute = False; startInfo.FileName = Path.Combine(rootfolder, "MODEL_SETUP", "run.bat"); startInfo.WorkingDirectory = Path.Combine(rootfolder, "MODEL_SETUP") with Process.Start(startInfo) as exeProcess : exeProcess.WaitForExit(); # convert exported csv-files to dfs0 # convert node depths dslist = [] for fil in Directory.GetFiles(Path.Combine(rootfolder,"MODEL_SETUP\\export"),"Node_*_depnod.csv"): lines = File.ReadAllLines(fil) headers = lines[0].split(",") for h in headers[2:]: ds = tsMgr.TimeSeriesList.CreateNew() ds.Name = h.strip() ds.YAxisVariable = "Water Level" dslist.append(ds) for line in lines[1:] : if not "[" in line: values = line.split(",") t = DateTime.ParseExact(values[0].strip(),"dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture) for v in range(2,values.Count): ds = dslist[v-2] vp = ds.CreateNew() vp.XValue = t vp.YValue = Double.Parse(values[v].strip(), CultureInfo.InvariantCulture) ds.Add(vp) # save to dfs0 for ds in dslist: fil = Path.Combine(rootfolder,"OUTPUT_DATA",ds.Name+".dfs0") TsUtilities.ExportToDfs0(ds,fil)
import clr clr.AddReference('System') from System.Diagnostics import Process, ProcessStartInfo processes = Process.GetProcessesByName('Dropbox') if len(processes) == 0: processStartInfo = ProcessStartInfo() processStartInfo.WorkingDirectory = r"C:\Users\Andrius\AppData\Roaming\Dropbox\bin" processStartInfo.FileName = 'Dropbox.exe' dropbox = Process.Start(processStartInfo)
# <command> # <description>Startet ein externes Programm</description> # <param name="program" type="file">Pfad zum Programm</param> # <param name="arguments" type="string">(optional) Parameter für das Programm</param> # <param name="directorz" type="dir">(optional) Verzeichnis in dem das Programm ausgeführt wird</param> # </command> from System.Diagnostics import Process, ProcessStartInfo setup = ProcessStartInfo(program, arguments) if directory is not None: setup.WorkingDirectory = directory Process.Start(setup)
print 'Conflicts', status.NumConflicts for conflict in ws.QueryConflicts(('$/TCWCS/Python/Main/Open_Source/', ), True): assert isinstance(conflict, Conflict) print 'Can Merge', conflict.CanMergeContent conflict.Resolution = Resolution.AcceptMerge conflict.ResolutionOptions.UseInternalEngine = True ws.ResolveConflict(conflict) if not conflict.IsResolved: if conflict.CanMergeContent: conflict.Resolution = Resolution.AcceptYours ws.ResolveConflict(conflict) if not conflict.IsResolved: print 'Failed to resolve conflict', dir(conflict) sys.exit(1) else: print 'Failed to resolve conflict', dir(conflict) sys.exit(1) ws.CheckIn(ws.GetPendingChanges(), x.Comment) comment = x.Comment.Replace("'", "''").Replace(unichr(8217), "''") psi = ProcessStartInfo(path, r'"' + workspace_root + "\Tools\CodePlex\Sync.ps1\" push '" + hg_root + "' '" + workspace_root +"' '" + comment + "' -suppress_push True -commit_date '" + x.CreationDate.ToString() + "'") print psi.Arguments psi.UseShellExecute = False p = Process.Start(psi) p.WaitForExit() cur_version = x.ChangesetId
def ExecProcess(file, arg=''): from System.Diagnostics import ProcessStartInfo, Process processStartInfo = ProcessStartInfo(file, arg) processStartInfo.UseShellExecute = True processStartInfo.CreateNoWindow = True process = Process.Start(processStartInfo)
True): assert isinstance(conflict, Conflict) print 'Can Merge', conflict.CanMergeContent conflict.Resolution = Resolution.AcceptMerge conflict.ResolutionOptions.UseInternalEngine = True ws.ResolveConflict(conflict) if not conflict.IsResolved: if conflict.CanMergeContent: conflict.Resolution = Resolution.AcceptYours ws.ResolveConflict(conflict) if not conflict.IsResolved: print 'Failed to resolve conflict', dir(conflict) sys.exit(1) else: print 'Failed to resolve conflict', dir(conflict) sys.exit(1) ws.CheckIn(ws.GetPendingChanges(), x.Comment) comment = x.Comment.Replace("'", "''").Replace(unichr(8217), "''") psi = ProcessStartInfo( path, r'"' + workspace_root + "\Tools\CodePlex\Sync.ps1\" push '" + hg_root + "' '" + workspace_root + "' '" + comment + "' -suppress_push True -commit_date '" + x.CreationDate.ToString() + "'") print psi.Arguments psi.UseShellExecute = False p = Process.Start(psi) p.WaitForExit() cur_version = x.ChangesetId