"hold onto your butts." - Arnold, Jurassic Park

This commit is contained in:
brent s. 2020-09-04 13:16:24 -04:00
parent 1c8f4da1b1
commit cd29b8d13f
Signed by: bts
GPG Key ID: 8C004C2F93481F6B
3 changed files with 19 additions and 3 deletions

View File

@ -38,15 +38,24 @@ class BaseFetcher(object):
for k, v in self.filechecks['remote'].items(): for k, v in self.filechecks['remote'].items():
if v: if v:
if self.mtime: if self.mtime:
self.timestamps[k] = datetime.datetime.fromtimestamp(float(self.fetch_content(v.path, mtime_only = True))) tstmp = self.fetch_content(v.path, mtime_only = True)
if not isinstance(tstmp, datetime.datetime):
self.timestamps[k] = None
continue
else:
self.timestamps[k] = datetime.datetime.fromtimestamp(float(tstmp))
else: else:
tstmp_raw = self.fetch_content(v.path).decode('utf-8').strip() tstmp_raw = self.fetch_content(v.path).decode('utf-8').strip()
if tstmp_raw == '':
self.timestamps[k] = None
continue
if '%s' in v.fmt: if '%s' in v.fmt:
tstmp = datetime.datetime.fromtimestamp(float(tstmp_raw)) tstmp = datetime.datetime.fromtimestamp(float(tstmp_raw))
else: else:
tstmp = datetime.datetime.strptime(tstmp_raw, v.fmt) tstmp = datetime.datetime.strptime(tstmp_raw, v.fmt)
self.timestamps[k] = tstmp self.timestamps[k] = tstmp
if self.offset: if self.offset:
newval = None
if self.offset.mod == '+' or not self.offset.mod: if self.offset.mod == '+' or not self.offset.mod:
newval = self.timestamps[k] + self.offset.offset newval = self.timestamps[k] + self.offset.offset
elif self.offset.mod == '-': elif self.offset.mod == '-':

View File

@ -121,7 +121,7 @@ class RSync(_base.BaseFetcher):
if stdout != '': if stdout != '':
_logger.debug('STDOUT: {0}'.format(stdout)) _logger.debug('STDOUT: {0}'.format(stdout))
if stderr != '' or (rtrn != 0 and rtrn not in self.rsync_ignores): if stderr != '' or (rtrn != 0 and rtrn not in self.rsync_ignores):
err = rsync_returns.returns[rtrn] err = rsync_returns.returns.get(rtrn, '(UNKNOWN ERROR)')
errmsg = 'Rsync to {0}:{1} returned'.format(self.domain, self.port) errmsg = 'Rsync to {0}:{1} returned'.format(self.domain, self.port)
debugmsg = 'Rsync command {0} returned'.format(' '.join(cmd_str)) debugmsg = 'Rsync command {0} returned'.format(' '.join(cmd_str))
if stderr != '': if stderr != '':
@ -134,6 +134,7 @@ class RSync(_base.BaseFetcher):
_logger.error(errmsg) _logger.error(errmsg)
_logger.debug(debugmsg) _logger.debug(debugmsg)
warnings.warn(errmsg) warnings.warn(errmsg)
return(b'')
if mtime_only: if mtime_only:
raw_content = datetime.datetime.fromtimestamp(os.stat(tf).st_mtime) raw_content = datetime.datetime.fromtimestamp(os.stat(tf).st_mtime)
else: else:

View File

@ -314,7 +314,13 @@ class Distro(object):
update = u.fetcher.timestamps.get('update') update = u.fetcher.timestamps.get('update')
sync = u.fetcher.timestamps.get('sync') sync = u.fetcher.timestamps.get('sync')
if update: if update:
if local_checks and (local_checks[-1] < update): if self.timestamps.get('update'):
if self.timestamps['update'] < update:
_logger.info('Local update timestamp is older than the remote update; syncing.')
_logger.debug('Local update: {0}, remote update: {1}'.format(self.timestamps['update'],
update))
u.has_new = True
elif local_checks and (local_checks[-1] < update):
_logger.info('Newest local timestamp is older than the remote update; syncing.') _logger.info('Newest local timestamp is older than the remote update; syncing.')
_logger.debug('Newest local: {0}, remote update: {1}'.format(local_checks[-1], update)) _logger.debug('Newest local: {0}, remote update: {1}'.format(local_checks[-1], update))
u.has_new = True u.has_new = True