How to use the rich.print function in rich

To help you get started, we’ve selected a few rich examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ArturSpirin / test_junkie / test_junkie / cli / audit / tags / commands.py View on Github external
no_test_retries, no_suite_meta, no_test_meta):
    """Pivot test information from tag's perspective"""
    if verbose:
        from test_junkie.debugger import LogJunkie
        LogJunkie.enable_logging(10)

    from test_junkie.cli.run.cli_runner import CliRunner
    from test_junkie.cli.audit.cli_audit import CliAudit
    try:
        tj = CliRunner(sources=sources, ignore=[".git"], suites=suites, no_guess_root=no_guess_root)
        tj.scan()
        aggregator = CliAudit(suites=tj.suites, args=locals())
        aggregator.aggregate()
        aggregator.print_results(command="tags")
    except BadCliParameters as error:
        print("[[[bold red]ERROR[/bold red]]] [bold red]{error}[/bold red]".format(error=error))
github djotaku / ELDonationTracker / eldonationtracker / gui.py View on Github external
choices = ("Replace with Defaults", "Update on Save")
            choice, ok = QInputDialog.getItem(self, "Input Dialog",
                                              "You are using an old version of the configuration file.\n Choose "
                                              "what you would like to do.\n If you choose Update on Save, please "
                                              "click on teh settings button, review the new options, and hit save.",
                                              choices, 0, False)
            if ok and choice:
                print(f"[bold blue]You have chosen {choice}[/bold blue]")
                if choice == "Replace with Defaults":
                    self.participant_conf.get_github_config()
                    print("[bold blue]Settings have been replaced with the repo defaults.[/bold blue]")
                    self.participant_conf.reload_json()
                if choice == "Update on Save":
                    print("[bold blue]When you save the settings, you will be up to date[/bold blue]")
        else:
            print("[bold green]Version is correct[/bold green] ")
github lotus-dgas / AnsibleUI / tools / AnsibleApi_v29.py View on Github external
def v2_runner_on_ok(self, result, **kwargs):    #执行成功,
        "处理成功任务,跳过 setup 模块的结果"
        host = result._host
        if "ansible_facts" in result._result.keys():    # 我们忽略 setup 操作的结果
            print("[blue underline]SetUp 操作,不Save结果")
        else:
            self._write_to_save({
                "host": host.name,
                "result": result._result,
                "task": result.task_name,
                "status": "success"
            })
github djotaku / ELDonationTracker / eldonationtracker / participant.py View on Github external
def _get_top_donor(self):
        """Return Top Donor from server.

        Uses donor drive's sorting to get the top guy or gal.
        """
        top_donor_json = extralife_io.get_json(self.participant_donor_url, True)
        if not top_donor_json:
            print("[bold red] Couldn't access top donor data[/bold red]")
            return self.top_donor
        else:
            return donor.Donor(top_donor_json[0])
github djotaku / ELDonationTracker / eldonationtracker / participant.py View on Github external
self.update_participant_attributes()
        self.output_participant_data()
        if self.first_run or self.number_of_donations > number_of_donations:
            if not self.first_run:
                print("[bold green]A new donation![/bold green]")
                self.new_donation = True
            self.update_donation_data()
            self.output_donation_data()
            self.update_donor_data()
            self.output_donor_data()
        # TEAM BLOCK ############################################
        if self.team_id:
            self.my_team.team_run()
        ##########################################################
        self.first_run = False
        print(time.strftime("%H:%M:%S"))
github lotus-dgas / AnsibleUI / tools / AnsibleApi_v29.py View on Github external
def __set_required_variables(self):
        print('BaseHost.__set_required_variables')
        host_data = self.host_data
        self.set_variable('ansible_host', host_data['ip'])
        self.set_variable('ansible_port', host_data.get('port', 22))

        if host_data.get('username'):
            self.set_variable('ansible_user', host_data['username'])

        if host_data.get('private_key'):
            self.set_variable('ansible_ssh_private_key_file', host_data['private_key'])
        if host_data.get('password'):
            self.set_variable('ansible_ssh_pass', host_data['password'])

        become = host_data.get("become", False)
        if become:
            self.set_variable("ansible_become", True)
            self.set_variable("ansible_become_method", become.get('method', 'sudo'))
github lotus-dgas / AnsibleUI / myCelery.py View on Github external
def after_return(self, status, respose, celery_id, args, *k, **kw):
        r = redis.Redis(host=REDIS_ADDR, password=REDIS_PD, port=REDIS_PORT, db=ansible_result_redis_db)
        a = redis.Redis(host=REDIS_ADDR, password=REDIS_PD, port=REDIS_PORT, db=result_db)
        tid = args[0]
        print('MyTask: 处理 Ansible 任务结果, AnsibleID: %s, %s, %s, %s, %s, %s, %s'% (tid,  status, respose, celery_id, args, k, kw))
        rlist = r.lrange(tid, 0, -1)
        try:
            at = AnsibleTasks.objects.filter(AnsibleID=tid)[0]
            at.AnsibleResult = json.dumps([ json.loads(i.decode()) for i in rlist ])
            ct = a.get('celery-task-meta-%s' % at.CeleryID).decode()
            at.CeleryResult = ct
            at.save()
            print("同步结果至db: syncAnsibleResult !!!!!: parent_id: %s" % self.request.get('parent_id'), a, kw)
        except:
            pass
        print("%s - %s - %s - %s - %s - %s" % (status, respose, celery_id, args, k, kw))
github lotus-dgas / AnsibleUI / tools / AnsibleApi_v29.py View on Github external
def _write_to_save(self, data):
        msg = json.dumps(data, ensure_ascii=False)
        self.log.info(msg)
        self.r.rpush(self.id, msg)
        print('[bold magenta]RedisCallBack [/bold magenta]', self.id, '*'*20, self.r ,data)
        self.results.append(data)