Exemplo n.º 1
0
    def test_backup_config_zip(self):
        """
        Test backup_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, '_backup_test.zip')

        self.assertTrue(helpers.backup_config_zip(files, zip_path, here))
        self.assertFalse(helpers.backup_config_zip(files, '/:/_backup_test.zip'))

        if os.path.isfile(zip_path):
            os.remove(zip_path)
Exemplo n.º 2
0
    def test_backup_config_zip(self):
        """
        Test backup_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, '_backup_test.zip')

        self.assertTrue(helpers.backup_config_zip(files, zip_path, here))
        self.assertFalse(helpers.backup_config_zip(files, '/:/_backup_test.zip'))

        if os.path.isfile(zip_path):
            os.remove(zip_path)
Exemplo n.º 3
0
    def backup(backupDir=None):

        finalResult = ''

        if backupDir:
            source = [
                ek(os.path.join, sickbeard.DATA_DIR, 'sickbeard.db'),
                sickbeard.CONFIG_FILE,
                ek(os.path.join, sickbeard.DATA_DIR, 'failed.db'),
                ek(os.path.join, sickbeard.DATA_DIR, 'cache.db')
            ]
            target = ek(os.path.join, backupDir,
                        'sickchill-' + time.strftime('%Y%m%d%H%M%S') + '.zip')

            for (path, dirs, files) in ek(os.walk,
                                          sickbeard.CACHE_DIR,
                                          topdown=True):
                for dirname in dirs:
                    if path == sickbeard.CACHE_DIR and dirname not in [
                            'images'
                    ]:
                        dirs.remove(dirname)
                for filename in files:
                    source.append(ek(os.path.join, path, filename))

            if helpers.backup_config_zip(source, target, sickbeard.DATA_DIR):
                finalResult += "Successful backup to " + target
            else:
                finalResult += "Backup FAILED"
        else:
            finalResult += "You need to choose a folder to save your backup to!"

        finalResult += "<br>\n"

        return finalResult
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
    def _backup(backupDir=None):
        if not backupDir:
            return False
        source = [
            ek(os.path.join, sickbeard.DATA_DIR, 'sickbeard.db'),
            sickbeard.CONFIG_FILE,
            ek(os.path.join, sickbeard.DATA_DIR, 'failed.db'),
            ek(os.path.join, sickbeard.DATA_DIR, 'cache.db')
        ]
        target = ek(os.path.join, backupDir, 'sickrage-' + time.strftime('%Y%m%d%H%M%S') + '.zip')

        for (path, dirs, files) in ek(os.walk, sickbeard.CACHE_DIR, topdown=True):
            for dirname in dirs:
                if path == sickbeard.CACHE_DIR and dirname not in ['images']:
                    dirs.remove(dirname)
            for filename in files:
                source.append(ek(os.path.join, path, filename))

        return helpers.backup_config_zip(source, target, sickbeard.DATA_DIR)
Exemplo n.º 7
0
    def _backup(backupDir=None):
        if not backupDir:
            return False
        source = [
            ek(os.path.join, sickbeard.DATA_DIR, 'sickbeard.db'),
            sickbeard.CONFIG_FILE,
            ek(os.path.join, sickbeard.DATA_DIR, 'failed.db'),
            ek(os.path.join, sickbeard.DATA_DIR, 'cache.db')
        ]
        target = ek(os.path.join, backupDir, 'sickchill-' + time.strftime('%Y%m%d%H%M%S') + '.zip')

        for (path, dirs, files) in ek(os.walk, sickbeard.CACHE_DIR, topdown=True):
            for dirname in dirs:
                if path == sickbeard.CACHE_DIR and dirname not in ['images']:
                    dirs.remove(dirname)
            for filename in files:
                source.append(ek(os.path.join, path, filename))

        return helpers.backup_config_zip(source, target, sickbeard.DATA_DIR)