def main(): # check cmd try: self, script = sys.argv[:2] except ValueError: error = 'CMD params must be: path_to_script [port] [func] [args]' title = 'Error' if b'' == '': # py2 error = error.decode() title = title.decode() winapi.MessageBox(0, error, title, 0) exit(4) # change output to the stealth system journal if not DEBUG: sys.stdout = sys.stderr = SysJournalOut() # modify the python import system if sys.version_info < (3, 4): # 2.6 - 3.3 import py_stealth.py26 as importer else: # 3.4 and above import py_stealth.py34 as importer sys.meta_path.insert(0, importer.Finder()) # run script directory, filename = os.path.split(script) sys.path.insert(0, directory) exc = False methods.Wait(1) # connect and save a port number into the Connection class try: module = __import__(os.path.splitext(filename)[0]) if len(sys.argv) >= 4: eval("module." + sys.argv[3]) except: if DEBUG or not ERROR_FILTER: raise # clean package files and code from trace trace = traceback.format_exc().splitlines() skip = False for line in trace: if skip: skip = False elif "\\py_stealth\\" in line or '/py_stealth/' in line: skip = True elif "_bootstrap" not in line: sys.stderr.write(line + '\n') if exc: exit(1)
def main(): # check cmd try: self, script = sys.argv[:2] except ValueError: error = 'CMD params must be: path_to_script [port] [func] [args]' utils.show_error_message(error) exit(4) return # change output to the stealth system journal if USE_STEALTH_SYSTEM_JOURNAL: sys.stdout = sys.stderr = SysJournalOut() # modify the python import system if sys.version_info < (3, 4): # 2.6 - 3.3 import py_stealth.py26 as importer else: # 3.4 and above import py_stealth.py34 as importer sys.meta_path.insert(0, importer.Finder()) # run script directory, filename = os.path.split(script) sys.path.insert(0, directory) methods.Wait(1) # connect and save a port number into the Connection class try: module = __import__(os.path.splitext(filename)[0]) if len(sys.argv) >= 4: eval("module." + sys.argv[3]) except Exception as error: if error is SystemExit: pass elif DEBUG or not ERROR_FILTER: raise error else: # clean package files and code from trace trace = traceback.format_exc().splitlines() skip = False for line in trace: if skip: skip = False elif "\\py_stealth\\" in line or '/py_stealth/' in line: skip = True elif "_bootstrap" not in line: sys.stderr.write(line + '\n')