Esempio n. 1
0
    def __init__(self, **overrides):
        Program.__init__(self, **overrides)
        internal_exec_path= self.getInternalExecPath()
        internal_exec_dir= os.path.dirname(internal_exec_path)
        module_path= self.getPythonModulePath()

        base_exec_dir= internal_exec_dir[:-len(module_path)]
        base_exec_dir= os.path.dirname(base_exec_dir)

        def mkInit(d):
            logging.debug("** "+d)
            try:
                os.mkdir(d)
            except:
                pass
            try:
                os.mknod(os.path.join(d, '__init__.py'))
                logging.debug("\t**! "+d)
            except:
                pass

        to_init= base_exec_dir
        mkInit(to_init)
        subdirs= module_path.split('/')
        for d in subdirs:
            to_init= os.path.join(to_init, d)
            mkInit(to_init)
            
        os.environ['PYTHONPATH']= base_exec_dir+':'+os.getenv('PYTHONPATH','')
        
        logging.debug("PYTHONPATH: "+os.environ['PYTHONPATH']+"\tinternal_exec_path="+internal_exec_path)
        logging.debug("NAME: "+self.name)
        p= ppath.expandEnvVariables(self.name)
        logging.debug("path: "+p)
Esempio n. 2
0
def find_local_program(name):
    name= ppath.expandEnvVariables(name)
    name2, ext= os.path.splitext(name)
    if ext=='.so':
        name= name2
    if os.path.exists( name ) or \
           os.path.exists( name+'.cc' ):
        return os.path.abspath(name)
    logging.debug("Could not find local program %s" % name)
    raise core.PyTestUsageError(
        "The '%s' program was not found in %s."%(name, os.getcwd()))
Esempio n. 3
0
def find_local_program(name):
    name = ppath.expandEnvVariables(name)
    name2, ext = os.path.splitext(name)
    if ext == '.so':
        name = name2
    if os.path.exists( name ) or \
           os.path.exists( name+'.cc' ):
        return os.path.abspath(name)
    logging.debug("Could not find local program %s" % name)
    raise core.PyTestUsageError("The '%s' program was not found in %s." %
                                (name, os.getcwd()))
Esempio n. 4
0
 def getPythonModulePath(self):
     if hasattr(self, '_python_module_path'):
         return self._python_module_path
     pythonpath= os.getenv('PYTHONPATH','').split(':')
     module_path= None
     common_prefix= None
     name= ppath.expandEnvVariables(self.name)
     for p in pythonpath:
         c= os.path.commonprefix([p, name])
         if c == p:
             logging.debug("Common Prefix Match: "+c+' -- '+repr(name[len(p):].split('/')))
             module_path= name[len(p):]
             while module_path[0] == '/':
                 module_path= module_path[1:]
             while module_path[-1] == '/':
                 module_path= module_path[:-1]
             module_path= os.path.dirname(module_path)
             common_prefix= c
             break
         else:
             logging.debug("NO Common Prefix: "+p+' -- '+name)
     self._python_module_path= module_path
     return module_path
Esempio n. 5
0
 def getPythonModulePath(self):
     if hasattr(self, '_python_module_path'):
         return self._python_module_path
     pythonpath = os.getenv('PYTHONPATH', '').split(':')
     module_path = None
     common_prefix = None
     name = ppath.expandEnvVariables(self.name)
     for p in pythonpath:
         c = os.path.commonprefix([p, name])
         if c == p:
             logging.debug("Common Prefix Match: " + c + ' -- ' +
                           repr(name[len(p):].split('/')))
             module_path = name[len(p):]
             while module_path[0] == '/':
                 module_path = module_path[1:]
             while module_path[-1] == '/':
                 module_path = module_path[:-1]
             module_path = os.path.dirname(module_path)
             common_prefix = c
             break
         else:
             logging.debug("NO Common Prefix: " + p + ' -- ' + name)
     self._python_module_path = module_path
     return module_path
Esempio n. 6
0
    def __init__(self, **overrides):
        Program.__init__(self, **overrides)
        internal_exec_path = self.getInternalExecPath()
        internal_exec_dir = os.path.dirname(internal_exec_path)
        module_path = self.getPythonModulePath()

        base_exec_dir = internal_exec_dir[:-len(module_path)]
        base_exec_dir = os.path.dirname(base_exec_dir)

        def mkInit(d):
            logging.debug("** " + d)
            try:
                os.mkdir(d)
            except:
                pass
            try:
                os.mknod(os.path.join(d, '__init__.py'))
                logging.debug("\t**! " + d)
            except:
                pass

        to_init = base_exec_dir
        mkInit(to_init)
        subdirs = module_path.split('/')
        for d in subdirs:
            to_init = os.path.join(to_init, d)
            mkInit(to_init)

        os.environ['PYTHONPATH'] = base_exec_dir + ':' + os.getenv(
            'PYTHONPATH', '')

        logging.debug("PYTHONPATH: " + os.environ['PYTHONPATH'] +
                      "\tinternal_exec_path=" + internal_exec_path)
        logging.debug("NAME: " + self.name)
        p = ppath.expandEnvVariables(self.name)
        logging.debug("path: " + p)