Esempio n. 1
0
        def load_module(name, path):
            if path:
                self.sys_path.insert(0, path)

            temp, sys.path = sys.path, self.sys_path
            content = {}
            exec_function('import %s as module' % name, content)
            self._module = content['module']
            sys.path = temp

            if path:
                self.sys_path.pop(0)
Esempio n. 2
0
 def execute_code(code):
     c = "import os; from os.path import *; result=%s"
     variables = {'__file__': module.path}
     try:
         exec_function(c % code, variables)
     except Exception:
         debug.warning('sys path detected, but failed to evaluate')
         return None
     try:
         res = variables['result']
         if isinstance(res, str):
             return os.path.abspath(res)
         else:
             return None
     except KeyError:
         return None
Esempio n. 3
0
 def execute_code(code):
     c = "import os; from os.path import *; result=%s"
     variables = {'__file__': module.path}
     try:
         exec_function(c % code, variables)
     except Exception:
         debug.warning('sys path detected, but failed to evaluate')
         return None
     try:
         res = variables['result']
         if isinstance(res, str):
             return os.path.abspath(res)
         else:
             return None
     except KeyError:
         return None
Esempio n. 4
0
        def load_module(name, path):
            if path:
                self.sys_path.insert(0, path)

            temp, sys.path = sys.path, self.sys_path
            content = {}
            try:
                exec_function('import %s as module' % name, content)
                self._module = content['module']
            except AttributeError:
                # use sys.modules, because you cannot access some modules
                # directly. -> #59
                self._module = sys.modules[name]
            sys.path = temp

            if path:
                self.sys_path.pop(0)
Esempio n. 5
0
        def load_module(name, path):
            if path:
                self.sys_path.insert(0, path)

            temp, sys.path = sys.path, self.sys_path
            content = {}
            try:
                exec_function('import %s as module' % name, content)
                self._module = content['module']
            except AttributeError:
                # use sys.modules, because you cannot access some modules
                # directly. -> #59
                self._module = sys.modules[name]
            sys.path = temp

            if path:
                self.sys_path.pop(0)