diff --git a/sarracenia/config.py b/sarracenia/config.py index 0c61d2743..b86b1cf9e 100755 --- a/sarracenia/config.py +++ b/sarracenia/config.py @@ -264,8 +264,6 @@ def __repr__(self) -> str: 'msg_rename_dmf': [ 'callback', 'accept.renamedmf.RenameDMF'], 'msg_hour_tree': [ 'callback', 'accept.hourtree.HourTree'], 'msg_renamer': [ 'callback', 'accept.renamer.Renamer'], - 'msg_2http': [ 'callback', 'accept.tohttp.ToHttp'], - 'msg_2local': [ 'callback', 'accept.tolocal.ToLocal'], 'msg_http_to_https': [ 'callback', 'accept.httptohttps.HttpToHttps'], 'msg_speedo': [ 'callback', 'accept.speedo.Speedo'], 'msg_WMO_type_suffix': [ 'callback', 'accept.wmotypesuffix.WmoTypeSuffix'], diff --git a/sarracenia/flowcb/accept/tohttp.py b/sarracenia/flowcb/accept/tohttp.py deleted file mode 100755 index d4ef3947f..000000000 --- a/sarracenia/flowcb/accept/tohttp.py +++ /dev/null @@ -1,49 +0,0 @@ -""" -Plugin tohttp.py: - ToHttp is the converse of ToFile. - After processing on a filter, a file URL needs to be turned back into a web url. - Uses savedUrl created by ToFile, to convert file url back to original. - -Usage: - flowcb sarracenia.flowcb.accept.tohttp.ToHttp -""" -import logging -import re -import urllib - -from sarracenia.flowcb import FlowCB -logger = logging.getLogger(__name__) - - -class ToHttp(FlowCB): - def __init__(self, options): - super().__init__(options,logger) - - self._ldocroot = None - - #self.o.add_option('baseDir', 'str') - if self.o.baseDir: - self._ldocroot = self.o.baseDir - - self.o.add_option('toHttpRoot', 'str') - if self.o.toHttpRoot: - self._ldocroot = self.o.toHttpRoot - - #self.o.hurlre = re.compile('file:/' + self.o.ldocroot) - - def after_accept(self, worklist): - for message in worklist.incoming: - logger.info("ToHttp message input: baseUrl=%s, relPath=%s" % (message['baseUrl'], message['relPath'])) - - url = urllib.parse.urlparse(message['baseUrl']) - - new_baseUrl = 'http://' + url.netloc - if self._ldocroot != None: - new_baseUrl += self._ldocroot - - new_baseUrl += url.path - - message['baseUrl'] = new_baseUrl.replace('///', '//') - - logger.debug("ToHttp config; baseDir=%s, toHttpRoot=%s" % (self.o.baseDir, self.o.toHttpRoot)) - logger.info("ToHttp message output: baseUrl=%s, relPath=%s" % (message['baseUrl'], message['relPath'])) diff --git a/sarracenia/flowcb/accept/tolocal.py b/sarracenia/flowcb/accept/tolocal.py deleted file mode 100755 index 7f02f9cb2..000000000 --- a/sarracenia/flowcb/accept/tolocal.py +++ /dev/null @@ -1,82 +0,0 @@ -""" -Plugin tolocal.py: - This is a helper script to work with filters. - What a data pump advertises, it will usually use Web URL, but if one is - on a server where the files are available, it is more efficient to access - them as local files, so filters operate on file urls. - -Example: - baseDir /var/www/html - url is http://localhost///input/file.txt - - flowcb sarracenia.flowcb.accept.tolocal.ToLocal # converts web URL to file URL - - http://localhost/ --> file://var/www/html/ - url is now file://var/www/html///input/file.txt - m.savedurl = http://localhost/ - - flowcb sarracenia.flowcb.accept. - - A new file is created in another directory. - url is now file://var/www///output/file.txt - - flowcb sarracenia.flowcb.accept.tohttp.ToHttp # turns the file URL back into a web one. - - file://var/www/html/ --> http:///localhost/ - url is now: http://localhost///output/file.txt - - - The regular expression used to find the web url matches either http or https - and just captures upto the first '/'. - - if you need to capture a different kind of url, such as ... - - https://hostname/~user/ .... - - The easiest way is to set toLocalUrl as follows: - - baseDir /home/user/www - toLocalUrl (https://hostname/~user/) - - the parentheses around the URL set the value of to be put in m.savedurl that - will be restored when the companion plugin msg_2http is called. - -Usage: - flowcb sarracenia.flowcb.accept.tolocal.ToLocal -""" -import logging -import re -from sarracenia.flowcb import FlowCB -logger = logging.getLogger(__name__) - - -class ToLocal(FlowCB): - def __init__(self, options): - super().__init__(options,logger) - - self._ldocroot = None - - if self.o.baseDir: - self._ldocroot = self.o.baseDir - - self.o.add_option('toLocalRoot', 'str') - if self.o.toLocalRoot: - self._ldocroot = self.o.toLocalRoot - - self._lurlre = re.compile("(http[s]{0,1}://[^/]+/)") - - self.o.add_option('toLocalUrl', 'str') - if self.o.toLocalUrl: - self._lurlre = re.compile(self.o.toLocalUrl) - - def after_accept(self, worklist): - for message in worklist.incoming: - # TODO should all these be logger.error? should we append - # to worklist.rejected or worklist.failed at some point? - logger.debug("input: urlstr: %s" % message['urlstr']) - - message['savedurl'] = self._lurlre.match(message['urlstr']).group(1) - message['urlstr'] = 'file:/%s' % self._lurlre.sub(self._ldocroot + '/', message['urlstr']) - - logger.debug("doc_root=%s " % (self.o.baseDir)) - logger.debug("output: savedurl: %s" % (message['savedurl']))