def init(): global SCRIPT_DIR, TMP_DIR, PREVIOUS_DIR, DUMB_MODE SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) import libraries import pycompatlayer import atexit # Activate Python compatibility layer pycompatlayer.set_default_encoding() pycompatlayer.fix_all() del libraries # It use only the auto-loaded code if sys.platform_codename == "win": os.system("TITLE "+__app__) # Add tools folder to search path (used from find_executable and subprocess) os.environ["PATH"] = os.path.join(SCRIPT_DIR, "tools", sys.platform_codename) + os.pathsep + os.path.join(SCRIPT_DIR, "tools") + os.pathsep + os.environ.get("PATH", "") if sys.python_bits == 64: os.environ["PATH"] = os.path.join(SCRIPT_DIR, "tools", sys.platform_codename+"64") + os.pathsep + os.environ["PATH"] # Set constants (they won't be changed again) TMP_DIR = None PREVIOUS_DIR = os.getcwd() DUMB_MODE = False if os.environ.get("TERM") == "dumb": DUMB_MODE = True # Register exit handler atexit.register(on_exit) sys.BasePatch = BasePatch
def init(): global SCRIPT_DIR, TMP_DIR, PREVIOUS_DIR, DUMB_MODE SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) if sys.platform == "win32": os.system("TITLE " + __app__) sys.path.append(os.path.join(SCRIPT_DIR, "libs")) import atexit import pycompatlayer # Activate Python compatibility layer pycompatlayer.fix_all() # Add tools folder to search path (used from subprocess) os.environ[ "PATH"] = SCRIPT_DIR + os.sep + "tools" + os.pathsep + os.environ.get( "PATH", "") # Set constants (they won't be changed again) TMP_DIR = None PREVIOUS_DIR = os.getcwd() DUMB_MODE = False if os.environ.get("TERM") == "dumb": DUMB_MODE = True # Register exit handler atexit.register(on_exit)
def test_fix_all(self): self.assertTrue(pycompatlayer.fix_all()) # The code is executed twice during the test in some cases, # this is a workaround to avoid failing. # ToDO: Fix the cause try: import builtins except ImportError: import __builtin__ as builtins del builtins.pycompatlayer
#!/usr/bin/env python import sys import os import subprocess curdir = os.getcwd() sys.path.insert(1, curdir + os.sep + "libs") import pycompatlayer pycompatlayer.fix_all() def func1(object): """This class docstring""" return True try: out = subprocess.check_output(["java", "-version"], stderr=subprocess.STDOUT) #print_(os.linesep+os.linesep+"Output: "+out.decode()); except subprocess.CalledProcessError as e: pass #print_(os.linesep+os.linesep+"E: "+str(e)+os.linesep); #print_("Return: "+str(e.returncode)+os.linesep+"Cmd: "+str(e.cmd)+os.linesep); #print_("Out: "+e.output.decode("utf-8").strip()+os.linesep+"Out: "+e.stdout.decode("utf-8").strip()+os.linesep+"Err: "+str(e.stderr)); #if sys.version_info >= (3, 3): #print_(1) #else: #print_(2)