Exemple #1
0
def RunPypeProcess(arguments, inputStream=None, outputStream=None, logOn=True):
    pipe = pypes.Pype()
    pipe.ExitOnError = 0
    if inputStream:
        pipe.InputStream = inputStream
    if outputStream:
        pipe.OutputStream = outputStream
    pipe.LogOn = logOn
    pipe.LogOn = True
    if type(arguments) in [str, unicode]:
        pipe.SetArgumentsString(arguments)
    else:
        pipe.Arguments = arguments
    try:
        pipe.ParseArguments()
        pipe.Execute()
    except BaseException, e:
        print traceback.format_exc()
Exemple #2
0
 def RunPype(self,arguments):
     if not arguments:
         return
     if self.output_to_file.get() is not 'n' and self.output_file_name:
         self.output_stream.output_to_file = True
         self.output_stream.output_file = open(self.output_file_name,self.output_to_file.get())
     else:
         self.output_stream.output_to_file = False
     pipe = pypes.Pype()
     pipe.ExitOnError = 0
     pipe.InputStream = self.input_stream
     pipe.OutputStream = self.output_stream
     pipe.LogOn = self.log_on.get()
     pipe.SetArgumentsString(arguments)
     pipe.ParseArguments()
     try: 
         pipe.Execute() 
     except Exception:
         return
Exemple #3
0
                                            os.path.join(vmtkhome,"vtk")
        sys.path.append(os.path.join(vmtkhome,"bin"))
        sys.path.append(os.path.join(vtkdir))
        sys.path.append(os.path.join(vmtkhome))
        sys.path.append(os.path.join(vmtkhome,"vtk"))

    os.environ[ldEnvironmentVariable] = newEnviron[ldEnvironmentVariable] + os.path.pathsep + currentEnviron[ldEnvironmentVariable]
        
    from vmtk import pypes
    
    vmtkOptions = ['--help', '--ui', '--file']
    
    if len(sys.argv) > 1 and sys.argv[1] not in vmtkOptions:
        arguments = sys.argv[1:]
        print "Executing", ' '.join(arguments)
        pipe = pypes.Pype()
        pipe.ExitOnError = 0
        pipe.Arguments = arguments
        pipe.ParseArguments()
        pipe.Execute()
        sys.exit(0)
    elif len(sys.argv) > 1 and '--file' in sys.argv:
        fileindex = sys.argv.index('--file')+1
        if fileindex < len(sys.argv):
            inputfile = open(sys.argv[fileindex],'r')
            physicalLines = [line for line in inputfile.readlines() if line and line.strip() and line.strip()[0]!='#']
            lines = []
            for line in physicalLines:
                if lines and lines[-1].endswith('\\\n'):
                    lines[-1] = lines[-1][:-2] + line
                else: