def connect(self): """ Connect to potentially provided locations arguments, remote or local. Defines the current time as being the time of a potentially upcoming backup. Returns self, to be used as context manager. """ if 'locations' in self.values: # TODO encapsulate the following lines into one # connections/connections_mgr construct, so that the action doesn't # need to care about cmdpairs and Security (which would become a # feature of the connection). cmdpairs = SetConnections.get_cmd_pairs( self.values.locations, remote_schema=self.remote_schema, ssh_compression=self.values.ssh_compression, remote_tempdir=self.remote_tempdir, term_verbosity=log.Log.term_verbosity) Security.initialize(self.get_security_class(), cmdpairs) self.connected_locations = list( map(SetConnections.get_connected_rpath, cmdpairs)) else: Security.initialize(self.get_security_class(), []) self.connected_locations = [] # once the connection is set, we can define "now" as being the current # time, unless the user defined a fixed a current time. Time.set_current_time(self.values.current_time) return self
def testConversion(self): """test timetostring and stringtotime""" Time.set_current_time() self.assertIsInstance(Time.curtime, (float, int)) self.assertIsInstance(Time.curtimestr, str) self.assertTrue( self.cmp_times(int(Time.curtime), Time.curtimestr) == 0 or self.cmp_times(int(Time.curtime) + 1, Time.curtimestr) == 0) time.sleep(1.05) self.assertEqual(self.cmp_times(time.time(), Time.curtime), 1) self.assertEqual( self.cmp_times(Time.timetostring(time.time()), Time.curtimestr), 1)
def set_compatible_timestamps(self): if Globals.chars_to_quote.find(b":") > -1: Globals.set_all('use_compatible_timestamps', 1) # Update the current time string to new timestamp format Time.set_current_time(Time.getcurtime()) log.Log("Enabled use_compatible_timestamps", log.INFO)
rf2 = getrp(b"two_hardlinked_files1") exec1 = getrp(b"executable") exec2 = getrp(b"executable2") sig = getrp(b"regular_file.sig") hl1, hl2 = list( map(getrp, [b"two_hardlinked_files1", b"two_hardlinked_files2"])) test = getrp(b"test") dir = getrp(b".") sym = getrp(b"symbolic_link") nothing = getrp(b"nothing") target = rpath.RPath(lc, os.path.join(abs_output_dir, b"out")) out2 = rpath.RPath(lc, os.path.join(abs_output_dir, b"out2")) out_gz = rpath.RPath(lc, os.path.join(abs_output_dir, b"out.gz")) Time.set_current_time(1000000000) Time.setprevtime_compat200(999424113) if os.name == "nt": prevtimestr = b"2001-09-02T02-48-33-07-00" else: prevtimestr = b"2001-09-02T02:48:33-07:00" t_pref = os.path.join(abs_output_dir, b"out.%s" % prevtimestr) t_diff = os.path.join(abs_output_dir, b"out.%s.diff" % prevtimestr) Globals.postset_regexp_local("no_compression_regexp", actions.DEFAULT_NOT_COMPRESSED_REGEXP, re.I) class inctest(unittest.TestCase): """Test the incrementRP function""" def setUp(self):