def cli(): stdout_io = StringIO() spinner = click_spinner.Spinner(force=True, stream=stdout_io) spinner.start() time.sleep(1) # allow time for a few spins spinner.stop() stdout_io.flush() stdout_str = stdout_io.getvalue() assert len(stdout_str) > 0
def cli(): spinner = click_spinner.Spinner() spinner.start() for thing in range(10): pass spinner.stop() spinner.start() for thing in range(10): pass spinner.stop()
def cli(): stdout_io = StringIO() saved_stdout = sys.stdout sys.stdout = stdout_io # redirect stdout to a string buffer spinner = click_spinner.Spinner(disable=True) spinner.start() time.sleep(1) # allow time for doing nothing spinner.stop() sys.stdout = saved_stdout stdout_io.flush() stdout_str = stdout_io.getvalue() assert len(stdout_str) == 0
def __init__(self, host, userid, password, output_format, transpose, error_format, timestats, session_id, get_password): self._host = host self._userid = userid self._password = password self._output_format = output_format self._transpose = transpose self._error_format = error_format self._timestats = timestats self._session_id = session_id self._get_password = get_password self._session = None self._spinner = click_spinner.Spinner()
def discover(ctx, lookup_known=True, spinner=click_spinner.Spinner()): if (lookup_known and len(KNOWN_DEVICES)): if (ctx.obj['debug']): click.echo('using knwon devices to find timebox') spinner.start() discovered = [(a, 'timebox') for a in KNOWN_DEVICES] else: if (ctx.obj['debug']): click.echo('scanning for timebox') spinner.start() discovered = bluetooth.discover_devices(duration=5, lookup_names=True) if (not len(discovered)): spinner.stop() click.echo("no devices discovered") ctx.abort() else: for a, n in discovered: click.echo('discovered device %s: %s' % (a, n)) if (n and 'timebox' in n.lower()): click.echo('checking device %s' % a) try: sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM) sock.connect((a, 4)) hello = [ord(c) for c in sock.recv(256)] if (hello == TIMEBOX_HELLO): ctx.obj['address'] = a ctx.obj['sock'] = sock break else: click.echo('invalid hello received') sock.close() except bluetooth.BluetoothError as be: click.echo('BluetoothError: %s' % be) pass spinner.stop() if (not 'address' in ctx.obj): if (len(KNOWN_DEVICES) and lookup_known): discover(ctx, False) else: click.echo('could not find a timebox ...') ctx.abort() else: if (ctx.obj['address'].upper() not in KNOWN_DEVICES and click.confirm( 'would you like to add %s to known devices [y/n]?')): with open(CONFFILE, 'a') as f: f.write(ctx.obj['address'].upper() + "\n")
def __init__(self, pywbem_server, output_format, use_pull, pull_max_cnt, timestats, log, verbose): self._pywbem_server = pywbem_server self._output_format = output_format self._use_pull = use_pull self._pull_max_cnt = pull_max_cnt self._timestats = timestats self._log = log self._verbose = verbose self._spinner_enabled = None # Deferred init in getter self._spinner_obj = click_spinner.Spinner() self._conn = None self._wbem_server = None
import sys import os import yaml import time import click import click_spinner spinner = click_spinner.Spinner() from kubeb import file_util, config, util from .generators import (PodderPipelineGenerator, PodderTaskBeanGenerator, LaravelGenerator) class Kubeb: def log(self, msg, *args): if args: msg %= args click.echo(msg, file=sys.stderr) def initiate(self, name, user, template, image, env, force): if file_util.config_file_exist() and force is False: self.log( 'Kubeb config found. Please update config file or use --force option' ) return if not file_util.template_exist(template): self.log('Kubeb template not found. Please check template name') return