コード例 #1
0
    def set_uploader(self, requested_uploader):
        """Returns an uploader object. 1 of S3, SCP, SFTP.
        SFTP uploaders not supported at this time.

        Args:
            requested_uploader (string): Either s3 or scp

        Returns:
            object (instance): Uploader object
        """
        if isinstance(requested_uploader, str) is False:
            raise UploaderError(u'Must pass str to set_uploader',
                                expected=True)

        try:  # pragma: no cover
            plugin = self.mgr[requested_uploader]
        except Exception as err:  # pragma: no cover
            log.debug(u'EP CACHE: {}'.format(self.mgr.ENTRY_POINT_CACHE))
            log.error(str(err))
            raise UploaderError(u'Requested uploader is not installed',
                                expected=True)

        self.uploader = plugin.plugin()  # pragma: no cover
        msg = u'Requested uploader: {}'.format(requested_uploader)
        log.debug(msg)  # pragma: no cover

        files = remove_dot_files(os.listdir(self.deploy_dir))  # pragma: no cover
        self.uploader.init(username=self.username,
                           password=self.password,
                           remote_dir=self.remote_dir,
                           host=self.host,
                           files=files)  # pragma: no cover
コード例 #2
0
def setup_func():
    ph.setup()
    kh.make_keys()
    test_data_dir = os.path.abspath(os.path.join(u'tests', u'test data',
                                    u'5.0'))
    with ChDir(test_data_dir):
        files = remove_dot_files(os.listdir(os.getcwd()))
        for f in files:
            shutil.copy(f, ph.new_dir)
    ph.process_packages()
    kh.sign_update()
コード例 #3
0
def setup_func():
    ph.setup()
    kh.make_keys()
    test_data_dir = os.path.abspath(
        os.path.join(u'tests', u'test data', u'5.0'))
    with ChDir(test_data_dir):
        files = remove_dot_files(os.listdir(os.getcwd()))
        for f in files:
            shutil.copy(f, ph.new_dir)
    ph.process_packages()
    kh.sign_update()
コード例 #4
0
def test_patch_creation():
    test_data_dir = os.path.abspath(os.path.join(u'tests', u'test data',
                                    u'5.3'))
    with ChDir(test_data_dir):
        files = remove_dot_files(os.listdir(os.getcwd()))
        for f in files:
            shutil.copy(f, ph.new_dir)
    ph.process_packages()
    kh.sign_update()
    assert os.path.exists(os.path.join(PYI_DATA, u'deploy',
                          u'Not So TUF-arm-1')) is True
    assert os.path.exists(os.path.join(PYI_DATA, u'deploy',
                          u'Not So TUF-mac-1')) is True
コード例 #5
0
def test_patch_creation():
    test_data_dir = os.path.abspath(
        os.path.join(u'tests', u'test data', u'5.3'))
    with ChDir(test_data_dir):
        files = remove_dot_files(os.listdir(os.getcwd()))
        for f in files:
            shutil.copy(f, ph.new_dir)
    ph.process_packages()
    kh.sign_update()
    assert os.path.exists(
        os.path.join(PYI_DATA, u'deploy', u'Not So TUF-arm-1')) is True
    assert os.path.exists(
        os.path.join(PYI_DATA, u'deploy', u'Not So TUF-mac-1')) is True
