当前位置: 首页>>代码示例>>Python>>正文


Python utils.AsyncTask类代码示例

本文整理汇总了Python中katello.client.core.utils.AsyncTask的典型用法代码示例。如果您正苦于以下问题:Python AsyncTask类的具体用法?Python AsyncTask怎么用?Python AsyncTask使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AsyncTask类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

    def run(self):
        provName = self.get_option('name')
        orgName  = self.get_option('org')

        prov = get_provider(orgName, provName)

        task = AsyncTask(self.api.last_sync_status(prov['id']))

        if task.is_running():
            pkgsTotal = task.total_count()
            pkgsLeft = task.items_left()
            prov['progress'] = (_("%d%% done (%d of %d packages downloaded)") % \
                (task.get_progress()*100, pkgsTotal-pkgsLeft, pkgsTotal))

        #TODO: last errors?

        self.printer.add_column('id')
        self.printer.add_column('name')

        self.printer.add_column('last_sync', formatter=format_sync_time)
        self.printer.add_column('sync_state', formatter=format_sync_state)
        self.printer.add_column('progress', show_with=printer.VerboseStrategy)

        self.printer.set_header(_("Provider Status"))
        self.printer.print_item(prov)
        return os.EX_OK
开发者ID:Pajk,项目名称:katello,代码行数:26,代码来源:provider.py

示例2: run

    def run(self):
        provName = self.get_option("name")
        orgName = self.get_option("org")

        prov = get_provider(orgName, provName)

        task = AsyncTask(self.api.last_sync_status(prov["id"]))

        if task.is_running():
            pkgsTotal = task.total_count()
            pkgsLeft = task.items_left()
            prov["progress"] = _("%d%% done (%d of %d packages downloaded)") % (
                task.get_progress() * 100,
                pkgsTotal - pkgsLeft,
                pkgsTotal,
            )

        # TODO: last errors?

        self.printer.add_column("id")
        self.printer.add_column("name")

        self.printer.add_column("last_sync", formatter=format_sync_time)
        self.printer.add_column("sync_state", formatter=format_sync_state)
        self.printer.add_column("progress", show_with=printer.VerboseStrategy)

        self.printer.set_header(_("Provider Status"))
        self.printer.print_item(prov)
        return os.EX_OK
开发者ID:gstoeckel,项目名称:katello,代码行数:29,代码来源:provider.py

示例3: run

    def run(self):
        provName = self.get_option('name')
        orgName  = self.get_option('org')

        prov = get_provider(orgName, provName)
        if prov == None:
            return os.EX_DATAERR

        task = AsyncTask(self.api.last_sync_status(prov['id']))

        prov['last_sync'] = format_sync_time(prov['last_sync'])
        prov['sync_state'] = format_sync_state(prov['sync_state'])

        if task.is_running():
            pkgsTotal = task.total_count()
            pkgsLeft = task.items_left()
            prov['progress'] = ("%d%% done (%d of %d packages downloaded)" % (task.get_progress()*100, pkgsTotal-pkgsLeft, pkgsTotal))

        #TODO: last errors?

        self.printer.addColumn('id')
        self.printer.addColumn('name')

        self.printer.addColumn('last_sync')
        self.printer.addColumn('sync_state')
        self.printer.addColumn('progress', show_in_grep=False)

        self.printer.setHeader(_("Provider Status"))
        self.printer.printItem(prov)
        return os.EX_OK
开发者ID:jsomara,项目名称:katello,代码行数:30,代码来源:provider.py

示例4: run

    def run(self):
        orgName     = self.get_option('org')
        prodName    = self.get_option('name')

        prod = get_product(orgName, prodName)
        if (prod == None):
            return os.EX_DATAERR

        task = AsyncTask(self.api.last_sync_status(orgName, prod['id']))

        prod['last_sync'] = format_sync_time(prod['last_sync'])
        prod['sync_state'] = format_sync_state(prod['sync_state'])

        if task.is_running():
            pkgsTotal = task.total_count()
            pkgsLeft = task.items_left()
            prod['progress'] = ("%d%% done (%d of %d packages downloaded)" % (task.get_progress()*100, pkgsTotal-pkgsLeft, pkgsTotal))

        #TODO: last errors?

        self.printer.add_column('id')
        self.printer.add_column('name')
        self.printer.add_column('provider_id')
        self.printer.add_column('provider_name')
        self.printer.add_column('last_sync')
        self.printer.add_column('sync_state')
        self.printer.add_column('progress', show_with=printer.VerboseStrategy)

        self.printer.set_header(_("Product Status"))
        self.printer.print_item(prod)
        return os.EX_OK
