def setup_virtualenvs():
 LOG.info('=========================================================')
 LOG.info('########### Setting up virtual environments #############')
 LOG.info('=========================================================')
 pack_dir = cfg.CONF.register.pack
 fail_on_failure = (not cfg.CONF.register.no_fail_on_failure)
 registrar = ResourceRegistrar()
 if pack_dir:
  pack_name = os.path.basename(pack_dir)
  pack_names = [pack_name]
  registrar.register_pack(pack_name=pack_name, pack_dir=pack_dir)
 else:
  base_dirs = content_utils.get_packs_base_paths()
  registrar.register_packs(base_dirs=base_dirs)
  pack_names = registrar.get_registered_packs()
 setup_count = 0
 for pack_name in pack_names:
  try:
   setup_pack_virtualenv(pack_name=pack_name, update=True, logger=LOG)
  except Exception as e:
   exc_info = (not fail_on_failure)
   LOG.warning('Failed to setup virtualenv for pack "%s": %s', pack_name, e, exc_info=exc_info)
   if fail_on_failure:
    raise e
  else:
   setup_count += 1
 LOG.info(('Setup virtualenv for %s pack(s).' % setup_count))

def setup_virtualenvs ( ) : LOG . info ( '=========================================================' ) LOG . info ( '########### Setting up virtual environments #############' ) LOG . info ( '=========================================================' ) pack_dir = cfg . CONF . register . pack fail_on_failure = ( not cfg . CONF . register . no_fail_on_failure ) registrar = ResourceRegistrar ( ) if pack_dir : pack_name = os . path . basename ( pack_dir ) pack_names = [ pack_name ] registrar . register_pack ( pack_name = pack_name , pack_dir = pack_dir ) else : base_dirs = content_utils . get_packs_base_paths ( ) registrar . register_packs ( base_dirs = base_dirs ) pack_names = registrar . get_registered_packs ( ) setup_count = 0 for pack_name in pack_names : try : setup_pack_virtualenv ( pack_name = pack_name , update = True , logger = LOG ) except Exception as e : exc_info = ( not fail_on_failure ) LOG . warning ( 'Failed to setup virtualenv for pack "%s": %s' , pack_name , e , exc_info = exc_info ) if fail_on_failure : raise e else : setup_count += 1 LOG . info ( ( 'Setup virtualenv for %s pack(s).' % setup_count ) )
setup python virtual environments for all the registered or the provided pack .