Exemplo n.º 1
0
 def test_no_patch_support(self, db):
     data_dir = os.getcwd()
     t_config = TConfig()
     t_config.DATA_DIR = data_dir
     t_config.UPDATE_PATCHES = False
     config = TransistionDict()
     config.from_object(t_config)
     p = PackageHandler(config, db)
     p.process_packages()
 def test_process_packages(self):
     data_dir = os.getcwd()
     t_config = TConfig()
     t_config.DATA_DIR = data_dir
     t_config.UPDATE_PATCHES = False
     config = Config()
     config.from_object(t_config)
     p = PackageHandler(config)
     p.process_packages()
Exemplo n.º 3
0
 def test_process_packages(self):
     data_dir = os.getcwd()
     t_config = TConfig()
     t_config.DATA_DIR = data_dir
     t_config.UPDATE_PATCHES = False
     config = Config()
     config.from_object(t_config)
     p = PackageHandler(config)
     p.process_packages()
Exemplo n.º 4
0
 def test_no_patch_support(self, db):
     data_dir = os.getcwd()
     t_config = TConfig()
     t_config.DATA_DIR = data_dir
     t_config.UPDATE_PATCHES = False
     config = TransistionDict()
     config.from_object(t_config)
     p = PackageHandler(config, db)
     p.process_packages()
Exemplo n.º 5
0
 def test_init(self):
     data_dir = os.getcwd()
     t_config = TConfig()
     t_config.DATA_DIR = data_dir
     config = Config()
     config.from_object(t_config)
     p = PackageHandler(config)
     assert p.files_dir == os.path.join(data_dir, user_data_dir, 'files')
     assert p.deploy_dir == os.path.join(data_dir, user_data_dir, 'deploy')
 def test_process_packages_fail(self):
     with pytest.raises(PackageHandlerError):
         p = PackageHandler()
         p.process_packages()
Exemplo n.º 7
0
 def _update(self, config):
     self.kh = KeyHandler(config)
     self.key_importer = KeyImporter()
     self.ph = PackageHandler(config)
     self.up = Uploader(config)
Exemplo n.º 8
0
class Core(object):
    """Processes, signs & uploads updates

        Kwargs:

            config (obj): config object
    """
    def __init__(self, config=None):
        self.config = ConfigDict()
        self.db = Storage()
        # Important to keep this before updating config
        if config is not None:
            self.update_config(config)

    def update_config(self, config):
        """Updates internal config

        Args:

            config (obj): config object
        """
        if not hasattr(config, 'DATA_DIR'):
            config.DATA_DIR = None
        if config.DATA_DIR is None:
            config.DATA_DIR = os.getcwd()
        self.config.from_object(config)
        self._update(self.config)

    def _update(self, config):
        self.kh = KeyHandler(config)
        self.key_importer = KeyImporter()
        self.ph = PackageHandler(config)
        self.up = Uploader(config)

    def setup(self):
        "Sets up root dir with required PyUpdater folders"
        self.ph.setup()

    def process_packages(self):
        """Creates hash for updates & adds information about update to
        version file
        """
        self.ph.process_packages()

    def set_uploader(self, requested_uploader):
        """Sets upload destination

        Args:

            requested_uploader (str): upload service. i.e. s3, scp
        """
        self.up.set_uploader(requested_uploader)

    def upload(self):
        "Uploads files in deploy folder"
        self.up.upload()

    def import_keypack(self):
        "Creates signing keys"
        self.key_importer.start()

    def sign_update(self):
        "Signs version file with signing key"
        self.kh.sign_update()
Exemplo n.º 9
0
 def test_process_packages_fail(self):
     with pytest.raises(PackageHandlerError):
         p = PackageHandler()
         p.process_packages()
Exemplo n.º 10
0
 def _update(self, config, db):
     self.kh = KeyHandler(config, db)
     self.ph = PackageHandler(config, db)
     self.up = Uploader(config)
