Esempio n. 1
0
 def test_get_item_that_is_a_directory(self):
     fs = filesys.get_file_system('local')
     root = fs.path_from_string(root_path)
     os.mkdir(os.path.join(root_path, 'subdir'))
     item = fs.get_item_at_path(root + ('subdir',))
     self.assertNotEqual(None, item)
     self.assertEqual('directory', item.get_filetype())
Esempio n. 2
0
 def test_get_non_existing_item(self):
     fs = filesys.get_file_system('local')
     root = fs.path_from_string(root_path)
     self.assertRaisesRegex(
         FileNotFoundError,
         'file or directory.*DELETEME_testebakup.*noexist',
         fs.get_item_at_path, root + ('noexist',))
Esempio n. 3
0
 def test_get_existing_item(self):
     fs = filesys.get_file_system('local')
     root = fs.path_from_string(root_path)
     with open(os.path.join(root_path, 'exist'), 'xb') as f:
         f.write(b'Yay!\n')
     item = fs.get_item_at_path(root + ('exist',))
     self.assertEqual(b'Yay!\n', item.get_data_slice(0, 100))
Esempio n. 4
0
 def test_get_filetype_pipe(self):
     fs = filesys.get_file_system('local')
     root = fs.path_from_string(root_path)
     path = root + ('a_file',)
     strpath = os.path.join(root_path, 'a_file')
     os.mkfifo(strpath)
     item = fs.get_item_at_path(path)
     self.assertEqual('pipe', item.get_filetype())
Esempio n. 5
0
 def test_get_filetype_symlink(self):
     fs = filesys.get_file_system('local')
     root = fs.path_from_string(root_path)
     path = root + ('a_file',)
     strpath = os.path.join(root_path, 'a_file')
     os.symlink('target', strpath)
     item = fs.get_item_at_path(path)
     self.assertEqual('symlink', item.get_filetype())
Esempio n. 6
0
 def test_get_filetype_socket(self):
     fs = filesys.get_file_system('local')
     root = fs.path_from_string(root_path)
     path = root + ('a_file',)
     strpath = os.path.join(root_path, 'a_file')
     sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
     sock.bind(strpath)
     item = fs.get_item_at_path(path)
     self.assertEqual('socket', item.get_filetype())
Esempio n. 7
0
 def test_get_filetype_regular(self):
     fs = filesys.get_file_system('local')
     root = fs.path_from_string(root_path)
     path = root + ('a_file',)
     strpath = os.path.join(root_path, 'a_file')
     with open(strpath, 'xb') as f:
         f.write(b'Yay!\n')
     item = fs.get_item_at_path(path)
     self.assertEqual('file', item.get_filetype())
Esempio n. 8
0
 def test_size_of_symlink(self):
     fs = filesys.get_file_system('local')
     root = fs.path_from_string(root_path)
     path = root + ('a_file',)
     with open(os.path.join(root_path, 'target'), 'xb') as f:
         f.write(b'This is the content of the real file\n')
     strpath = os.path.join(root_path, 'a_file')
     os.symlink('target', strpath)
     item = fs.get_item_at_path(path)
     self.assertEqual(37, item.get_size())
Esempio n. 9
0
 def test_readsymlink_on_file(self):
     fs = filesys.get_file_system('local')
     root = fs.path_from_string(root_path)
     path = root + ('a_file',)
     strpath = os.path.join(root_path, 'a_file')
     with open(strpath, 'xb') as f:
         f.write(b'Yay!\n')
     item = fs.get_item_at_path(path)
     self.assertRaisesRegex(
         OSError, 'a_file', item.readsymlink)
Esempio n. 10
0
 def test_delete_file_at_path(self):
     fs = filesys.get_file_system('local')
     root = fs.path_from_string(root_path)
     path = root + ('a_file',)
     strpath = os.path.join(root_path, 'a_file')
     with open(strpath, 'xb') as f:
         f.write(b'Yay!\n')
     self.assertTrue(os.path.exists(strpath))
     fs.delete_file_at_path(path)
     self.assertFalse(os.path.exists(strpath))
     # Deleting non-existing files should "succeed" silently
     fs.delete_file_at_path(path)
     self.assertFalse(os.path.exists(strpath))
     os.mkdir(strpath)
     self.assertRaisesRegex(
         IsADirectoryError, 'a_file', fs.delete_file_at_path, path)
     self.assertTrue(os.path.exists(strpath))
Esempio n. 11
0
 def _read_file(self, bkpath, bkname):
     fs = filesys.get_file_system('local')
     dbpath = fs.path_from_string(os.path.join(bkpath, 'db'))
     with datafile.open_backup_by_name(fs, dbpath, bkname) as df:
         self._read_datafile(df)
Esempio n. 12
0
 def _read_file(self, bkpath):
     fs = filesys.get_file_system('local')
     dbpath = fs.path_from_string(os.path.join(bkpath, 'db'))
     with datafile.open_content(fs, dbpath) as df:
         self._read_datafile(df)
Esempio n. 13
0
def main():
    args = parse_arguments()
    tree = filesys.get_file_system('local')
    db = database.Database(tree, tree.path_from_string(args.database))
    comparer = BackupComparer(db, args.backup[0], args.backup[1])
    comparer.compare()
Esempio n. 14
0
def _fixup_arguments(args):
    if args.config is not None:
        localfs = filesys.get_file_system('local')
        args.config = localfs.path_from_string(args.config)
    if args.command == 'webui':
        args.no_exit = True