Exemple #1
0
 def venv_modules(self):
   # The deps are python_requirement_library specs, the reqs are the requirements.txt entries.
   reqs, deps = self.map_python_deps
   analysis_hash = self.analysis_hash(reqs)
   analysis_file = os.path.join(self.workdir, 'python-analysis-{}.json'.format(analysis_hash))
   if not os.path.isfile(analysis_file):
     mapping = get_venv_map(self.python_virtual_envs, deps)
     with open(analysis_file, 'wb') as f:
       json.dump(mapping, f)
   else:
     with open(analysis_file, 'rb') as f:
       # This is an escape hatch in case the json cannot be read. Maybe it should just raise an exception.
       try:
         mapping = json.load(f)
       except Exception:
         logger.debug("Could not read the buildgen analysis file, regenerating: {}.".format(f))
         mapping = get_venv_map(self.python_virtual_envs, deps)
         os.remove(analysis_file)
   return mapping
Exemple #2
0
 def venv_modules(self):
   # The deps are python_requirement_library specs, the reqs are the requirements.txt entries.
   reqs, deps = self.map_python_deps
   analysis_hash = self.analysis_hash(reqs)
   analysis_file = os.path.join(self.workdir, 'python-analysis-{}.json'.format(analysis_hash))
   if not os.path.isfile(analysis_file):
     mapping = get_venv_map(self.python_virtual_envs, deps)
     with open(analysis_file, 'wb') as f:
       json.dump(mapping, f)
   else:
     with open(analysis_file, 'rb') as f:
       # This is an escape hatch in case the json cannot be read. Maybe it should just raise an exception.
       try:
         mapping = json.load(f)
       except Exception:
         logger.debug("Could not read the buildgen analysis file, regenerating: {}.".format(f))
         mapping = get_venv_map(self.python_virtual_envs, deps)
         os.remove(analysis_file)
   return mapping