Exemplo n.º 11
0
class Core(object):
    """Processes, signs & uploads updates

        Kwargs:

            config (obj): config object
    """
    def __init__(self, config=None, db=None):
        self.config = TransistionDict()
        # Important to keep this before updating config
        if config is not None:
            self.update_config(config, db)

    def update_config(self, config, db):
        """Updates internal config

        Args:

            config (obj): config object
        """
        if not hasattr(config, 'DATA_DIR'):
            config.DATA_DIR = None
        if config.DATA_DIR is None:
            config.DATA_DIR = os.getcwd()

        if db is None:
            self.db = Storage(config.DATA_DIR)
        else:
            self.db = db
        self.config.from_object(config)
        self._update(self.config, self.db)

    def _update(self, config, db):
        self.kh = KeyHandler(config, db)
        self.ph = PackageHandler(config, db)
        self.up = Uploader(config)

    def setup(self):
        "Sets up root dir with required PyUpdater folders"
        self.ph.setup()

    def process_packages(self):
        """Creates hash for updates & adds information about update to
        version file
        """
        self.ph.process_packages()

    def set_uploader(self, requested_uploader):
        """Sets upload destination

        Args:

            requested_uploader (str): upload service. i.e. s3, scp
        """
        self.up.set_uploader(requested_uploader)

    def upload(self):
        "Uploads files in deploy folder"
        self.up.upload()

    def make_keys(self, count=3):
        "Creates signing keys"
        self.kh.make_keys(count)

    def revoke_key(self, count):
        self.kh.revoke_key(count)

    def get_recent_revoked_key(self):
        return self.kh.get_recent_revoked_key()

    def sign_update(self):
        "Signs version file with signing key"
        self.kh.sign_update()

    def get_public_keys(self):
        "Returns public key"
        return self.kh.get_public_keys()

    def print_public_key(self):
        "Prints public key to console"
        self.kh.print_public_key()
Exemplo n.º 12
0
 def _update(self, config):
     self.kh = KeyHandler()
     self.key_importer = KeyImporter()
     self.ph = PackageHandler(config)
     self.up = Uploader(config)
Exemplo n.º 13
0
class PyUpdater(object):
    """Processes, signs & uploads updates

        Kwargs:

            config (obj): config object
    """
    def __init__(self, config=None):
        self.config = Config()
        # Important to keep this before updating config
        if config is not None:
            self.update_config(config)

    def update_config(self, config):
        """Updates internal config

        Args:

            config (obj): config object
        """
        if not hasattr(config, 'DATA_DIR'):
            config.DATA_DIR = None
        if config.DATA_DIR is None:
            config.DATA_DIR = os.getcwd()
        self.config.from_object(config)
        self._update(self.config)

    def _update(self, config):
        self.kh = KeyHandler()
        self.key_importer = KeyImporter()
        self.ph = PackageHandler(config)
        self.up = Uploader(config)

    def setup(self):
        "Sets up root dir with required PyUpdater folders"
        self.ph.setup()

    def process_packages(self, report_errors=False):
        """Creates hash for updates & adds information about update to
        version file
        """
        self.ph.process_packages(report_errors)

    def set_uploader(self, requested_uploader):
        """Sets upload destination

        Args:

            requested_uploader (str): upload service. i.e. s3, scp
        """
        self.up.set_uploader(requested_uploader)

    def upload(self):
        "Uploads files in deploy folder"
        self.up.upload()

    def get_plugin_names(self):
        return self.up.get_plugin_names()

    def import_keypack(self):
        "Creates signing keys"
        self.key_importer.start()

    def sign_update(self):
        "Signs version file with signing key"
        self.kh.sign_update()
Exemplo n.º 14
0
class PyUpdater(object):
    """Processes, signs & uploads updates

        Kwargs:

            config (obj): config object
    """
    def __init__(self, config=None):
        self.config = Config()
        # Important to keep this before updating config
        if config is not None:
            self.update_config(config)

    def update_config(self, config):
        """Updates internal config

        Args:

            config (obj): config object
        """
        if not hasattr(config, 'DATA_DIR'):
            config.DATA_DIR = None
        if config.DATA_DIR is None:
            config.DATA_DIR = os.getcwd()
        self.config.from_object(config)
        self._update(self.config)

    def _update(self, config):
        self.kh = KeyHandler()
        self.key_importer = KeyImporter()
        self.ph = PackageHandler(config)
        self.up = Uploader(config)

    def setup(self):
        """Sets up root dir with required PyUpdater folders"""
        self.ph.setup()

    def process_packages(self, report_errors=False):
        """Creates hash for updates & adds information about update to
        version file
        """
        self.ph.process_packages(report_errors)

    def set_uploader(self, requested_uploader, keep=False):
        """Sets upload destination

        Args:

            requested_uploader (str): upload service. i.e. s3, scp

            keep (bool): False to delete files after upload.
                         True to keep files. Default False.

        """
        self.up.set_uploader(requested_uploader, keep)

    def upload(self):
        """Uploads files in deploy folder"""
        return self.up.upload()

    def get_plugin_names(self):
        return self.up.get_plugin_names()

    def import_keypack(self):
        """Creates signing keys"""
        return self.key_importer.start()

    def sign_update(self):
        """Signs version file with signing key"""
        self.kh.sign_update()