Esempio n. 1
0
 def system(self, cmd):
     if self.background:
         try:
             proc = Popen(cmd, shell=True, executable=self.shell[0],
                          close_fds=True, preexec_fn=os.setsid, stdout=PIPE, stderr=PIPE)
             message.puts("Spawn: {0} ({1})".format(cmd.strip(), proc.pid))
             ProcessNotify(proc, cmd).start()
         except Exception as e:
             message.exception(e)
     else:
         try:
             widget.end_curses()
             os.system("clear")
             proc = Popen(cmd, shell=True, executable=self.shell[0],
                          close_fds=True, preexec_fn=os.setsid)
             proc.wait()
             if not self.quick:
                 util.wait_restore()
             message.puts("Spawn: {0} ({1})".format(cmd.strip(), proc.pid))
         except KeyboardInterrupt as e:
             message.error("KeyboardInterrupt: {0}".format(cmd))
         except Exception as e:
             message.exception(e)
         finally:
             widget.start_curses()
Esempio n. 2
0
 def python(self, cmd):
     cmd = self.parsemacro(cmd)
     try:
         widget.end_curses()
         os.system("clear")
         exec(cmd)
         if not self.quick:
             util.wait_restore()
         message.puts("Eval: {0}".format(cmd))
     except KeyboardInterrupt as e:
         message.error("KeyboardInterrupt: {0}".format(cmd))
     except Exception as e:
         message.exception(e)
     finally:
         widget.start_curses()