format; kwargs fix
This commit is contained in:
parent
934a1bd15e
commit
6118cb932a
3 changed files with 13 additions and 27 deletions
|
@ -7,22 +7,6 @@ import subprocess
|
||||||
from .config import LoadedConfig
|
from .config import LoadedConfig
|
||||||
|
|
||||||
|
|
||||||
def _update_kwargs(**kwargs):
|
|
||||||
config = LoadedConfig.get()
|
|
||||||
|
|
||||||
# ensure there is an environment
|
|
||||||
if 'env' not in kwargs:
|
|
||||||
kwargs['env'] = {}
|
|
||||||
|
|
||||||
# add common environment from config
|
|
||||||
if config['runtime:env'] is not None:
|
|
||||||
kwargs['env'].update(config['runtime:env'])
|
|
||||||
|
|
||||||
logging.debug(f"kwargs updated: {kwargs}")
|
|
||||||
|
|
||||||
return kwargs
|
|
||||||
|
|
||||||
|
|
||||||
def _is_executable(filename):
|
def _is_executable(filename):
|
||||||
if filename is None:
|
if filename is None:
|
||||||
return False
|
return False
|
||||||
|
@ -46,7 +30,7 @@ class Executable:
|
||||||
def __init__(self, exe_name):
|
def __init__(self, exe_name):
|
||||||
self.__exe_path = _find_exe_file(exe_name)
|
self.__exe_path = _find_exe_file(exe_name)
|
||||||
|
|
||||||
def __build_cmd(self, args, **kwargs):
|
def __build_cmd(self, args, kwargs):
|
||||||
cmd = [self.__exe_path, *args]
|
cmd = [self.__exe_path, *args]
|
||||||
|
|
||||||
logging.debug(f"Executable cmd{cmd}, kwargs{kwargs}")
|
logging.debug(f"Executable cmd{cmd}, kwargs{kwargs}")
|
||||||
|
@ -54,13 +38,13 @@ class Executable:
|
||||||
|
|
||||||
def run(self, process_args, **kwargs):
|
def run(self, process_args, **kwargs):
|
||||||
return subprocess.run(
|
return subprocess.run(
|
||||||
self.__build_cmd(process_args, **_update_kwargs(**kwargs)),
|
self.__build_cmd(process_args, kwargs),
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
def Popen(self, process_args, **kwargs):
|
def Popen(self, process_args, **kwargs):
|
||||||
return subprocess.Popen(
|
return subprocess.Popen(
|
||||||
self.__build_cmd(process_args, **_update_kwargs(**kwargs)),
|
self.__build_cmd(process_args, kwargs),
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -73,10 +57,9 @@ class Executable:
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
less_process = Executable('less').run(
|
less_process = Executable('less').run([
|
||||||
['-R', '+G'],
|
'-R', '+G'
|
||||||
stdin=process.stdout
|
], stdin=process.stdout)
|
||||||
)
|
|
||||||
|
|
||||||
process.communicate()
|
process.communicate()
|
||||||
return less_process
|
return less_process
|
||||||
|
|
|
@ -88,6 +88,10 @@ class Project:
|
||||||
'TARGETDIR': self.target_dir_name()
|
'TARGETDIR': self.target_dir_name()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# add common environment from config
|
||||||
|
if config['runtime:env'] is not None:
|
||||||
|
kwargs['env'].update(config['runtime:env'])
|
||||||
|
|
||||||
logging.debug(f"kwargs updated: {kwargs}")
|
logging.debug(f"kwargs updated: {kwargs}")
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -19,10 +19,9 @@ class Runner:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# probe for Docker access
|
# probe for Docker access
|
||||||
try:
|
try:
|
||||||
Executable('docker').run(
|
Executable('docker').run([
|
||||||
['ps'],
|
'ps'
|
||||||
check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
|
], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
)
|
|
||||||
|
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
raise PermissionError("Cannot access docker, please get into the docker group or run as root!")
|
raise PermissionError("Cannot access docker, please get into the docker group or run as root!")
|
||||||
|
|
Loading…
Reference in a new issue