示例#1
0
    def randomize_list(self, target, output):
        """
        Randomize scan list
        :param str target: target list
        :param str output: output list
        :raise ReaderError
        :return: None
        """

        try:

            target_file = self.__config.get(target)
            tmp_file = self.__config.get(output)
            output_file = filesystem.makefile(tmp_file)

            if False is sys().is_windows:
                process.execute('shuf {target} -o {output}'.format(target=target_file, output=output_file))
            else:
                filesystem.shuffle(target=target_file, output=output_file, total=self.total_lines)
        except (CoreSystemError, FileSystemError) as error:
            raise ReaderError(error)
示例#2
0
    def update():
        """
        Check for update
        :raise PackageError
        :return: str
        """

        try:
            if False is sys().is_windows:
                status = process.execute(CoreConfig.get('command').get('cvsupdate'))
                upd_status = tpl.line(status, color='green')
                msg = CoreConfig.get('update').format(status=upd_status)
            else:
                msg = CoreConfig.get('update').format(status=tpl.line(key='upd_win_stat'))
            return msg
        except (AttributeError, CoreSystemError) as error:
            raise PackageError(error)
示例#3
0
    def update():
        """
        Check for update
        :raise PackageError
        :return: str
        """

        try:
            if False is sys().is_windows:
                status = process.execute(Config.params.get('cvsupdate'))
                upd_status = tpl.line(status, color='green')
                msg = Config.params.get('update').format(status=upd_status)
            else:
                msg = Config.params.get('update').format(status=tpl.line(key='upd_win_stat'))
            return msg
        except (AttributeError, CoreSystemError) as error:
            raise PackageError(error)
示例#4
0
    def __remote_version():
        """
        Get application remote version
        :raise PackageError
        :return: str
        """

        if None is Package.remote_version:

            try:
                request_uri = CoreConfig.get('info').get('remote_version')
                result = process.execute('curl -sb GET {uri}'.format(uri=request_uri))
                Package.remote_version = str(result, "utf-8")
                return Package.remote_version

            except (FileSystemError, CoreSystemError) as error:
                raise PackageError(error)
        else:
            return Package.remote_version
示例#5
0
    def __remote_version():
        """
        Get application remote version
        :raise PackageError
        :return: str
        """

        if None is Package.remote_version:

            try:
                request_uri = CoreConfig.get('info').get('remote_version')
                result = process.execute(
                    'curl -sb GET {uri}'.format(uri=request_uri))
                Package.remote_version = str(result, "utf-8")
                return Package.remote_version

            except (FileSystemError, CoreSystemError) as error:
                raise PackageError(error)
        else:
            return Package.remote_version
示例#6
0
文件: package.py 项目: ll2b/OpenDoor
    def __remote_version():
        """
        Get application remote version
        :raise PackageError
        :return: str
        """

        if None is Package.remote_version:

            try:
                config = filesystem.readcfg(Config.params.get('cfg'))
                request_uri = config.get('info', 'setup')
                result = process.execute(
                    'curl -sb GET {uri}'.format(uri=request_uri))
                raw = filesystem.readraw(result)
                Package.remote_version = raw.get('info', 'version')

                return Package.remote_version

            except (FileSystemError, CoreSystemError) as e:
                raise PackageError(e)
        else:
            return Package.remote_version