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


Python halo.Halo方法代码示例

本文整理汇总了Python中halo.Halo方法的典型用法代码示例。如果您正苦于以下问题:Python halo.Halo方法的具体用法?Python halo.Halo怎么用?Python halo.Halo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在halo的用法示例。


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

示例1: get_reporter

# 需要导入模块: import halo [as 别名]
# 或者: from halo import Halo [as 别名]
def get_reporter(
        self,
        requirements: List[Requirement],
        tracked_names: Optional[Iterable[str]] = None,
        spinner: Optional[halo.Halo] = None,
    ) -> BaseReporter:
        """Return the reporter object to construct a resolver.

        :param requirements: requirements to resolve
        :param tracked_names: the names of packages that needs to update
        :param spinner: optional spinner object
        :returns: a reporter
        """
        from pdm.resolver.reporters import SpinnerReporter

        return SpinnerReporter(spinner, requirements) 
开发者ID:frostming,项目名称:pdm,代码行数:18,代码来源:core.py

示例2: __refresh_token

# 需要导入模块: import halo [as 别名]
# 或者: from halo import Halo [as 别名]
def __refresh_token(url, username, password, config_dir, headless=True, spinner=True):
    spinner = Halo(enabled=spinner)
    try:
        spinner.start(SPINNER_MSGS['token_refresh'])
        driver = SSODriver(url, username, headless=headless, cookie_dir=config_dir)
        try:
            return driver.refresh_token(username, password)
        except MFACodeNeeded as e:
            spinner.stop()
            mfacode = inquirer.text(message='MFA Code')
            spinner.start(SPINNER_MSGS['mfa_send'])
            driver.send_mfa(e.mfa_form, mfacode)
            spinner.start(SPINNER_MSGS['token_refresh'])
            return driver.get_token()
        except AlertMessage as e:
            sys.exit(e)
        finally:
            spinner.stop()
    except KeyboardInterrupt as e:
        spinner.stop()
        raise e
    finally:
        driver.close() 
开发者ID:wnkz,项目名称:aws-sso,代码行数:25,代码来源:cli.py

示例3: _destroy_cluster

# 需要导入模块: import halo [as 别名]
# 或者: from halo import Halo [as 别名]
def _destroy_cluster(
    cluster_id: str,
    transport: Transport,
    enable_spinner: bool,
) -> None:
    """
    Destroy a cluster.

    Args:
        cluster_id: The ID of the cluster.
        transport: The transport to use for any communication with the cluster.
        enable_spinner: Whether to enable the spinner animation.
    """
    with Halo(enabled=enable_spinner):
        check_cluster_id_exists(
            new_cluster_id=cluster_id,
            existing_cluster_ids=existing_cluster_ids(),
        )
        cluster_containers = ClusterContainers(
            cluster_id=cluster_id,
            transport=transport,
        )
        cluster_containers.destroy() 
开发者ID:dcos,项目名称:dcos-e2e,代码行数:25,代码来源:destroy.py

示例4: get_url

# 需要导入模块: import halo [as 别名]
# 或者: from halo import Halo [as 别名]
def get_url(name):
    """Get URL of the specific event

    :name: Name of the CTF entered by user

    :return: A url of to the tasks of the CTF
            eg: https://ctftime.org/event/683/tasks/
    """

    spinner = Halo(text="Finding the URL", spinner="moon", color="red")
    spinner.start()
    past_ctfs = await past_events()
    ctfs = get_event(past_ctfs, name)

    if not ctfs:
        spinner.fail(colors("No CTF found", "32"))
        return

    if len(ctfs) != 1:
        spinner.stop()
        tables = [i["name"] for i in ctfs]
        question = [
            inquirer.List("choice", message="Choose one from below?", choices=tables)
        ]
        answer = inquirer.prompt(question)

        # Compare answer with name of CTF to get a link
        choice = list(filter(lambda ctf: ctf["name"] == answer["choice"], ctfs))
        url = ROOT_URL + choice[0]["link"] + "/tasks/"
        return url

    spinner.succeed("Got it")
    return ROOT_URL + ctfs[0]["link"] + "/tasks/" 
开发者ID:mzfr,项目名称:lswriteups,代码行数:35,代码来源:check_ctf.py

示例5: open_spinner

# 需要导入模块: import halo [as 别名]
# 或者: from halo import Halo [as 别名]
def open_spinner(self, title: str, spinner: str = "dots"):
        with halo.Halo(title, spinner=spinner) as spin:
            yield spin 
开发者ID:frostming,项目名称:pdm,代码行数:5,代码来源:iostream.py

示例6: __init__

