def startDetached(cmd): """Run a command in the background with psutil Parameters: * cmd (list): command to be executed with its arguments. Returns: psutil.Popen: Object view of the process Notes: * The command is executed by the Popen function of the psutil module. * Since the command is run as a daemon, it does not block the execution of the script. * stdout is captured and forwarded to odpy.proclog_logger. * stderr is captured and forwarded to odpy.proclog_logger. """ try: runningproc = None if isWin(): runningproc = psutil.Popen( cmd, stdout=subprocess.PIPE, \ stderr=subprocess.STDOUT ) else: runningproc = psutil.Popen( cmd, start_new_session=True, \ stdout=subprocess.PIPE, \ stderr=subprocess.STDOUT ) t = threading.Thread(target=log_subprocess_output, args=(runningproc.stdout, )) t.start() except subprocess.CalledProcessError as err: std_msg('Failed: ', err) raise return runningproc
def getDBDict(cmd): ret = execCommand(cmd) retstr = ret.decode('utf-8') if isWin(): retstr = retstr.translate(str.maketrans({"\\": r"\\"})) ret = json.loads(retstr) if ret['Status'] != 'OK': log_msg(ret['Status']) raise FileNotFoundError return ret
def retFileLoc(bstdout): if bstdout == None: return None retstr = bstdout.decode('utf-8') if isWin(): retstr = retstr.translate(str.maketrans({"\\": r"\\"})) fileloc = json.loads(retstr) if fileloc['Status'] != 'OK': log_msg(fileloc['Status']) raise FileNotFoundError return fileloc['File_name']
def retFileLoc( bstdout ): if bstdout == None: return None retstr = bstdout.decode('utf-8') if isWin(): retstr = retstr.translate(str.maketrans({"\\": r"\\"})) fileloc = json.loads( retstr ) if fileloc['Status'] != 'OK': log_msg( fileloc['Status'] ) raise FileNotFoundError return fileloc['data']['File_name']
def startDetached( cmd ): try: if isWin(): runningproc = psutil.Popen( cmd, stdout=get_log_stream(), \ stderr=get_std_stream() ) else: runningproc = psutil.Popen( cmd, start_new_session=True, \ stdout=get_log_stream(), \ stderr=get_std_stream() ) except subprocess.CalledProcessError as err: std_msg( 'Failed: ', err ) raise return runningproc
def startDetached(cmd): try: if isWin(): runningproc = psutil.Popen( cmd, stdout=get_log_stream(), \ stderr=get_std_stream() ) else: runningproc = psutil.Popen( cmd, start_new_session=True, \ stdout=get_log_stream(), \ stderr=get_std_stream() ) except subprocess.CalledProcessError as err: std_msg('Failed: ', err) raise return runningproc
def getDBList(translnm,args=None): cmd = getODCommand(dbmanexe,args) cmd.append( '--json' ) cmd.append( '--list' ) cmd.append( translnm ) ret = execCommand( cmd ) retstr = ret.decode('utf-8') if isWin(): retstr = retstr.translate(str.maketrans({"\\": r"\\"})) db = json.loads( retstr ) if db['Status'] != 'OK': log_msg( db['Status'] ) raise FileNotFoundError return db['data']
def getDBList(translnm, args=None): cmd = getODCommand(dbmanexe, args) cmd.append('--json') cmd.append('--list') cmd.append(translnm) ret = execCommand(cmd) retstr = ret.decode('utf-8') if isWin(): retstr = retstr.translate(str.maketrans({"\\": r"\\"})) ret = json.loads(retstr) if ret['Status'] != 'OK': log_msg(ret['Status']) raise FileNotFoundError return ret