コード例 #1
0
    def get_signature_chain_at_time(self, time):
        """
        Return signature chain covering specified time

        Tries to find the signature chain covering the given time.  If
        there is none, return the earliest chain before, and failing
        that, the earliest chain.
        """
        if not self.all_sig_chains:
            raise CollectionsError("No signature chains found")

        covering_chains = [c for c in self.all_sig_chains
                           if c.start_time <= time <= c.end_time]
        if covering_chains:
            return covering_chains[-1]  # prefer local if multiple sig chains

        old_chains = [c for c in self.all_sig_chains if c.end_time < time]
        if old_chains:
            return old_chains[-1]
        else:
            # no chains are old enough, give oldest and warn user
            oldest = self.all_sig_chains[0]
            if time < oldest.start_time:
                log.Warn(_("No signature chain for the requested time. "
                           "Using oldest available chain, starting at time %s.") %
                         dup_time.timetopretty(oldest.start_time),
                         log.WarningCode.no_sig_for_time,
                         dup_time.timetostring(oldest.start_time))
            return oldest
コード例 #2
0
ファイル: test_dup_time.py プロジェクト: alanfranz/duplicity
 def testStringtotime(self):
     """Test converting string to time"""
     timesec = int(time.time())
     assert timesec == int(dup_time.stringtotime(dup_time.timetostring(timesec)))
     assert not dup_time.stringtotime("2001-18-83T03:03:03Z")
     assert not dup_time.stringtotime("2001-01-23L03:03:03L")
     assert not dup_time.stringtotime("2001_01_23T03:03:03Z")
コード例 #3
0
ファイル: test_dup_time.py プロジェクト: lorenz/duplicity
 def testStringtotime(self):
     u"""Test converting string to time"""
     timesec = int(time.time())
     assert timesec == int(dup_time.stringtotime(dup_time.timetostring(timesec)))
     assert not dup_time.stringtotime(u"2001-18-83T03:03:03Z")
     assert not dup_time.stringtotime(u"2001-01-23L03:03:03L")
     assert not dup_time.stringtotime(u"2001_01_23T03:03:03Z")
コード例 #4
0
    def get_signature_chain_at_time(self, time):
        """
        Return signature chain covering specified time

        Tries to find the signature chain covering the given time.  If
        there is none, return the earliest chain before, and failing
        that, the earliest chain.
        """
        if not self.all_sig_chains:
            raise CollectionsError("No signature chains found")

        covering_chains = [c for c in self.all_sig_chains
                           if c.start_time <= time <= c.end_time]
        if covering_chains:
            return covering_chains[-1]  # prefer local if multiple sig chains

        old_chains = [c for c in self.all_sig_chains if c.end_time < time]
        if old_chains:
            return old_chains[-1]
        else:
            # no chains are old enough, give oldest and warn user
            oldest = self.all_sig_chains[0]
            if time < oldest.start_time:
                log.Warn(_("No signature chain for the requested time. "
                           "Using oldest available chain, starting at time %s.") %
                         dup_time.timetopretty(oldest.start_time),
                         log.WarningCode.no_sig_for_time,
                         dup_time.timetostring(oldest.start_time))
            return oldest
コード例 #5
0
ファイル: test_dup_time.py プロジェクト: lorenz/duplicity
 def testConversion(self):
     u"""test timetostring and stringtotime"""
     dup_time.setcurtime()
     assert type(dup_time.curtime) in integer_types
     assert isinstance(dup_time.curtimestr, (str, u"".__class__))
     assert (dup_time.cmp(int(dup_time.curtime), dup_time.curtimestr) == 0 or
             dup_time.cmp(int(dup_time.curtime) + 1, dup_time.curtimestr) == 0)
     time.sleep(1.05)
     assert dup_time.cmp(time.time(), dup_time.curtime) == 1
     assert dup_time.cmp(dup_time.timetostring(time.time()), dup_time.curtimestr) == 1
コード例 #6
0
ファイル: test_dup_time.py プロジェクト: alanfranz/duplicity
 def testConversion(self):
     """test timetostring and stringtotime"""
     dup_time.setcurtime()
     assert type(dup_time.curtime) in (types.IntType, types.LongType)
     assert type(dup_time.curtimestr) is types.StringType
     assert (dup_time.cmp(int(dup_time.curtime), dup_time.curtimestr) == 0 or
             dup_time.cmp(int(dup_time.curtime) + 1, dup_time.curtimestr) == 0)
     time.sleep(1.05)
     assert dup_time.cmp(time.time(), dup_time.curtime) == 1
     assert dup_time.cmp(dup_time.timetostring(time.time()), dup_time.curtimestr) == 1
コード例 #7
0
ファイル: test_dup_time.py プロジェクト: henrysher/duplicity
 def testConversion(self):
     """test timetostring and stringtotime"""
     dup_time.setcurtime()
     assert type(dup_time.curtime) in integer_types
     assert isinstance(dup_time.curtimestr, types.StringType)
     assert (dup_time.cmp(int(dup_time.curtime), dup_time.curtimestr) == 0 or
             dup_time.cmp(int(dup_time.curtime) + 1, dup_time.curtimestr) == 0)
     time.sleep(1.05)
     assert dup_time.cmp(time.time(), dup_time.curtime) == 1
     assert dup_time.cmp(dup_time.timetostring(time.time()), dup_time.curtimestr) == 1
コード例 #8
0
 def testConversion(self):
     """test timetostring and stringtotime"""
     dup_time.setcurtime()
     assert type(dup_time.curtime) in (types.IntType, types.LongType)
     assert type(dup_time.curtimestr) is types.StringType
     assert (dup_time.cmp(int(dup_time.curtime), dup_time.curtimestr) == 0
             or dup_time.cmp(
                 int(dup_time.curtime) + 1, dup_time.curtimestr) == 0)
     time.sleep(1.05)
     assert dup_time.cmp(time.time(), dup_time.curtime) == 1
     assert dup_time.cmp(dup_time.timetostring(time.time()),
                         dup_time.curtimestr) == 1
コード例 #9
0
 def to_log_info(self, prefix=''):
     """
     Return summary, suitable for printing to log
     """
     l = []
     for s in self.get_all_sets():
         if s.time:
             type = "full"
             time = s.time
         else:
             type = "inc"
             time = s.end_time
         enc = "enc" if s.encrypted else "noenc"
         l.append("%s%s %s %d %s" % (prefix, type, dup_time.timetostring(time), (len(s)), enc))
     return l
コード例 #10
0
 def to_log_info(self, prefix=''):
     """
     Return summary, suitable for printing to log
     """
     l = []
     for s in self.get_all_sets():
         if s.time:
             type = "full"
             time = s.time
         else:
             type = "inc"
             time = s.end_time
         if s.encrypted:
             enc = "enc"
         else:
             enc = "noenc"
         l.append("%s%s %s %d %s" % (prefix, type, dup_time.timetostring(time), (len(s)), enc))
     return l
コード例 #11
0
ファイル: test_dup_time.py プロジェクト: lorenz/duplicity
 def testConvertion(self):
     t = int(time.time())
     assert dup_time.stringtotime(dup_time.timetostring(t)) == t
コード例 #12
0
ファイル: test_dup_time.py プロジェクト: alanfranz/duplicity
 def testConvertion(self):
     t = int(time.time())
     assert dup_time.stringtotime(dup_time.timetostring(t)) == t