Пример #1
0
def main():
    access_token = get_dropbox_access_token()

    parser = argparse.ArgumentParser(
        description='Passing parameter for rabbit youtube....')

    parser.add_argument('--remote_folder', '-r', help='remote folder')
    parser.add_argument('--retention_days',
                        '-d',
                        help='retention days',
                        type=int)
    parser.add_argument('--log_file', '-l', help='log path')
    parser.add_argument('local_file', help='local file', nargs='+')

    args = parser.parse_args()

    remote_folder = args.remote_folder
    retention_days = int(args.retention_days)
    log_file = args.log_file or '/tmp/rabbit-backup.log'
    local_file = args.local_file

    setup_log(log_file)
    logger.info(
        'backup job summary: backup %s to %s and remove backup files %s days ago'
        % (local_file, remote_folder, retention_days))

    rabbit_dropbox_job = BackupJob(access_token, remote_folder, retention_days)
    rabbit_dropbox_job.backup_and_clear_history_data(local_file)
Пример #2
0
 def setUp(self):
     access_token_for_testing = get_access_token_for_t()
     self.backup_job = BackupJob(access_token_for_testing, 'backup_test', 1)
     self.test_file_full_path = os.path.join(current_path,
                                             'test-file_for_uploading')
     f = open(self.test_file_full_path, 'w')
     f.write('test-data')
     f.close()
 def setUp(self):
     access_token_for_testing = get_access_token_for_t()
     self.backup_job = BackupJob(access_token_for_testing, 'backup_test', 1)
     self.test_file_full_path = os.path.join(current_path, 'test-file_for_uploading')
     f = open(self.test_file_full_path, 'w')
     f.write('test-data')
     f.close()
class TestPyBackup(unittest.TestCase):

    def setUp(self):
        access_token_for_testing = get_access_token_for_t()
        self.backup_job = BackupJob(access_token_for_testing, 'backup_test', 1)
        self.test_file_full_path = os.path.join(current_path, 'test-file_for_uploading')
        f = open(self.test_file_full_path, 'w')
        f.write('test-data')
        f.close()

    def test_login(self):
        self.assertTrue('@' in self.backup_job.account['email'])

    def test_upload(self):
        self.backup_job.backup_and_clear_history_data([self.test_file_full_path])

    @unittest.skip('skip the download testing')
    def test_download(self):
        self.backup_job.rabbit_dropbox.get_file("/tmp/test-file", "ibm.pdf")

    def tearDown(self):
        if os.path.isfile(self.test_file_full_path):
            os.remove(self.test_file_full_path)
Пример #5
0
def main():
    access_token = get_dropbox_access_token()

    parser = argparse.ArgumentParser(description='Passing parameter for rabbit youtube....')

    parser.add_argument('--remote_folder', '-r', help='remote folder')
    parser.add_argument('--retention_days', '-d', help='retention days', type=int)
    parser.add_argument('--log_file', '-l', help='log path')
    parser.add_argument('local_file', help='local file', nargs='+')

    args = parser.parse_args()

    remote_folder = args.remote_folder
    retention_days = int(args.retention_days)
    log_file = args.log_file or '/tmp/rabbit-backup.log'
    local_file = args.local_file

    setup_log(log_file)
    logger.info('backup job summary: backup %s to %s and remove backup files %s days ago' %
                (local_file, remote_folder, retention_days))

    rabbit_dropbox_job = BackupJob(access_token, remote_folder, retention_days)
    rabbit_dropbox_job.backup_and_clear_history_data(local_file)
Пример #6
0
class TestPyBackup(unittest.TestCase):
    def setUp(self):
        access_token_for_testing = get_access_token_for_t()
        self.backup_job = BackupJob(access_token_for_testing, 'backup_test', 1)
        self.test_file_full_path = os.path.join(current_path,
                                                'test-file_for_uploading')
        f = open(self.test_file_full_path, 'w')
        f.write('test-data')
        f.close()

    def test_login(self):
        self.assertTrue('@' in self.backup_job.account['email'])

    def test_upload(self):
        self.backup_job.backup_and_clear_history_data(
            [self.test_file_full_path])

    @unittest.skip('skip the download testing')
    def test_download(self):
        self.backup_job.rabbit_dropbox.get_file("/tmp/test-file", "ibm.pdf")

    def tearDown(self):
        if os.path.isfile(self.test_file_full_path):
            os.remove(self.test_file_full_path)