You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
654 B
Python
26 lines
654 B
Python
import subprocess
|
|
import os
|
|
import shutil
|
|
from . import host
|
|
|
|
class Run:
|
|
resource_name = 'run'
|
|
|
|
def __init__(self, label, section):
|
|
self.label = label or None
|
|
self.cmd = section.get('cmd', '').split()
|
|
self.cwd = section.get('cwd', host.dotfiles_root)
|
|
self.shell = section.get('shell', False)
|
|
|
|
def run(self):
|
|
kwargs = {
|
|
"cwd": self.cwd,
|
|
"stdout": subprocess.PIPE,
|
|
"text": True,
|
|
"shell": self.shell,
|
|
}
|
|
with subprocess.Popen(self.cmd, **kwargs) as proc:
|
|
line = proc.stdout.read()
|
|
if line:
|
|
print(line)
|