diff --git a/repomirror/__init__.py b/repomirror/__init__.py index e309666..725b28d 100644 --- a/repomirror/__init__.py +++ b/repomirror/__init__.py @@ -4,15 +4,8 @@ import logging ## from . import config from . import constants +from . import sync _logger = logging.getLogger() - -class Sync(object): - def __init__(self, cfg = None, dummy = False, distro = None, logdir = None, *args, **kwargs): - _args = dict(locals()) - del(_args['self']) - _logger.debug('Sync class instantiated with args: {0}'.format(_args)) - self.cfg = config.Config(cfg) - diff --git a/repomirror/sync.py b/repomirror/sync.py new file mode 100644 index 0000000..885c505 --- /dev/null +++ b/repomirror/sync.py @@ -0,0 +1,61 @@ +import datetime +import logging +import os +## +from . import config + + +_logger = logging.getLogger() + + +class Args(object): + def __init__(self, args_xml): + self.xml = args_xml + self.args = [] + self._parse_xml() + + def _parse_xml(self): + for arg_xml in self.xml.xpath('(short|long)'): + + + +class Mount(object): + def __init__(self, mpchk_xml): + self.path = os.path.abspath(os.path.expanduser(mpchk_xml)) + self.is_mounted = None + self._check_mount() + + def _check_mount(self): + with open('/proc/mounts', 'r') as fh: + raw = fh.read() + for line in raw.splitlines(): + l = line.split() + mp = l[1] + if mp == self.path: + self.is_mounted = True + return(None) + self.is_mounted = False + return(None) + + +class TimestampFile(object): + def __init__(self, ts_xml): + self.fmt = ts_xml.attrib.get('timeFormat', 'UNIX_EPOCH') + if self.fmt == 'UNIX_EPOCH': + self.fmt = '%s' + elif self.fmt == 'MICROSECOND_EPOCH': + self.fmt = '%s.%f' + self.path = os.path.abspath(os.path.expanduser(ts_xml.text)) + + +class Upstream(object): + def __init__(self, upstream_xml): + pass + + +class Sync(object): + def __init__(self, cfg = None, dummy = False, distro = None, logdir = None, *args, **kwargs): + _args = dict(locals()) + del(_args['self']) + _logger.debug('Sync class instantiated with args: {0}'.format(_args)) + self.cfg = config.Config(cfg) diff --git a/sample.config.xml b/sample.config.xml index 4e4c692..14c60a8 100644 --- a/sample.config.xml +++ b/sample.config.xml @@ -28,8 +28,8 @@ * https://strftime.org/ The default is to use a regular UNIX Epoch integer (e.g. June 13, 2020 5:03:53 PM UTC => 1592067833). This can be manually specified by the special string "UNIX_EPOCH". - Optionally, you can use the special string "MICROSECOND_EPOCH", which will specify the above with microseconds. - e.g. June 13, 2020 5:09:13.995777 PM UTC => 1592068153.995777 + Optionally, you can use the special string "MICROSECOND_EPOCH", which will specify the above with left-padded + microseconds (e.g. June 13, 2020 5:09:13.995777 PM UTC => 1592068153.995777). --> /srv/http/arch.lastcheck