def start(self): """Start a new interpreter process.""" if self.isStarted: # nop if started already return # inform the user that we're starting the console self.txtTerm.Clear() self.txtTerm.WriteText( "Starting Python interpreter session, please wait ...\n") # setup the sub-process wx.BeginBusyCursor() self._process = wx.Process(self) self._process.Redirect() # get the path to the interpreter interpPath = '"' + sys.executable + '"' # start the sub-process self._pid = wx.Execute(r' '.join([interpPath, r'-i']), wx.EXEC_ASYNC, self._process) # bind the event called when the process ends self._process.Bind(wx.EVT_END_PROCESS, self.onTerminate) # clear all text in the widget and display the welcome message self.txtTerm.Clear() self.txtTerm.WriteText( "Python shell in PsychoPy (pid:{}) - type some commands!\n\n". format(self._pid)) # show the subprocess PID for reference self._lastTextPos = self.txtTerm.GetLastPosition() wx.EndBusyCursor()
def RunDosCommand(win, command, guiflag=False, redirect=True): """replace $file = current document filename""" if redirect: win.createDosWindow() win.panel.showPage(tr('Dos')) win.dosprompt.SetText('') win.dosprompt.editpoint = 0 win.dosprompt.writeposition = 0 try: win.dosprompt.process = wx.Process(win) win.dosprompt.process.Redirect() if guiflag: win.dosprompt.pid = wx.Execute(command, wx.EXEC_ASYNC | wx.EXEC_NOHIDE, win.dosprompt.process) else: win.dosprompt.pid = wx.Execute(command, wx.EXEC_ASYNC, win.dosprompt.process) win.dosprompt.inputstream = win.dosprompt.process.GetInputStream() win.dosprompt.errorstream = win.dosprompt.process.GetErrorStream() win.dosprompt.outputstream = win.dosprompt.process.GetOutputStream( ) except: win.dosprompt.process = None dlg = wx.MessageDialog( win, tr("There are some problems when running the program!\nPlease run it in shell." ), "Stop running", wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() else: wx.Execute(command)
def OnDebuggerStart(self, evt): try: wx.BeginBusyCursor() try: if self.server is None: # Start the subprocess. process = wx.Process(self.event_handler, self.win_id) process.Redirect() self.process = process wx.EVT_END_PROCESS(self.event_handler, self.win_id, self.OnProcessEnded) (self.server, self.input_stream, self.error_stream, self.processId, self.pyIntpPath) = spawnChild(self, process, self.process_args) self.taskHandler.addTask(evt.GetTask()) except: t, v, tb = sys.exc_info() evt = self.createEvent(wxEVT_DEBUGGER_EXC) evt.SetExc(t, v) self.postEvent(evt) if LOG_TRACEBACKS: import traceback fn = os.path.join(os.path.dirname(__file__), 'DebugTracebacks.txt') open(fn, 'a').write(''.join( traceback.format_exception(t, v, tb))) del tb finally: wx.EndBusyCursor()
def Execute(self, command, label = None, statustext = "Running script...",beep=False): """Executes a command of which the output will be redirected by OnIdle and OnEndProcess.""" if self.pid is -1: if not label: label = command #give feedback self.AddText('<table bgcolor=#CCCCCC width=100%%><tr><td><TT><img src="%s"> %s</TT></td></tr></table>'%(RUN_ICON,label)) self.SetStatusText(statustext) self.UpdateToolbar() self.Raise() #bind events self.Bind(wx.EVT_IDLE,self.OnIdle) self.Bind(wx.EVT_END_PROCESS,self.OnEndProcess) #create process self.process = wx.Process(self) self.process.Redirect() if info.WIN: self.pid = wx.Execute(command, wx.EXEC_ASYNC | wx.EXEC_NOHIDE, self.process) else: self.pid = wx.Execute(command, wx.EXEC_ASYNC | wx.EXEC_MAKE_GROUP_LEADER, self.process) self.inputstream = self.process.GetInputStream() self.errorstream = self.process.GetErrorStream() self.outputstream = self.process.GetOutputStream() self.inputstream.Write = Write self._check_run(True) self.beep = beep
def test_process2(self): flag = False def onEndProcess(evt): flag = True if 'wxMac' not in wx.PlatformInfo: p = wx.Process(self.frame) self.frame.Bind(wx.EVT_END_PROCESS, onEndProcess) wx.Execute('%s %s' % (sys.executable, testscript), callback=p)
def start_local( exe='scsynth', exedir='/Applications/SuperCollider', port=57110, inputs=2, outputs=2, samplerate=44100, ## this is missing from command! verbose=False, ): """ Start an return a local scsynth process. """ fmt = '%(exe)s -u %(port)s -i %(inputs)s -o %(outputs)s' cmd = fmt % locals() fulldir = exedir and os.path.isdir(exedir) if fulldir: cmd = os.path.join(exedir, cmd) print "process.py start_local verbose is", verbose if verbose: print "" print "... ... Starting Supercollider Server ... ..." print "" print cmd if fulldir: _cwd = os.getcwd() os.chdir(exedir) proc = None if os.name == 'nt': if wxparentwin == None: # e for use with wx proc = subprocess.Popen(cmd) else: import wx proc = wx.Process(wxparentwin) proc.Redirect() else: proc = popen2.Popen4(cmd) if fulldir: os.chdir(_cwd) time.sleep(.5) if wxparentwin: ret = wx.Execute(cmd, wx.EXEC_ASYNC, proc) else: ret = proc.poll() if not is_alive(ret): raise OSError('Could not start scsynth, error %i' % ret) return _Instance(proc)
def execute(self, cmd): self.process = wx.Process(self.handler) self.process.Redirect() self.pid = wx.Execute(cmd, wx.EXEC_NOHIDE, self.process) self.inputStream = self.process.GetOutputStream() self.errorStream = self.process.GetErrorStream() self.outputStream = self.process.GetInputStream() #self.OnIdle() wx.WakeUpIdle()
def LongRunning(self): """ This runs in the GUI thread but uses wx.Process and wx.Execute to start and monitor a separate process. """ cmd = 'python -u external_program.py' self.process = wx.Process(self) self.process.Redirect() wx.Execute(cmd, wx.EXEC_ASYNC, self.process)
def reset(self): self.SetReadOnly(0) self.ClearAll() self.commandlist = [] self.current_command_pos = -1 self.process = wx.Process(self) self.process.Redirect() self.pip = wx.Execute(self.parent.setting.CALL_PYTHON, wx.EXEC_ASYNC, self.process) self.input = self.process.GetInputStream() self.output = self.process.GetOutputStream() self.error = self.process.GetErrorStream() self.getOutput()
def OnExecuteBtn(self, evt): cmd = self.cmd.GetValue() self.process = wx.Process(self) self.process.Redirect() pid = wx.Execute(cmd, wx.EXEC_ASYNC, self.process) self.inp.Enable(True) self.sndBtn.Enable(True) self.termBtn.Enable(True) self.cmd.Enable(False) self.exBtn.Enable(False) self.inp.SetFocus()
def __init__(self, parent, cmd, end_callback): self.process = wx.Process(parent) self.process.Redirect() self.process.pid = wx.Execute(cmd, wx.EXEC_ASYNC, self.process) self.b = [] self.last_result = '' if self.process.pid: #what was up with wx.Process.Get*Stream names? self.process._stdin_ = self.process.GetOutputStream() self.process._stdout_ = self.process.GetInputStream() self.process._stderr_ = self.process.GetErrorStream() self.process.Bind(wx.EVT_END_PROCESS, end_callback) return raise StartupError
def OnExecuteBtn(self, evt): cmd = self.cmd.GetValue() self.process = wx.Process(self) self.process.Redirect(); pid = wx.Execute(cmd, wx.EXEC_ASYNC, self.process) self.log.write('OnExecuteBtn: "%s" pid: %s\n' % (cmd, pid)) self.inp.Enable(True) self.sndBtn.Enable(True) self.termBtn.Enable(True) self.cmd.Enable(False) self.exBtn.Enable(False) self.inp.SetFocus()
def Start_Debug_Application ( self, filename ) : if not ( self.filename ) and filename : ##filename = '../PyLab_Works/test_IDE.py' filename = '../PyLab_Works/test_IDE.py' self.filename = filename #print 'FF',filename debugger = 'pdb_my' #'../Lib_Extensions' #'../Lib_Extensions/my_pdb.py' cmd = 'python -u -m ' + debugger + ' ' + filename self.process = wx.Process ( self.Owner ) #self.process.OnTerminate = self.My_Terminate self.process.Redirect() pid = wx.Execute ( cmd, wx.EXEC_ASYNC, self.process ) self.Started = True
def startWebHelp(self): ''' This method start web server for eclipse help . http://localhost:5000/ ''' try: process = wx.Process(self) process.Redirect() dirPath = os.path.dirname(os.path.realpath(__file__)) filePath = os.path.join(dirPath, '..', '..', '..', '..', 'web', 'HelpWeb.py') logger.debug(dirPath) cmd = f'python {filePath}' pid = wx.Execute(cmd, wx.EXEC_ASYNC, process) logger.debug(f'executing: {cmd} pid: {pid}') except Exception as e: logger.error(e)
def EditWith(self, editor): assert self.temppath == None if self.path: path = self.path else: self.temppath = GenerateTempFilePath(self.editor.GetValue()) path = self.temppath assert self.path != None or self.temppath != None assert path != None cmd = editor % path self.process = wx.Process(self) pid = wx.Execute(cmd, wx.EXEC_ASYNC, self.process) if pid: self.LockEditor() else: # can't find program self.temppath = None self.process.Destroy()
def RunCmd(self, command, statustext="Running Command", pagetext="Prompt", redin="", redout="", rederr=""): ''' process = wx.Process(self) if type(command) == unicode: command = command.encode(wx.GetDefaultPyEncoding()) wx.Execute(command, wx.EXEC_ASYNC , process) ''' self.txtPrompt.SetReadOnly(0) self.txtPrompt.SetText(command + '\n') self.txtPrompt.SetScrollWidth(1) self.txtPrompt.editpoint = self.txtPrompt.GetLength() self.txtPrompt.GotoPos(self.txtPrompt.editpoint) self.SetStatusText(statustext, 2) self.txtPrompt.process = wx.Process(self) self.txtPrompt.process.Redirect() self.txtPrompt.pid = wx.Execute(command, wx.EXEC_ASYNC | wx.EXEC_NOHIDE, self.txtPrompt.process) ''' if self.PLATFORM_IS_WIN: self.txtPrompt.pid = wx.Execute(command, wx.EXEC_ASYNC | wx.EXEC_NOHIDE, self.txtPrompt.process) else: self.txtPrompt.pid = wx.Execute(command, wx.EXEC_ASYNC, self.txtPrompt.process) ''' self.txtPrompt.inputstream = self.txtPrompt.process.GetInputStream() self.txtPrompt.errorstream = self.txtPrompt.process.GetErrorStream() self.txtPrompt.outputstream = self.txtPrompt.process.GetOutputStream() self.txtPrompt.process.redirectOut = redout self.txtPrompt.process.redirectErr = rederr self.txtPrompt.SetFocus()
def ExecuteInLog(parent, cmd, logMsg=''): """Run a program and send stdout & stderr to the log window""" if parent.running: msg = ("Please wait till this finishes:\n %s" % parent.running) title = 'Abeni: Error - Wait till external program is finished.' MyMessage(parent, msg, title, "error") return if logMsg: write(parent, logMsg) parent.running = cmd parent.toolbar.EnableTool(parent.StopID, True) parent.process = wx.Process(parent) parent.process.Redirect() pyCmd = "python -u %s/doCmd.py %s" % (modulePath, cmd) parent.pid = wx.Execute(pyCmd, wx.EXEC_ASYNC, parent.process) #parent.pid = wx.Execute("sh -c '%s'" % cmd, wx.EXEC_ASYNC, parent.process) #TODO: Maybe add option to show commands as they execute #write(parent, cmd) ID_Timer = wx.NewId() parent.timer = wx.Timer(parent, ID_Timer) wx.EVT_TIMER(parent, ID_Timer, parent.OnTimer) parent.timer.Start(100)
def start(self, command, stdin): if self.process is not None: #print u'process: busy' #code prior version 0.0.1 logging.warning(u'process: busy') return False #print 'process: executing', command, #code prior version 0.0.1 logging.debug(u'process: executing' + unicode(command)) if stdin is not None: #print 'with', stdin #code prior version 0.0.1 logging.debug(u'with: executing' + unicode(stdin)) #else: #print #code prior version 0.0.1 self.process = wx.Process(self.parent) self.process.Redirect() self.process_pid = wx.Execute(command, wx.EXEC_ASYNC, self.process) #print u'process: exec', self.process_pid #code prior version 0.0.1 logging.debug(u'process: exec' + unicode(self.process_pid)) if self.process_pid == 0: #print u'process: error' #code prior version 0.0.1 logging.error(u'process: error') #self.process_clear() # fallaba aqui self.ended() # parece ser buen reemplazo para lo anterior return None self.process_in = self.process.GetOutputStream() #print u'stream pread', stream if self.process_in is not None and stdin is not None: #print u'process: write', self.process_in.write(stdin), self.process_in.LastWrite() #code prior version 0.0.1 logging.debug(u'process: write' + unicode(self.process_in.write(stdin)) + unicode(self.process_in.LastWrite())) self.process.CloseOutput() self.process_out = self.process.GetInputStream() self.process_err = self.process.GetErrorStream() #print u'stream pwrite', self.process_out #print u'stream perror', self.process_err return True
def Execute(self, script, cmdline, title=""): self.out.AppendText("\nRunning...\n\n") if title: self.title = title self.SetTitle(title) #retrieve game config info projectService = wx.GetApp().GetService(ProjectEditor.ProjectService) project = projectService.GetCurrentProject() base, ext = os.path.splitext(project.GetFilename()) gameConfig = os.path.basename(base) + ".cfg" #spawn process self.process = wx.Process(self) self.process.Redirect() cmd = sys.executable path = os.getcwd() cmd = '%s %s/%s %s' % (cmd, path, script, cmdline) cmd += " gameconfig=%s" % gameConfig self.pid = wx.Execute(cmd, wx.EXEC_ASYNC, self.process) self.Tick()
def run_wiki(self, state): if state.process() is not None: wm.error(self, 'Wiki is already running') return wikexe, exepath = get_wik_cmd() if wikexe is None: wm.error( self, "I cannot determine how to run wik. Please report this to\nthe mailing list (http://groups.google.com/group/wikklytext)\nso that a fix can be developed." ) return proc = wx.Process(self) # send events to me proc.Redirect() # redirect stdin/stdout to pipes cmd = '%s -d %s --no-respawn serve' % (wikexe, state.path()) pid = wx.Execute(cmd, wx.EXEC_ASYNC, proc) #print "STARTED",pid state.setpid(pid) state.setprocess(proc) state.seterror(None) # will set later if fails self.update_row(state)
def OnGoBtn(self, evt): try: if platform.system() == "Windows": cmd = ".\\antonie.exe " else: cmd = "./antonie " cmd += "-1 \"" + self.fastq1.GetValue( ) + "\" -2 \"" + self.fastq2.GetValue( ) + "\" -r \"" + self.fna.GetValue( ) + "\" -a \"" + self.gff.GetValue() + "\"" # print "Go Button pressed, commandline: "+cmd if self.bam.GetValue(): cmd += " -w antonie.bam" if self.unfound.GetValue(): cmd += " -u " self.process = wx.Process(self) self.process.Redirect() pid = wx.Execute(cmd, wx.EXEC_ASYNC, self.process) except: print "Unexpected error:", traceback.print_tb(sys.exc_info()[2])
def check(self): if not self.process: if self.panel.confirmSave( 'File must be saved to be analyzed by Pychecker.'): if self.panel.isNew(): return self.reset() #update wx ListCtrl self.DeleteAllItems() self.InsertStringItem(0, '') self.SetStringItem( 0, 1, '%s checking...' % METHOD_NAMES[self.methodIndex]) self.SetItemBackgroundColour(0, wx.Colour(255, 200, 200)) self.focus() #register idle event eventManager.Register(self.OnIdle, wx.EVT_IDLE, self) #initialize self.index = 1 self.methodIndex = 1 self.started = 1 fileName = self.panel.fileName path = os.path.dirname(fileName) #change path os.chdir(path) #start process self.process = wx.Process(self) self.process.Redirect() #run pychecker cmd = 'python -u %s%s %s%s%s'%\ (QUOTE, os.path.join(self.panel.parentPanel.pathPlugins,METHOD_PATHS[self.methodIndex]), QUOTE, fileName, QUOTE) pid = wx.Execute(cmd, wx.EXEC_ASYNC, self.process) else: self.panel.parentPanel.message( 'Sorry, only one pycheck at a time.')
def OnExecuteBtn(self, cmd): self.process = wx.Process(self) self.process.Redirect() pid = wx.Execute(cmd, wx.EXEC_ASYNC, self.process) print('OnExecuteBtn: "%s" pid: %s\n' % (cmd, pid))
import os, sys sys.path[0:0] = [os.pardir] from ChildProcessClient import spawnChild import wx from time import sleep import threading class Monitor: def isAlive(self): return 1 monitor = Monitor() process = wx.Process() process.Redirect() def pollStreams(): stream = process.GetInputStream() if not stream.eof(): print '<<' + stream.read() + '>>' stream = process.GetErrorStream() if not stream.eof(): print '<<<' + stream.read() + '>>>' poll_streams = 1 def streamPollThread(): while poll_streams: pollStreams() sleep(0.15)
def B ( self, event ): cmd = 'python -u -m pdb D:/Data_Python_25/PyLab_Works/test_IDE.py"' self.process = wx.Process(self) self.process.Redirect(); pid = wx.Execute(cmd, wx.EXEC_ASYNC, self.process)
def B(self, event): cmd = 'python -u -m pdb test_IDE.py"' self.process = wx.Process(self) self.process.Redirect() pid = wx.Execute(cmd, wx.EXEC_ASYNC, self.process)
def RunCommand(win, command, redirect=True, hide=False, input_decorator=None, callback=None): """replace $file = current document filename""" global input_appendtext #test if there is already a running process if hasattr(win, 'messagewindow' ) and win.messagewindow and win.messagewindow.process: common.showmessage( win, tr("The last process didn't stop yet. Please stop it and try again." )) return if input_decorator: input_appendtext = input_decorator(appendtext) else: input_appendtext = appendtext if redirect: win.createMessageWindow() win.panel.showPage(tr('Messages')) win.callplugin('start_run', win, win.messagewindow) win.messagewindow.SetReadOnly(0) win.messagewindow.callback = callback appendtext(win.messagewindow, '> ' + command + '\n') win.messagewindow.editpoint = win.messagewindow.GetLength() win.messagewindow.writeposition = win.messagewindow.GetLength() win.SetStatusText(tr("Running "), 0) try: win.messagewindow.process = wx.Process(win) win.messagewindow.process.Redirect() if wx.Platform == '__WXMSW__': if hide == False: win.messagewindow.pid = wx.Execute( command, wx.EXEC_ASYNC | wx.EXEC_NOHIDE, win.messagewindow.process) else: win.messagewindow.pid = wx.Execute( command, wx.EXEC_ASYNC, win.messagewindow.process) else: win.messagewindow.pid = wx.Execute( command, wx.EXEC_ASYNC | wx.EXEC_MAKE_GROUP_LEADER, win.messagewindow.process) if hasattr(win.messagewindow, 'inputstream') and win.messagewindow.inputstream: win.messagewindow.inputstream.close() win.messagewindow.inputstream = win.messagewindow.process.GetInputStream( ) win.messagewindow.outputstream = win.messagewindow.process.GetOutputStream( ) win.messagewindow.errorstream = win.messagewindow.process.GetErrorStream( ) except: win.messagewindow.process = None dlg = wx.MessageDialog( win, tr("There are some issues with running the program.\nPlease run it in the shell." ), "Error", wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() else: wx.Execute(command, wx.EXEC_ASYNC)
def Start(self): """ Starts the compilation process. """ # Change the directory to the compilation folder os.chdir(opj(self.buildDir)) # Verify if it is a dry-run or a real compilation dryRun = (self.run and [""] or ["--dry-run"])[0] # Create a temporary file that we will delete later if self.compiler == "PyInstaller": suffix = ".spec" elif self.compiler == "vendorid": if wx.Platform == "__WXMSW__": suffix = ".bat" else: suffix = ".sh" else: suffix = ".py" # Run the setup.py optimized, if the user chose to configuration = self.project[self.compiler] optimize = "" if "optimize" in configuration: value = int(configuration["optimize"]) if value > 0: optimize = "-" + "O"*value setupScript = self.setupScript fd, tmpFileName = tempfile.mkstemp(suffix=suffix, dir=self.buildDir) if wx.Platform == "__WXMSW__": separator = "&" else: separator = ";" # Build the compilation command if self.compiler == "py2exe": cmd = '%s %s -u "%s" %s %s'%(self.pythonVersion, optimize, tmpFileName, self.compiler, dryRun) elif self.compiler == "cx_Freeze": distDir = configuration["dist_dir"] distChoice = configuration["dist_dir_choice"] if not distDir.strip() or not distChoice: distDir = "dist" cmd = '%s %s -u "%s" %s%s'%(self.pythonVersion, optimize, tmpFileName, "build --build-exe=", distDir) elif self.compiler == "bbfreeze": cmd = '%s %s -u "%s"'%(self.pythonVersion, optimize, tmpFileName) elif self.compiler == "PyInstaller": pyInstallerPath = self.MainFrame.GetPyInstallerPath() build = os.path.normpath(pyInstallerPath + "/Build.py") cmd = '%s %s -u "%s" "%s"'%(self.pythonVersion, optimize, build, tmpFileName) elif self.compiler == "py2app": cmd = '%s %s -u "%s" %s'%(self.pythonVersion, optimize, tmpFileName, self.compiler) elif self.compiler == "vendorid": sibPath, makeOrNmake = self.MainFrame.GetVendorIDPath() sibString = self.setupScript.split(separator) setupScript = '%s %s -u %s %s\n'%(self.pythonVersion, optimize, sibPath, sibString[0]) for strs in sibString[1:]: setupScript += strs + "\n" if wx.Platform == "__WXMSW__": cmd = '%s'%tmpFileName else: cmd = 'chmod +x %s; ./%s'%(tmpFileName, tmpFileName) # Write the setup script string in the temporary file fid = open(tmpFileName, "wt") fid.write(setupScript) fid.close() # Store the temporary file data self.tmpFileName = (fd, tmpFileName) if self.compiler == "vendorid": os.close(fd) # Monitor the elapsed time self.startTime = time.time() # Start the process, redirecting the output to catch stdio self.process = wx.Process(self.MainFrame) self.process.Redirect() # We want the process to be asynchronous self.pid = wx.Execute(cmd, wx.EXEC_ASYNC, self.process)
def OnStartProcess(self, event): self.log_debug("OnStartProcess") self.process = wx.Process(self) self.process.Redirect() self.run_process(event.pathfilename)
def Extract(self, inputFile, outputFile, mode='AudioExtraction'): """ Perform Audio Extraction, or Media Conversion with the new version. """ # Remember the mode being used self.mode = mode # If we're messing with wxProcess, we need to define a function to clean up if we shut down! def __del__(self): if self.process is not None: self.process.Detach() self.process.CloseOutput() self.process = None # Be prepared to capture the wxProcess' EVT_END_PROCESS self.Bind(wx.EVT_END_PROCESS, self.OnEndProcess) # Windows requires that we change the default encoding for Python for the audio extraction code to work # properly with Unicode files (!!!) This isn't needed on OS X, as its default file system encoding is utf-8. # See python's documentation for sys.getfilesystemencoding() if 'wxMSW' in wx.PlatformInfo: wx.SetDefaultPyEncoding('mbcs') # Build the command line for the appropriate media conversion call if mode == 'AudioExtraction': # -i input file # -vn disable video # -ar 2756 Audio Sampling rate 2756 Hz # -ab 8k Audio Bitrate 8kb/s # -ac 1 Audio Channels 1 (mono) # -acodec pcm_u8 8-bit PCM audio codec # -y overwrite existing destination file programStr = os.path.join(TransanaGlobal.programDir, 'ffmpeg_Transana') if 'wxMSW' in wx.PlatformInfo: programStr += '.exe' process = '"' + programStr + '" "-embedded" "1" "-i" "%s" "-vn" "-ar" "2756" "-ab" "8k" "-ac" "1" "-acodec" "pcm_u8" "-y" "%s"' tempMediaFilename = inputFile tempWaveFilename = outputFile elif mode == 'AudioExtraction-OLD': programStr = os.path.join(TransanaGlobal.programDir, 'audioextract') if 'wxMSW' in wx.PlatformInfo: programStr += '.exe' process = '"' + programStr + '" "%s" "%s"' tempMediaFilename = inputFile.encode('utf8') tempWaveFilename = outputFile.encode('utf8') elif mode == 'CustomConvert': process = self.processCommand if DEBUG: print "WaveformProgress.Extract():", sys.getfilesystemencoding( ) print process % (inputFile, outputFile) print tempMediaFilename = inputFile.encode(sys.getfilesystemencoding()) tempWaveFilename = outputFile.encode(sys.getfilesystemencoding()) else: import TransanaExceptions raise TransanaExceptions.NotImplementedError self.destFile = outputFile # Create a wxProcess object self.process = wx.Process(self) # Call the wxProcess Object's Redirect method. This allows us to capture the process's output! self.process.Redirect() # Encode the filenames to UTF8 so that unicode files are handled properly process = process.encode('utf8') if DEBUG: print "WaveformProgress.Extract():" st = process % (tempMediaFilename, tempWaveFilename) if isinstance(st, unicode): print st.encode('utf8') else: print st print # Call the Audio Extraction program using wxExecute, capturing the output via wxProcess. This call MUST be asynchronous. self.pid = wx.Execute(process % (tempMediaFilename, tempWaveFilename), wx.EXEC_ASYNC, self.process) # On Windows ... if 'wxMSW' in wx.PlatformInfo: # ... reset the default Python encoding to UTF-8 wx.SetDefaultPyEncoding('utf_8') # Note the time when the progress bar started self.progressStartTime = time.time() # Start the timer to get feedback and post progress self.timer.Start(500) # If we're processing Modally ... if self.showModally: # ... show the Progress Dialog modally self.ShowModal() # If we're allowing multiple threads ... else: # ... show the Progress Dialog non-modally self.Show()