diff options
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/util.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py index c827425ee..291ce64ea 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -24,12 +24,12 @@ def debug(flag): # - developer: the code will drop into PBD on un-handled exception # - ifconfig: prints command and sysfs access on stdout for interface if flag not in ['developer', 'ifconfig']: - return False + return '' return flag if os.path.isfile(f'/tmp/vyos.{flag}.debug') else '' def debug_msg(message, section=''): - if section: + if debug(section): print(f'DEBUG/{section:<6} {message}') @@ -92,6 +92,21 @@ def cmd(command, section='', shell=None, input=None, timeout=None, env=None, return decoded +def call(command, section='', shell=None, input=None, timeout=None, env=None, + universal_newlines=None, stdout=PIPE, stderr=STDOUT, decode=None): + """ does not raise exception on error, returns error code, print output """ + out, code = popen( + command, section, + stdout=stdout, stderr=stderr, + input=input, timeout=timeout, + env=env, shell=shell, + universal_newlines=universal_newlines, + decode=decode, + ) + print(out) + return code + + def read_file(path): """ Read a file to string """ with open(path, 'r') as f: |