def __configure_logging(self): try: for maybe_file_path in self.__logging_configuration_file_paths(): if not os.path.exists(maybe_file_path): continue else: config_file_path = maybe_file_path filesystem.ensure_parent_directories_exist( self.__log_file_path ) logging.config.fileConfig( config_file_path, defaults={'log_file_path': self.__log_file_path}, disable_existing_loggers=False ) self.__log_application_start() logger.debug( 'Loaded logging configuration from %s', config_file_path ) break except Exception as e: sys.stderr.write( 'Please run %s with sudo.\n' % self.name ) sys.stderr.flush() sys.exit(str(e))
def fetch_all(target_directory, allow_overwrite=False): host_config_dir = os.path.join(target_directory, env.host) for file_name in ALL_CONFIG: local_config_file = os.path.join(host_config_dir, file_name) ensure_parent_directories_exist(local_config_file) if not allow_overwrite and os.path.exists(local_config_file): abort("Refusing to overwrite %s" % (local_config_file)) configuration_fetch(file_name, local_config_file)