whosonline/netcheck.py
def safe_syscall(cmds, raisemode=False):
    '''Send a command and return both the return code and the output.  If
    used as a compatibility replacement for os.system(), pass
    "raisemode=True", which will mean that you don't get the return
    code, but instead an error.
    '''
    # Split command into list for safer parsing.
    if isinstance(cmds, str):
        cmds = cmds.split()

    import subprocess
    try:
        output = subprocess.check_output(cmds, stderr=subprocess.STDOUT)
        retcode = 0
    except subprocess.CalledProcessError as e:
        retcode = e.returncode
        output = e.output

    if raisemode and retcode:
        raise AssertionError("safe_syscall returned %s on %s" % (retcode, cmds))

    return retcode, output
Send a command and return both the return code and the output.  If
    used as a compatibility replacement for os.system(), pass
    "raisemode=True", which will mean that you don't get the return
    code, but instead an error.
    
Send a command and return both the return code and the output.  If
used as a compatibility replacement for os.system(), pass
"raisemode=True", which will mean that you don't get the return
code, but instead an error.
Send a command and return both the return code and the output . If used as a compatibility replacement for os . system () pass " raisemode = True " which will mean that you don ' t get the return code but instead an error .
def safe_syscall(cmds, raisemode=False):
    if isinstance(cmds, str):
        cmds = cmds.split()
    import subprocess
    try:
        output = subprocess.check_output(cmds, stderr=subprocess.STDOUT)
        retcode = 0
    except subprocess.CalledProcessError as e:
        retcode = e.returncode
        output = e.output
    if raisemode and retcode:
        raise AssertionError("safe_syscall returned %s on %s" % (retcode, cmds))
    return retcode, output
def safe_syscall ( cmds , raisemode = False ) : if isinstance ( cmds , str ) : cmds = cmds . split ( ) import subprocess try : output = subprocess . check_output ( cmds , stderr = subprocess . STDOUT ) retcode = 0 except subprocess . CalledProcessError as e : retcode = e . returncode output = e . output if raisemode and retcode : raise AssertionError ( "safe_syscall returned %s on %s" % ( retcode , cmds ) ) return retcode , output
Send a command and return both the return code and the output.
Send a command and return both the return code and the output .
'''Send a command and return both the return code and the output.  If
    used as a compatibility replacement for os.system(), pass
    "raisemode=True", which will mean that you don't get the return
    code, but instead an error.
    ''' # Split command into list for safer parsing.
cmds
raisemode