def __init__(self, appname=None, base_dir=None, verbose=0, version=__version__):
"""Constructor."""
+ self._check_date = None
+
description = _(
"Generates a list of all Puppets modules, which are newer "
"in Puppet forge than in a defined environment.")
self._environment = self.default_env
+ self._check_date = datetime.datetime.now(LOCALTZ)
+
super(GetModuleChangesApp, self).__init__(
appname=appname, base_dir=base_dir, verbose=verbose, version=version,
no_cc=True, description=description)
self._environment = val
+ # -----------------------------------------------------------
+ @property
+ def check_date(self):
+ """The timestamp of the check as a datetime object."""
+ return self._check_date
+
+ # -----------------------------------------------------------
+ @property
+ def check_date_str(self):
+ """The timestamp of the check as a string."""
+ if self.check_date is None:
+ return None
+ return format_datetime(self.check_date, 'yyyy-MM-dd HH:mm:ss z', tzinfo=LOCALTZ)
+
# -------------------------------------------------------------------------
def as_dict(self, short=True):
"""
res = super(GetModuleChangesApp, self).as_dict(short=short)
+ res['check_date'] = self.check_date
+ res['check_date_str'] = self.check_date_str
res['default_env'] = self.default_env
res['environment'] = self.environment
version_infos = self.get_newer_modules(module_infos)
self.generate_version_msgs(version_infos)
+ self.error_data.append("\n" + _("Checked at: {}").format(self.check_date_str))
+
# -------------------------------------------------------------------------
def get_newer_modules(self, module_infos):
"Results of checking for newer versions of Puppet modules "
"in environment {!r}:").format(self.environment)
- dt = datetime.datetime.now(LOCALTZ)
- dt_str = format_datetime(dt, 'yyyy-MM-dd HH:mm:ss z', tzinfo=LOCALTZ)
-
if not version_infos:
msg = _(
"Didn't found any modules in environment {!r} with a\n"
"newer version on Puppet Forge.").format(self.environment) + "\n\n:-D"
self.error_data.append(msg)
- self.error_data.append("\n" + _("Checked at: {}").format(dt_str))
+ self.error_data.append("\n" + _("Checked at: {}").format(self.check_date_str))
return
msg = ngettext(
forge_version=str(version_info['forge_version'])
))
- self.error_data.append("\n" + _("Checked at: {}").format(dt_str))
-
# =============================================================================
if __name__ == "__main__":