开发者ID:ohadlevy,项目名称:katello,代码行数:31,代码来源:product.py

示例5: run

    def run(self):
        orgName     = self.get_option('org')
        prodName    = self.get_option('name')
        envName     = self.get_option('env')

        env = get_environment(orgName, envName)
        prod = get_product(orgName, prodName)

        returnCode = os.EX_OK

        cset = self.csapi.create(orgName, env["id"], self.create_cs_name())
        try:
            self.csapi.add_content(cset["id"], "products", {'product_id': prod['id']})
            task = self.csapi.promote(cset["id"])
            task = AsyncTask(task)

            run_spinner_in_bg(wait_for_async_task, [task], message=_("Promoting the product, please wait... "))

            if task.succeeded():
                print _("Product [ %s ] promoted to environment [ %s ] " % (prodName, envName))
                returnCode = os.EX_OK
            else:
                print _("Product [ %s ] promotion failed: %s" % (prodName, format_task_errors(task.errors())) )
                returnCode = os.EX_DATAERR

        except Exception as e:
            #exception message is printed from action's main method
            raise e

        return returnCode
开发者ID:skottler,项目名称:katello,代码行数:30,代码来源:product.py

示例6: run

    def run(self):
        orgName     = self.get_option('org')
        prodName    = self.get_option('name')
        prodLabel   = self.get_option('label')
        prodId      = self.get_option('id')
        envName     = self.get_option('environment')

        env = get_environment(orgName, envName)
        prod = get_product(orgName, prodName, prodLabel, prodId)

        returnCode = os.EX_OK

        cset = self.csapi.create(orgName, env["id"], self.create_cs_name(), constants.PROMOTION)
        try:
            self.csapi.add_content(cset["id"], "products", {'product_id': prod['id']})
            task = self.csapi.apply(cset["id"])
            task = AsyncTask(task)

            run_spinner_in_bg(wait_for_async_task, [task], message=_("Promoting the product, please wait... "))

            if task.succeeded():
                print _("Product [ %(prod_name)s ] promoted to environment [ %(envName)s ] " \
                    % {'prod_name':prod["name"], 'envName':envName})
                returnCode = os.EX_OK
            else:
                print _("Product [ %(prod_name)s ] promotion failed: %(task_errors)s" \
                    % {'prod_name':prod["name"], 'task_errors':format_task_errors(task.errors())} )
                returnCode = os.EX_DATAERR

        except Exception:
            #exception message is printed from action's main method
            raise

        return returnCode
开发者ID:chiehwen,项目名称:katello,代码行数:34,代码来源:product.py

示例7: run

    def run(self):
        repo = self.get_repo()

        task = AsyncTask(self.api.last_sync_status(repo['id']))

        repo['last_sync'] = format_sync_time(repo['last_sync'])
        repo['sync_state'] = format_sync_state(repo['sync_state'])
        if 'next_scheduled_sync' in repo:
            repo['next_scheduled_sync'] = format_sync_time(repo['next_scheduled_sync'])

        if task.is_running():
            pkgsTotal = task.total_count()
            pkgsLeft = task.items_left()
            repo['progress'] = ("%d%% done (%d of %d packages downloaded)" % (task.get_progress()*100, pkgsTotal-pkgsLeft, pkgsTotal))

        repo['last_errors'] = format_sync_errors(task)

        self.printer.addColumn('package_count')
        self.printer.addColumn('last_sync')
        self.printer.addColumn('sync_state')
        if 'next_scheduled_sync' in repo:
            self.printer.addColumn('next_scheduled_sync')
        self.printer.addColumn('progress', show_in_grep=False)
        self.printer.addColumn('last_errors', multiline=True, show_in_grep=False)

        self.printer.setHeader(_("Repository Status"))
        self.printer.printItem(repo)
        return os.EX_OK
开发者ID:jsomara,项目名称:katello,代码行数:28,代码来源:repo.py

示例8: run

    def run(self):
        name = self.get_option('name')

        task = self.api.delete(name)
        task = AsyncTask(task)

        run_spinner_in_bg(wait_for_async_task, [task], message=_("Deleting the organization, please wait... "))

        if task.succeeded():
            print _("Successfully deleted org [ %s ]") % name
            return os.EX_OK
        else:
            print _("Organization [ %s ] deletion failed: %s" % (name, format_task_errors(task.errors())) )
            return os.EX_DATAERR
