Exemple #1
0
 def run_script(self, fname):
     if not fname or not os.path.exists(fname):
         dlg = gtk.MessageDialog(self, gtk.DIALOG_DESTROY_WITH_PARENT,
                                 gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
                                 "Invalid filename " + fname)
         dlg.run()
         return
     args = dialogs.InputBox("Arguments",
                             "Enter any command line arguments", self)
     if args == None: return
     os.system(VT_CMD + 'python "' + fname + '" ' + args + ' &')
     return
Exemple #2
0
 def do_run(self, _b=None):
     line = dialogs.InputBox("Execute Code", "Enter code to execute:", self)
     if line == None: return
     locals = self.curframe.f_locals
     globals = self.curframe.f_globals
     globals['__privileged__'] = 1
     try:
         code = compile(line + '\n', '<stdin>', 'single')
         exec code in globals, locals
     except:
         if type(sys.exc_type) == type(''):
             exc_type_name = sys.exc_type
         else:
             exc_type_name = sys.exc_type.__name__
         self.set_status('*** ' + exc_type_name + ': ' + str(sys.exc_value))
         return
     self.update_var_listing()
     return
Exemple #3
0
 def do_edit(self, _b=None):
     locals = self.curframe.f_locals
     varname = self.vardisp.varnames[self.vardisp.selected]
     val = repr.repr(locals[varname])
     value = dialogs.InputBox("Edit Variable",
                              "Enter new value for " + varname + ":", self,
                              val)
     if value == None: return
     globals = self.curframe.f_globals
     globals['__privileged__'] = 1
     try:
         val = eval(value, globals, locals)
         self.curframe.f_locals[varname] = val
     except:
         if type(sys.exc_type) == type(''):
             exc_type_name = sys.exc_type
         else:
             exc_type_name = sys.exc_type.__name__
         self.set_status('*** ' + exc_type_name + ': ' + str(sys.exc_value))
         return
     row = self.vardisp.selected
     model = self.vardisp.get_model()
     model[row][1] = type(val).__name__
     model[row][2] = repr.repr(val)