Ejemplo n.º 1
0
    def __init__(self, name):
        super(Package, self).__init__(self, name=name)

        self.maybe_update_pkgbuild_repo()

        try:
            if (not self.pkgname or self.pkgname == '') and os.path.exists(os.path.join(REPO_DIR, name)):

                key_lists = ['redis_string', 'redis_string_bool', 'redis_string_int', 'redis_list', 'redis_zset']
                for key_list_name in key_lists:
                    key_list = self.all_keys[key_list_name]
                    for key in key_list:
                        if key_list_name.endswith('string') and key != 'name':
                            setattr(self, key, '')
                        elif key_list_name.endswith('bool'):
                            setattr(self, key, False)
                        elif key_list_name.endswith('int'):
                            setattr(self, key, 0)
                        elif key_list_name.endswith('list'):
                            setattr(self, key, RedisList.as_child(self, key, str))
                        elif key_list_name.endswith('zset'):
                            setattr(self, key, RedisZSet.as_child(self, key, str))

            self.pkgname = name
            next_id = db.incr('antbs:misc:pkgid:next')
            self.pkg_id = next_id
            all_pkgs = status.all_packages()
            all_pkgs.add(self.name)
        except Exception:
            logger.error('unable to init package object for %s', name)
Ejemplo n.º 2
0
    def __init__(self, name):
        super(Package, self).__init__(self, name=name)

        self.maybe_update_pkgbuild_repo()

        if not self or not self.pkg_id and (os.path.exists(os.path.join(REPO_DIR, name)) or self.is_deepin_pkg()):
            # Package is not in the database, so it must be new. Let's initialize it.
            for key in self.all_keys:
                if key in self.key_lists['redis_string'] and key != 'name':
                    setattr(self, key, '')
                elif key in self.key_lists['redis_string_bool']:
                    setattr(self, key, False)
                elif key in self.key_lists['redis_string_int']:
                    setattr(self, key, 0)
                elif key in self.key_lists['redis_list']:
                    setattr(self, key, RedisList.as_child(self, key, str))
                elif key in self.key_lists['redis_zset']:
                    setattr(self, key, RedisZSet.as_child(self, key, str))
            self.pkgname = name
            next_id = db.incr('antbs:misc:pkgid:next')
            self.pkg_id = next_id
            all_pkgs = status.all_packages
            all_pkgs.add(self.name)

            if '-x86_64' in self.name or '-i686' in self.name:
                self.is_iso = True
            else:
                self.is_iso = False
Ejemplo n.º 3
0
    def __init__(self, pkg_obj=None, bnum=None):
        if not pkg_obj and not bnum:
            raise AttributeError

        super(BuildObject, self).__init__()

        self.key_lists = dict(
            redis_string=['pkgname', 'pkgver', 'epoch', 'pkgrel', 'path', 'build_path', 'start_str', 'end_str',
                          'version_str', 'container', 'review_status', 'review_dev', 'review_date', 'log_str'],
            redis_string_bool=['failed', 'completed'],
            redis_string_int=['pkg_id', 'bnum'],
            redis_list=['log'],
            redis_zset=[])

        self.all_keys = [item for sublist in self.key_lists.values() for item in sublist]

        if not bnum:
            next_bnum = db.incr('antbs:misc:bnum:next')
            self.namespace = 'antbs:build:%s:' % next_bnum
            self.prefix = self.namespace[:-1]
            for key in self.all_keys:
                if key in self.key_lists['redis_string']:
                    value = getattr(pkg_obj, key, '')
                    setattr(self, key, value)
                elif key in self.key_lists['redis_string_bool']:
                    value = getattr(pkg_obj, key, False)
                    setattr(self, key, value)
                elif key in self.key_lists['redis_string_int']:
                    value = getattr(pkg_obj, key, 0)
                    setattr(self, key, value)
                elif key in self.key_lists['redis_list']:
                    setattr(self, key, RedisList.as_child(self, key, str))
                elif key in self.key_lists['redis_zset']:
                    setattr(self, key, RedisZSet.as_child(self, key, str))
            self.bnum = next_bnum
            self.failed = False
            self.completed = False
        else:
            self.namespace = 'antbs:build:%s:' % bnum
            self.prefix = self.namespace[:-1]
Ejemplo n.º 4
0
    def __init__(self, pkg_obj=None, bnum=None):
        if not pkg_obj and not bnum:
            raise AttributeError

        super(BuildObject, self).__init__()

        self.all_keys = dict(
            redis_string=['pkgname', 'pkgver', 'epoch', 'pkgrel', 'path', 'build_path', 'start_str', 'end_str',
                          'version_str', 'container', 'review_status', 'review_dev', 'review_date', 'log_str'],
            redis_string_bool=['failed', 'completed'],
            redis_string_int=['pkgid', 'bnum'],
            redis_list=['log'],
            redis_zset=[])

        if not bnum:
            key_lists = ['redis_string', 'redis_string_bool', 'redis_string_int', 'redis_list', 'redis_zset']
            for key_list_name in key_lists:
                key_list = self.all_keys[key_list_name]
                for key in key_list:
                    if key_list_name.endswith('string'):
                        value = getattr(pkg_obj, key, '')
                        setattr(self, key, value)
                    elif key_list_name.endswith('bool'):
                        value = getattr(pkg_obj, key, False)
                        setattr(self, key, value)
                    elif key_list_name.endswith('int'):
                        value = getattr(pkg_obj, key, 0)
                        setattr(self, key, value)
                    elif key_list_name.endswith('list'):
                        setattr(self, key, RedisList.as_child(self, key, str))
                    elif key_list_name.endswith('zset'):
                        setattr(self, key, RedisZSet.as_child(self, key, str))
            next_bnum = db.incr('antbs:misc:bnum:next')
            self.namespace = 'antbs:build:%s:' % next_bnum
            self.bnum = next_bnum
        else:
            self.namespace = 'antbs:build:%s:' % bnum