# 需要导入模块: import halo [as 别名]
# 或者: from halo import Halo [as 别名]
def __init__(self, spinner: halo.Halo, requirements: List[Requirement]) -> None:
        self.spinner = spinner
        self.requirements = requirements
        self._previous = None  # type: Optional[Dict[str, Candidate]] 
开发者ID:frostming,项目名称:pdm,代码行数:6,代码来源:reporters.py

示例7: train

# 需要导入模块: import halo [as 别名]
# 或者: from halo import Halo [as 别名]
def train(self):
        """
        Method to train a kNN classifier.
        """

        # step 1: get the dataset
        x, y = self.read_dataset()

        # split into training and testing
        features_train, features_test, labels_train, labels_test = train_test_split(x, y, test_size=0.2, random_state=0)

        spinner = Halo(text='Training', spinner='dots')
        spinner.start()

        # step 2: train the model
        pipeline_knn_clf = Pipeline([('scaler', MinMaxScaler()), ('classifier', KNeighborsClassifier())])
        pipeline_knn_clf.fit(features_train, labels_train)

        spinner.succeed(text='Finished training')

        if self.skip_evaluation:
            print('Skipping running evaluation')

        else:
            spinner = Halo(text='Evaluating', spinner='dots')
            spinner.start()

            # step 3: evaluate the model
            labels_pred = pipeline_knn_clf.predict(features_test)
            score = accuracy_score(labels_test, labels_pred)

            spinner.succeed(text='Finished evaluation')

            print(f'Accuracy (max=1.0): {score}')

        # persist model
        dump(pipeline_knn_clf, self.joblib_path)

        print(f'Model saved at {self.joblib_path}') 
开发者ID:samkit-jain,项目名称:Handwriting-Recognition,代码行数:41,代码来源:model.py

示例8: audio_consumer

# 需要导入模块: import halo [as 别名]
# 或者: from halo import Halo [as 别名]
def audio_consumer(vad_audio, websocket):
    """blocks"""
    spinner = None
    if not ARGS.nospinner: spinner = Halo(spinner='line') # circleHalves point arc boxBounce2 bounce line
    length_ms = 0
    wav_data = bytearray()

    for block in vad_audio.vad_collector():
        if ready and websocket.is_active:
            if block is not None:
                if not length_ms:
                    logging.debug("begin utterence")
                if spinner: spinner.start()
                logging.log(5, "sending block")
                websocket.send_binary(block)
                if ARGS.savewav: wav_data.extend(block)
                length_ms += vad_audio.block_duration_ms

            else:
                if spinner: spinner.stop()
                if not length_ms: raise RuntimeError("ended utterence without beginning")
                logging.debug("end utterence")
                if ARGS.savewav:
                    vad_audio.write_wav(os.path.join(ARGS.savewav, datetime.now().strftime("savewav_%Y-%m-%d_%H-%M-%S_%f.wav")), wav_data)
                    wav_data = bytearray()
                logging.info("sent audio length_ms: %d" % length_ms)
                logging.log(5, "sending EOS")
                websocket.send_text('EOS')
                length_ms = 0 
开发者ID:daanzu,项目名称:deepspeech-websocket-server,代码行数:31,代码来源:client.py

示例9: __init__

# 需要导入模块: import halo [as 别名]
# 或者: from halo import Halo [as 别名]
def __init__(self, message):
        self.halo = Halo(text=message, spinner='dot', color='green') 
开发者ID:rougeth,项目名称:bottery,代码行数:4,代码来源:log.py

示例10: destroy_loopback_sidecar

# 需要导入模块: import halo [as 别名]
# 或者: from halo import Halo [as 别名]
def destroy_loopback_sidecar(enable_spinner: bool, name: str) -> None:
    """
    Destroy a loopback sidecar.
    """
    loopback_sidecars = loopback_sidecars_by_name(name=name)

    if not loopback_sidecars:
        message = 'Loopback sidecar "{name}" does not exist'.format(
            name=name,
        )
        raise click.BadParameter(message)

    [loopback_sidecar] = loopback_sidecars
    with Halo(enabled=enable_spinner):
        DockerLoopbackVolume.destroy(container=loopback_sidecar) 
开发者ID:dcos,项目名称:dcos-e2e,代码行数:17,代码来源:destroy_loopback_sidecar.py

示例11: _destroy_mac_network_containers

# 需要导入模块: import halo [as 别名]
# 或者: from halo import Halo [as 别名]
def _destroy_mac_network_containers(enable_spinner: bool) -> None:
    """
    Destroy containers created by ``minidcos docker setup-mac-network``.
    """
    with Halo(enabled=enable_spinner):
        client = docker_client()
        for name in (_PROXY_CONTAINER_NAME, _OPENVPN_CONTAINER_NAME):
            try:
                container = client.containers.get(container_id=name)
            except docker.errors.NotFound:
                pass
            else:
                container.remove(v=True, force=True) 
