Ejemplo n.º 1
0
 def test_iso_utc(self):
     when = 1266760143.7841301
     out = time_format.iso_utc_date(when)
     self.failUnlessEqual(out, "2010-02-21")
     out = time_format.iso_utc_date(t=lambda: when)
     self.failUnlessEqual(out, "2010-02-21")
     out = time_format.iso_utc(when)
     self.failUnlessEqual(out, "2010-02-21_13:49:03.784130")
     out = time_format.iso_utc(when, sep="-")
     self.failUnlessEqual(out, "2010-02-21-13:49:03.784130")
Ejemplo n.º 2
0
 def render_lease_expiration_mode(self, ctx, data):
     lc = self.storage.lease_checker
     if lc.mode == "age":
         if lc.override_lease_duration is None:
             ctx.tag["Leases will expire naturally, probably 31 days after "
                     "creation or renewal."]
         else:
             ctx.tag["Leases created or last renewed more than %s ago "
                     "will be considered expired."
                     % abbreviate_time(lc.override_lease_duration)]
     else:
         assert lc.mode == "cutoff-date"
         localizedutcdate = time.strftime("%d-%b-%Y", time.gmtime(lc.cutoff_date))
         isoutcdate = time_format.iso_utc_date(lc.cutoff_date)
         ctx.tag["Leases created or last renewed before %s (%s) UTC "
                 "will be considered expired." % (isoutcdate, localizedutcdate, )]
     if len(lc.mode) > 2:
         ctx.tag[" The following sharetypes will be expired: ",
                 " ".join(sorted(lc.sharetypes_to_expire)), "."]
     return ctx.tag
Ejemplo n.º 3
0
 def lease_expiration_mode(self, req, tag):
     lc = self._storage.lease_checker
     if lc.mode == "age":
         if lc.override_lease_duration is None:
             tag("Leases will expire naturally, probably 31 days after "
                 "creation or renewal.")
         else:
             tag("Leases created or last renewed more than %s ago "
                 "will be considered expired." %
                 abbreviate_time(lc.override_lease_duration))
     else:
         assert lc.mode == "cutoff-date"
         localizedutcdate = time.strftime("%d-%b-%Y",
                                          time.gmtime(lc.cutoff_date))
         isoutcdate = time_format.iso_utc_date(lc.cutoff_date)
         tag("Leases created or last renewed before %s (%s) UTC "
             "will be considered expired." % (
                 isoutcdate,
                 localizedutcdate,
             ))
     if len(lc.mode) > 2:
         tag(" The following sharetypes will be expired: ",
             " ".join(sorted(lc.sharetypes_to_expire)), ".")
     return tag