Commit bce8d44e authored by BODERE's avatar BODERE
Browse files

Merge branch 'hotfix_7.0.1' into 'master'

Fix #91: Add of the "protocol_timeout" parameter in the downloads configuration file

Closes #91

See merge request !52
parents b84a8016 3d153d09
......@@ -62,6 +62,7 @@ class Config:
# Protocol parameters
self.protocol = None
self.protocol_option = None
self.protocol_timeout = None
self.path = None
self.server_address = None
self.server_port = None
......@@ -149,6 +150,8 @@ class Config:
self.protocol = module.PROTOCOL
if 'PROTOCOL_OPTION' in module_attr:
self.protocol_option = module.PROTOCOL_OPTION
if 'PROTOCOL_TIMEOUT' in module_attr:
self.protocol_timeout = module.PROTOCOL_TIMEOUT
if 'PATH' in module_attr:
self.path = module.PATH
if 'SERVER_ADDRESS' in module_attr:
......@@ -296,6 +299,7 @@ class Config:
cfg_str += "<protocol>"
cfg_str += self.getNodeString('protocol')
cfg_str += self.getNodeString('protocol_option')
cfg_str += self.getNodeString('protocol_timeout')
cfg_str += self.getNodeString('path')
cfg_str += self.getNodeString('server_address')
cfg_str += self.getNodeString('server_port')
......@@ -350,7 +354,7 @@ class Config:
class DCheck(object):
def getProtocolObject(self, protocolname, path, option=None):
def getProtocolObject(self, protocolname, path, option=None, timeout=None):
obj = None
if protocolname in ("localpath", "localmove", "localpointer") \
or protocolname == 'file' \
......@@ -397,6 +401,11 @@ class DCheck(object):
fileExtractor=classFileExtractor,
redirector=redirector)
if timeout is not None:
obj.setTimeout(timeout)
log.debug(f"protocol : {protocolname} => set timeout : {obj.getDefaultTimeout()}")
return obj
def getOptions(self, argsList=None):
......@@ -553,7 +562,8 @@ class DCheck(object):
log.debug("Config : " + config.constConfigString())
proto = self.getProtocolObject(config.protocol,
config.path,
config.protocol_option)
config.protocol_option,
config.protocol_timeout)
if proto is None:
raise DC_ConfigError("Unknown protocol : %s" % (config.protocol))
......
......@@ -53,6 +53,8 @@ class AbstractProtocol(object):
self.dataReader = None
self.smart_crawler = False
self.timeout = DEFAULT_TIMEOUT
# unused any more...
#self.last_directory_level = None
#self.timer_level_dict = {}
......@@ -186,6 +188,10 @@ class AbstractProtocol(object):
in subclasses if needed """
return self.check_infos
def setTimeout(self, timeout):
""" set method for timeout, see method above for more info """
self.timeout = timeout
def setCheckInfos(self, check_infos):
""" set the informations to check, verifying if each wanted info
is compliant with the protocol checkable infos
......@@ -219,4 +225,4 @@ class AbstractProtocol(object):
def getDefaultTimeout(self):
""" get method for default timeout, see method above for more info """
return DEFAULT_TIMEOUT
return self.timeout
......@@ -328,6 +328,12 @@ class DCheckReportListingBuilder(IListingBuilder):
self.__download.configuration.source.protocol_option),
"PROTOCOL_OPTION",
"")
self.__writeLineDCheckFileConfig(
configFile,
self.__makeNumericParameter(
self.__download.configuration.settings.protocolTimeout),
"PROTOCOL_TIMEOUT",
"")
self.__writeLineDCheckFileConfig(
configFile,
self.__makeStringParameter(
......
......@@ -681,6 +681,7 @@ class ConfigurationSettings(object):
self.__maxNbOfLinesInAutoListing = None
self.__monitoring = None
self.__projectName = None
self.__protocolTimeout = None
def Read(self):
......@@ -771,6 +772,11 @@ class ConfigurationSettings(object):
self.__projectName = self.__xr.getSubNodeValue(logging.WARNING,
self.__node, 'project_name')
self.__protocolTimeout, readOK = readInteger(
self._log, self.__xr, self.__node, 'protocol_timeout')
if not readOK:
result = False
return result
database_path = property(
......@@ -849,3 +855,10 @@ class ConfigurationSettings(object):
None,
None,
"read only projectName variable")
protocolTimeout = property(
lambda self: self.__protocolTimeout,
None,
None,
"read only protocolTimeout variable")
......@@ -3707,6 +3707,8 @@ class Download(threading.Thread):
self.__configuration.settings.maxNbOfLinesInAutoListing) # default LISTING_AUTO_MAX_LINES_DEFAULT
self._log.log(level, " monitoring : '%s'" %
self.__configuration.settings.monitoring) # default None
self._log.log(level, " protocol timeout : '%s'" %
self.__configuration.settings.protocolTimeout) # default None
self._log.log(level, " " + "-" * 99)
def cleanWorkspace(self):
......
......@@ -10,7 +10,7 @@ author-email = sherleda@ifremer.fr
license = GPLv3
# Python version
requires-python = >=3.8 <3.9
requires-python >=3.8 <3.9
# Installation -------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment