logger.warn("Downloading the AT&T database from '%s' to '%s' ...",source_url,atnt_downloaded_directory)
logger.warn("To avoid this, please download the database manually, extract the data and set the ATNT_DATABASE_DIRECTORY environment variable to this directory.")
def_is_library_available(function):
@functools.wraps(function)
defwrapper(*args,**kwargs):
try:
importlib.import_module(library)
# to avoid re-downloading in parallel test execution
logger.debug("RESOURCES: Using the resource '%s' from '%s', and ignoring the one from '%s'",resource,entry_points[index].module_name,entry_points[1-index].module_name)
returnentry_points[index].load()
else:
logger.warn("Under the desired name '%s', there are multiple entry points defined, we return the first one: %s",resource,[entry_point.module_nameforentry_pointinentry_points])
returnentry_points[0].load()
# if the resource is neither a config file nor an entry point,
# just execute it as a command
try:
# first, execute all import commands that are required
foriinimports:
exec("import %s"%i)
# now, evaluate the resource (re-evaluate if the resource is still a string)
whileisinstance(resource,six.string_types):
resource=eval(resource)
returnresource
ifkeywordnotinvalid_keywords:
logger.warning(
"The given keyword '%s' is not valid. Please use one of %s!",
keyword,
valid_keywords,
)
exceptExceptionase:
raiseImportError("The given command line option '%s' is neither a resource for a '%s', nor an existing configuration file, nor could be interpreted as a command (error: %s)"%(resource,keyword,str(e)))
# now, we check if the resource is registered as an entry point in the resource files
# if the resource is neither a config file nor an entry point,
# just execute it as a command
try:
# first, execute all import commands that are required
foriinimports:
exec("import %s"%i)
# now, evaluate the resource (re-evaluate if the resource is still a string)
whileisinstance(resource,six.string_types):
resource=eval(resource)
returnresource
exceptExceptionase:
raiseImportError(
"The given command line option '%s' is neither a resource for a '%s', nor an existing configuration file, nor could be interpreted as a command (error: %s)"