开发者ID:dcos,项目名称:dcos-e2e,代码行数:15,代码来源:mac_network.py

示例12: destroy_cluster

# 需要导入模块: import halo [as 别名]
# 或者: from halo import Halo [as 别名]
def destroy_cluster(cluster_id: str, enable_spinner: bool) -> None:
    """
    Destroy a cluster.

    Args:
        cluster_id: The ID of the cluster.
        enable_spinner: Whether to enable the spinner animation.
    """
    with Halo(enabled=enable_spinner):
        check_cluster_id_exists(
            new_cluster_id=cluster_id,
            existing_cluster_ids=existing_cluster_ids(),
        )
        cluster_vms = ClusterVMs(cluster_id=cluster_id)
        cluster_vms.destroy() 
开发者ID:dcos,项目名称:dcos-e2e,代码行数:17,代码来源:destroy.py

示例13: __init__

# 需要导入模块: import halo [as 别名]
# 或者: from halo import Halo [as 别名]
def __init__(self, text):
        """ 초기화
        Parameters
        ----------
        text: str
            spinner 사용시 표시할 text
        """
        self.spinner = Halo(text=text, spinner='dots') 
开发者ID:josw123,项目名称:dart-fss,代码行数:10,代码来源:spinner.py

示例14: main

# 需要导入模块: import halo [as 别名]
# 或者: from halo import Halo [as 别名]
def main():
    print_banner()
    args = get_args()
    if( args.s == 0 ):
        spinner = Halo(spinner='dots')
    try:
        if (args.s == 0):
           spinner.start(text='Parsing configuration file')
        config = ConfParse()
        if (args.s == 0):
            spinner.succeed()
    except Exception as e:
        if(args.s == 0):
            spinner.fail()
        print("\n\nError parsing configuration file: {}\n".format(e))
        exit(1)
    try:
        if(args.s == 0):
            spinner.start(text="Retrieving hpHosts feed: {}".format(args.c))
        hphosts_feed = HpHostsFeed(args.c)
        if(args.s == 0):
            spinner.succeed()
    except Exception as e:
        if(args.s == 0):
            spinner.fail()
        print("\n\nError retrieving hpHosts feed: {}\n".format(e))
        exit(1)
    # Create object and load in the retrieved values from above
    report_filename = "hpHosts-{}-{}".format(args.c, args.o)
    report = Report(hphosts_feed, report_filename, config)
    # Process results
    print("\nProcessing {} entries, this may take a while:\n".format(args.n))
    report.write_results(args.n)
    print("\nGreat success.\n")
    # Plot stats histogram
    if(args.s==0):
        report.print_stats_diagram(args.n)
    print("\nDetailed report is available in {}\n".format(report_filename)) 
开发者ID:cryptoaustralia,项目名称:dingoes,代码行数:40,代码来源:dingoes.py

示例15: original_writeups

# 需要导入模块: import halo [as 别名]
# 或者: from halo import Halo [as 别名]
def original_writeups(link):
    """Get all the information about events along with
       link to original writeups

    :link: A URL to the tasks of a CTF

    :return: Information about the all the task along with URL
             to original writeups in tabulated form
    """
    spinner = Halo(text=colors("Grabing writeups", "32"), spinner="moon", color="green")
    spinner.start()

    info = []
    headers = ["S.no", "Name", "Points", "tags", "URL"]
    soup = await make_soup(link)
    trs = soup.findAll("tr")

    # For getting tasks links
    for ind, tr in enumerate(trs[1:]):
        rated = {}
        gen = tr.text.split("\n")

        # Check if writeup exists or not
        if gen[-1] == str(0):
            tags = ",".join(gen[3:-2])
            info.append([ind, gen[0], gen[1], tags, "No writeups"])
            continue

        url = ROOT_URL + tr.find("a").get("href")
        soup = await make_soup(url)
        trs1 = soup.findAll("tr")

        # For getting "all" the writeups of one task
        for tr1 in trs1[1:]:
            para = soup.findAll("p")
            name = soup.find("h2").text
            point = para[0].text.split(":")[-1].strip()
            tags = para[1].text.split(":")[-1].split("\xa0")
            tags = ", ".join(i for i in tags[:-1])
            rated[tr1.find("a").get("href")] = tr1.find("div").text

        # Get writeup link which has the max rating.
        Link = await original_writeup_link(max(rated, key=rated.get))

        info.append([ind, name, point, tags, Link])

    table = tabulate(info, headers, tablefmt="fancy_grid")

    spinner.succeed("Voila!!")
    return table 
开发者ID:mzfr,项目名称:lswriteups,代码行数:52,代码来源:find_writeups.py


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