예제 #1
0
    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
            )
            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.setcurtime(self.values.current_time)

        return self
예제 #2
0
 def testConversion(self):
     """test timetostring and stringtotime"""
     Time.setcurtime()
     assert type(Time.curtime) is types.FloatType or types.LongType
     assert type(Time.curtimestr) is types.StringType
     assert (Time.cmp(int(Time.curtime), Time.curtimestr) == 0
             or Time.cmp(int(Time.curtime) + 1, Time.curtimestr) == 0)
     time.sleep(1.05)
     assert Time.cmp(time.time(), Time.curtime) == 1
     assert Time.cmp(Time.timetostring(time.time()), Time.curtimestr) == 1
예제 #3
0
 def testConversion(self):
     """test timetostring and stringtotime"""
     Time.setcurtime()
     assert type(Time.curtime) is float or int, Time.curtime
     assert type(Time.curtimestr) is str, Time.curtimestr
     assert (Time.cmp(int(Time.curtime), Time.curtimestr) == 0
             or Time.cmp(int(Time.curtime) + 1, Time.curtimestr) == 0)
     time.sleep(1.05)
     assert Time.cmp(time.time(), Time.curtime) == 1
     assert Time.cmp(Time.timetostring(time.time()), Time.curtimestr) == 1
예제 #4
0
	def testConversion(self):
		"""test timetostring and stringtotime"""
		Time.setcurtime()
		assert type(Time.curtime) is types.FloatType or types.LongType
		assert type(Time.curtimestr) is types.StringType
		assert (Time.cmp(int(Time.curtime), Time.curtimestr) == 0 or
				Time.cmp(int(Time.curtime) + 1, Time.curtimestr) == 0)
		time.sleep(1.05)
		assert Time.cmp(time.time(), Time.curtime) == 1
		assert Time.cmp(Time.timetostring(time.time()), Time.curtimestr) == 1
예제 #5
0
 def testConversion(self):
     """test timetostring and stringtotime"""
     Time.setcurtime()
     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)
예제 #6
0
    def setup(self):
        """
        Prepare the execution of the action.
        """
        # Set default change ownership flag, umask, relay regexps
        os.umask(0o77)
        Time.setcurtime(Globals.current_time)
        SetConnections.UpdateGlobal("client_conn", Globals.local_connection)
        Globals.postset_regexp('no_compression_regexp',
                               Globals.no_compression_regexp_string)
        for conn in Globals.connections:
            conn.robust.install_signal_handlers()
            conn.Hardlink.initialize_dictionaries()

        return 0
예제 #7
0
rf = getrp("regular_file")
rf2 = getrp("two_hardlinked_files1")
exec1 = getrp("executable")
exec2 = getrp("executable2")
sig = getrp("regular_file.sig")
hl1, hl2 = map(getrp, ["two_hardlinked_files1", "two_hardlinked_files2"])
test = getrp("test")
dir = getrp(".")
sym = getrp("symbolic_link")
nothing = getrp("nothing")

target = rpath.RPath(lc, "testfiles/output/out")
out2 = rpath.RPath(lc, "testfiles/output/out2")
out_gz = rpath.RPath(lc, "testfiles/output/out.gz")

Time.setcurtime(1000000000)
Time.setprevtime(999424113)
prevtimestr = "2001-09-02T02:48:33-07:00"
t_pref = "testfiles/output/out.2001-09-02T02:48:33-07:00"
t_diff = "testfiles/output/out.2001-09-02T02:48:33-07:00.diff"

Globals.no_compression_regexp = \
    re.compile(Globals.no_compression_regexp_string, re.I)


class inctest(unittest.TestCase):
    """Test the incrementRP function"""
    def setUp(self):
        Globals.set('isbackup_writer', 1)
        MakeOutputDir()
예제 #8
0
rf = getrp("regular_file")
rf2 = getrp("two_hardlinked_files1")
exec1 = getrp("executable")
exec2 = getrp("executable2")
sig = getrp("regular_file.sig")
hl1, hl2 = map(getrp, ["two_hardlinked_files1", "two_hardlinked_files2"])
test = getrp("test")
dir = getrp(".")
sym = getrp("symbolic_link")
nothing = getrp("nothing")

target = rpath.RPath(lc, "testfiles/output/out")
out2 = rpath.RPath(lc, "testfiles/output/out2")
out_gz = rpath.RPath(lc, "testfiles/output/out.gz")

Time.setcurtime(1000000000)
Time.setprevtime(999424113)
prevtimestr = "2001-09-02T02:48:33-07:00"
t_pref = "testfiles/output/out.2001-09-02T02:48:33-07:00"
t_diff = "testfiles/output/out.2001-09-02T02:48:33-07:00.diff"

Globals.no_compression_regexp = \
			 re.compile(Globals.no_compression_regexp_string, re.I)

class inctest(unittest.TestCase):
	"""Test the incrementRP function"""
	def setUp(self):
		Globals.set('isbackup_writer',1)
		MakeOutputDir()

	def check_time(self, rp):
예제 #9
0
 def set_compatible_timestamps(self):
     if Globals.chars_to_quote.find(b":") > -1:
         SetConnections.UpdateGlobal('use_compatible_timestamps', 1)
         Time.setcurtime(
             Time.curtime)  # update Time.curtimestr on all conns
         log.Log("Enabled use_compatible_timestamps", log.INFO)