Esempio n. 1
0
 def execute(self, action=None):
     text = self.text
     if self.mode.__class__.__name__ == "Shell":
         expanded = util.expandmacro(self.text, shell=True)
     else:
         expanded = util.expandmacro(self.text, shell=False)
     self.hide()
     self.history.append(text)
     self.history.hide()
     ret = self.mode.execute(expanded, action)
     if isinstance(ret, (tuple, list)) and len(ret) == 2:
         self.restart(ret[0], ret[1])
Esempio n. 2
0
 def communicate(self, string=None):
     if self.cmdline.mode.__class__.__name__ != "Shell":
         return
     if string is None:
         string = self.cmdline.text
     cmd = util.expandmacro(string)
     out, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).communicate()
     entries = []
     for line in (out + err).splitlines():
         try:
             line = line.decode()
             line = re.sub(r"[\r]", "", line).expandtabs()
             attr = 0
         except UnicodeError:
             line = "????? - Invalid encoding"
             attr = look.colors["ErrorMessage"]
         entries.append(Entry(line, attr=attr))
     if entries:
         self.show(entries)
     else:
         self.show([Entry("No output: `{0}'".format(cmd))])
Esempio n. 3
0
 def expandmacro(self):
     if self.mode.__class__.__name__ == "Shell":
         self.settext(util.expandmacro(self.text, shell=True))
     else:
         self.settext(util.expandmacro(self.text, shell=False))
     self.edithook()
Esempio n. 4
0
def _enter_exec():
    """Behavior of executable file."""
    widgets.cmdline.start(mode.Shell(), util.expandmacro(" ./%f", shell=True), 0)
Esempio n. 5
0
def python(cmd):
    cmd = util.expandmacro(cmd, shell=False)
    Process().python(cmd)
Esempio n. 6
0
def spawn(cmd, title=None, expandmacro=True):
    if expandmacro:
        cmd = util.expandmacro(cmd, shell=True)
    Process().spawn(cmd, title)