Beispiel #1
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()
Beispiel #2
0
 def _update(self, config):
     self.kh = KeyHandler(config)
     self.key_importer = KeyImporter()
     self.ph = PackageHandler(config)
     self.up = Uploader(config)
Beispiel #3
0
 def _update(self, config, db):
     self.kh = KeyHandler(config, db)
     self.ph = PackageHandler(config, db)
     self.up = Uploader(config)
Beispiel #4
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()
Beispiel #5
0
 def _update(self, config):
     self.kh = KeyHandler()
     self.key_importer = KeyImporter()
     self.ph = PackageHandler(config)
     self.up = Uploader(config)
Beispiel #6
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()
Beispiel #7
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()