def test_restore_config_zip(self): """ Test restore_config_zip """ here = os.path.dirname(__file__) files = [f for f in os.listdir(here) if f[-3:] in [".db", ".py"]] zip_path = os.path.join(here, '_restore_test.zip') helpers.backup_config_zip(files, zip_path, here) restore_container = os.path.join(here, '_restore_tests') os.mkdir(restore_container) restore_path = os.path.join(restore_container, 'test') self.assertFalse(helpers.restore_config_zip(os.path.abspath(files[1]), restore_path)) # test invalid zip self.assertTrue(helpers.restore_config_zip(zip_path, restore_path)) self.assertTrue(helpers.restore_config_zip(zip_path, restore_path)) # test extractDir exists if os.path.isfile(zip_path): os.remove(zip_path) if os.path.isdir(restore_container): rmtree(restore_container)
def restore(backupFile=None): finalResult = '' if backupFile: source = backupFile target_dir = ek(os.path.join, sickbeard.DATA_DIR, 'restore') if helpers.restore_config_zip(source, target_dir): finalResult += "Successfully extracted restore files to " + target_dir finalResult += "<br>Restart sickchill to complete the restore." else: finalResult += "Restore FAILED" else: finalResult += "You need to select a backup file to restore!" finalResult += "<br>\n" return finalResult