コード例 #6
0
    def _check_make_patch(self, name, version_str, platform):
        # Check to see if previous version is available to
        # make patch updates
        # Also calculates patch number
        log.debug('Checking if patch creation is possible')
        version = version_string_to_tuple(version_str)
        if bsdiff4 is None:
            return None
        src_file_path = None
        highest_version_str = None
        data_dir = os.path.join(self.files_dir, name)
        if os.path.exists(data_dir):
            with ChDir(data_dir):
                # getting a list of all version folders
                # for current app
                version_dirs = os.listdir(os.getcwd())
                version_dirs = remove_dot_files(version_dirs)

                # Changing version strings into tuples
                fixed_version_dirs = []
                for v in version_dirs:
                    fixed_version_dirs.append(version_string_to_tuple(v))

                # Can't make a patch if no source file to work with
                if len(fixed_version_dirs) < 1:
                    return None

                # highest_version = sorted(fixed_version_dirs)[-1]
                # highest_version_str = version_tuple_to_string(highest_version)

                # # ToDo: Not sure if this is need.
                # #       Will research later.
                # if highest_version > version:
                #     return None

            found = False
            versions_hi_to_low = sorted(fixed_version_dirs, reverse=True)
            for v in versions_hi_to_low:
                if found is True:
                    break
                files = os.listdir(os.path.join(data_dir,
                                   version_tuple_to_string(v)))
                for f in files:
                    if platform in f:
                        found = True
                        highest_version_str = version_tuple_to_string(v)
                        break

            if highest_version_str is None:
                return None
            # Chainging into directory to get absolute path of
            # source file for patch creation later
            target_dir = os.path.join(data_dir, highest_version_str)
            with ChDir(target_dir):
                files = remove_dot_files(os.listdir(os.getcwd()))
                log.debug('Files in {}:\n{}'.format(target_dir, files))
                # If somehow the source file got deleted
                # just return
                if len(files) == 0:
                    return None
                # Getting the correct source matches
                # destination platform
                for f in files:
                    if highest_version_str in f and platform in f:
                        log.debug('Found src file to create patch')
                        log.debug('Src file: {}'.format(f))
                        src_file_path = os.path.abspath(f)
                        break
            # if our list gets exhausted before finding
            # source file then just return None
            if src_file_path is None:
                return None
            return src_file_path, len(fixed_version_dirs)
コード例 #7
0
    def _check_make_patch(self, name, version_str, platform):
        # Check to see if previous version is available to
        # make patch updates
        # Also calculates patch number
        log.debug('Checking if patch creation is possible')
        version = version_string_to_tuple(version_str)
        if bsdiff4 is None:
            return None
        src_file_path = None
        highest_version_str = None
        data_dir = os.path.join(self.files_dir, name)
        if os.path.exists(data_dir):
            with ChDir(data_dir):
                # getting a list of all version folders
                # for current app
                version_dirs = os.listdir(os.getcwd())
                version_dirs = remove_dot_files(version_dirs)

                # Changing version strings into tuples
                fixed_version_dirs = []
                for v in version_dirs:
                    fixed_version_dirs.append(version_string_to_tuple(v))

                # Can't make a patch if no source file to work with
                if len(fixed_version_dirs) < 1:
                    return None

                # highest_version = sorted(fixed_version_dirs)[-1]
                # highest_version_str = version_tuple_to_string(highest_version)

                # # ToDo: Not sure if this is need.
                # #       Will research later.
                # if highest_version > version:
                #     return None

            found = False
            versions_hi_to_low = sorted(fixed_version_dirs, reverse=True)
            for v in versions_hi_to_low:
                if found is True:
                    break
                files = os.listdir(
                    os.path.join(data_dir, version_tuple_to_string(v)))
                for f in files:
                    if platform in f:
                        found = True
                        highest_version_str = version_tuple_to_string(v)
                        break

            if highest_version_str is None:
                return None
            # Chainging into directory to get absolute path of
            # source file for patch creation later
            target_dir = os.path.join(data_dir, highest_version_str)
            with ChDir(target_dir):
                files = remove_dot_files(os.listdir(os.getcwd()))
                log.debug('Files in {}:\n{}'.format(target_dir, files))
                # If somehow the source file got deleted
                # just return
                if len(files) == 0:
                    return None
                # Getting the correct source matches
                # destination platform
                for f in files:
                    if highest_version_str in f and platform in f:
                        log.debug('Found src file to create patch')
                        log.debug('Src file: {}'.format(f))
                        src_file_path = os.path.abspath(f)
                        break
            # if our list gets exhausted before finding
            # source file then just return None
            if src_file_path is None:
                return None
            return src_file_path, len(fixed_version_dirs)