开发者ID:AdamSaleh,项目名称:katello,代码行数:14,代码来源:organization.py

示例9: run

    def run(self):
        repo = self.get_repo()

        task = AsyncTask(self.api.sync(repo['id']))
        run_async_task_with_status(task, ProgressBar())

        if task.succeeded():
            print _("Repo [ %s ] synced" % repo['name'])
            return os.EX_OK
        elif task.cancelled():
            print _("Repo [ %s ] synchronization cancelled" % repo['name'])
            return os.EX_OK
        else:
            print _("Repo [ %s ] failed to sync: %s" % (repo['name'], format_sync_errors(task)) )
            return os.EX_DATAERR
开发者ID:pmutha,项目名称:katello,代码行数:15,代码来源:repo.py

示例10: sync_provider

    def sync_provider(self, providerName, orgName):
        prov = get_provider(orgName, providerName)

        task = AsyncTask(self.api.sync(prov["id"]))
        run_async_task_with_status(task, ProgressBar())

        if task.failed():
            errors = format_sync_errors(task)
            print _("Provider [ %s ] failed to sync: %s" % (providerName, errors))
            return os.EX_DATAERR
        elif task.cancelled():
            print _("Provider [ %s ] synchronization canceled" % providerName)
            return os.EX_DATAERR

        print _("Provider [ %s ] synchronized" % providerName)
        return os.EX_OK
开发者ID:Pajk,项目名称:katello,代码行数:16,代码来源:provider.py

示例11: run

    def run(self):
        csName = self.get_option('name')
        orgName = self.get_option('org')
        envName = self.get_option('env')

        cset = get_changeset(orgName, envName, csName)

        task = self.api.promote(cset["id"])
        task = AsyncTask(task)

        run_spinner_in_bg(wait_for_async_task, [task], message=_("Promoting the changeset, please wait... "))

        if task.succeeded():
            print _("Changeset [ %s ] promoted" % csName)
            return os.EX_OK
        else:
            print _("Changeset [ %s ] promotion failed: %s" % (csName, format_task_errors(task.errors())))
            return os.EX_DATAERR
开发者ID:bbuckingham,项目名称:katello,代码行数:18,代码来源:changeset.py

示例12: run

    def run(self):
        csName = self.get_option('name')
        orgName = self.get_option('org')
        envName = self.get_option('environment')

        cset = get_changeset(orgName, envName, csName)

        task = self.api.apply(cset["id"])
        task = AsyncTask(task)

        run_spinner_in_bg(wait_for_async_task, [task], message=_("Applying the changeset, please wait... "))

        if task.succeeded():
            print _("Changeset [ %s ] applied" % csName)
            return os.EX_OK
        else:
            print _("Changeset [ %(csName)s ] promotion failed: %(task_errors)s" \
                % {'csName':csName, 'task_errors':format_task_errors(task.errors())})
            return os.EX_DATAERR
开发者ID:chiehwen,项目名称:katello,代码行数:19,代码来源:changeset.py

示例13: run

    def run(self):
        repo = self.get_repo()

        task = AsyncTask(self.api.last_sync_status(repo['id']))

        if task.is_running():
            pkgsTotal = task.total_count()
            pkgsLeft = task.items_left()
            repo['progress'] = ("%(task_progress)d%% done (%(pkgs_count)d of %(pkgs_total)d packages downloaded)" % 
                {'task_progress':task.get_progress()*100, 'pkgs_count':pkgsTotal-pkgsLeft, 'pkgs_total':pkgsTotal})

        repo['last_errors'] = format_sync_errors(task)

        self.printer.add_column('package_count', _("Package Count"))
        self.printer.add_column('last_sync', _("Last Sync"), formatter=format_sync_time)
        self.printer.add_column('sync_state', _("Sync State"), formatter=format_sync_state)
        if 'next_scheduled_sync' in repo:
            self.printer.add_column('next_scheduled_sync', _("Next Scheduled Sync"), formatter=format_sync_time)
        self.printer.add_column('progress', _("Progress"), show_with=printer.VerboseStrategy)
        self.printer.add_column('last_errors', _("Last Errors"), multiline=True, show_with=printer.VerboseStrategy)

        self.printer.set_header(_("Repository Status"))
        self.printer.print_item(repo)
        return os.EX_OK
开发者ID:chiehwen,项目名称:katello,代码行数:24,代码来源:repo.py


注:本文中的katello.client.core.utils.AsyncTask类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。