def main():
    custom_formatters = [
        formatters.Label(),
        formatters.Text(': [', style='class:percentage'),
        formatters.Percentage(),
        formatters.Text(']', style='class:percentage'),
        formatters.Text(' '),
        formatters.Bar(sym_a='#', sym_b='#', sym_c='.'),
        formatters.Text('  '),
    ]

    with ProgressBar(style=style, formatters=custom_formatters) as pb:
        for i in pb(range(1600), label='Installing'):
            time.sleep(.01)
Esempio n. 2
0
def do_konami(event):
    custom_formatters = [
        formatters.Label(),
        formatters.Text(" "),
        formatters.Rainbow(formatters.Bar()),
        formatters.Text(" left: "),
        formatters.Rainbow(formatters.TimeLeft()),
    ]

    color_depth = ColorDepth.DEPTH_8_BIT
    with ProgressBar(formatters=custom_formatters, color_depth=color_depth) as pb:
        for i in pb(range(1000), label=""):
            time.sleep(0.001)
    print('Downloaded L33t Hax...')
Esempio n. 3
0
def main():
    custom_formatters = [
        formatters.Label(),
        formatters.Text(": [", style="class:percentage"),
        formatters.Percentage(),
        formatters.Text("]", style="class:percentage"),
        formatters.Text(" "),
        formatters.Bar(sym_a="#", sym_b="#", sym_c="."),
        formatters.Text("  "),
    ]

    with ProgressBar(style=style, formatters=custom_formatters) as pb:
        for i in pb(range(1600), label="Installing"):
            time.sleep(0.01)
Esempio n. 4
0
def main():
    custom_formatters = [
        formatters.Label(),
        formatters.Text(' '),
        formatters.SpinningWheel(),
        formatters.Text(' '),
        formatters.Text(HTML('<tildes>~~~</tildes>')),
        formatters.Bar(sym_a='#', sym_b='#', sym_c='.'),
        formatters.Text(' left: '),
        formatters.TimeLeft(),
    ]
    with ProgressBar(title='Progress bar example with custom formatter.',
                     formatters=custom_formatters, style=style) as pb:

        for i in pb(range(20), label='Downloading...'):
            time.sleep(1)
def main():
    custom_formatters = [
        formatters.Label(suffix=': '),
        formatters.Percentage(),
        formatters.Bar(start='|', end='|', sym_a=' ', sym_b=' ', sym_c=' '),
        formatters.Text(' '),
        formatters.Progress(),
        formatters.Text(' ['),
        formatters.TimeElapsed(),
        formatters.Text('<'),
        formatters.TimeLeft(),
        formatters.Text(', '),
        formatters.IterationsPerSecond(),
        formatters.Text('it/s]'),
    ]

    with ProgressBar(style=style, formatters=custom_formatters) as pb:
        for i in pb(range(1600), label='Installing'):
            time.sleep(.01)
Esempio n. 6
0
def main():
    custom_formatters = [
        formatters.Label(suffix=": "),
        formatters.Percentage(),
        formatters.Bar(start="|", end="|", sym_a=" ", sym_b=" ", sym_c=" "),
        formatters.Text(" "),
        formatters.Progress(),
        formatters.Text(" ["),
        formatters.TimeElapsed(),
        formatters.Text("<"),
        formatters.TimeLeft(),
        formatters.Text(", "),
        formatters.IterationsPerSecond(),
        formatters.Text("it/s]"),
    ]

    with ProgressBar(style=style, formatters=custom_formatters) as pb:
        for i in pb(range(1600), label="Installing"):
            time.sleep(0.01)
Esempio n. 7
0
def main():
    custom_formatters = [
        formatters.Label(),
        formatters.Text(" "),
        formatters.SpinningWheel(),
        formatters.Text(" "),
        formatters.Text(HTML("<tildes>~~~</tildes>")),
        formatters.Bar(sym_a="#", sym_b="#", sym_c="."),
        formatters.Text(" left: "),
        formatters.TimeLeft(),
    ]
    with ProgressBar(
            title="Progress bar example with custom formatter.",
            formatters=custom_formatters,
            style=style,
    ) as pb:

        for i in pb(range(20), label="Downloading..."):
            time.sleep(1)
def main():
    true_color = confirm('Yes true colors? (y/n) ')

    custom_formatters = [
        formatters.Label(),
        formatters.Text(' '),
        formatters.Rainbow(formatters.Bar()),
        formatters.Text(' left: '),
        formatters.Rainbow(formatters.TimeLeft()),
    ]

    if true_color:
        color_depth = ColorDepth.DEPTH_24_BIT
    else:
        color_depth = ColorDepth.DEPTH_8_BIT

    with ProgressBar(formatters=custom_formatters, color_depth=color_depth) as pb:
        for i in pb(range(20), label='Downloading...'):
            time.sleep(1)
Esempio n. 9
0
SWIGGY_URL = 'https://www.swiggy.com'
SWIGGY_LOGIN_URL = SWIGGY_URL + '/dapi/auth/signin-with-check'
SWIGGY_ORDER_URL = SWIGGY_URL + '/dapi/order/all'
SWIGGY_SEND_OTP_URL = SWIGGY_URL + '/dapi/auth/sms-otp'
SWIGGY_VERIFY_OTP_URL = SWIGGY_URL + '/dapi/auth/otp-verify'
SWIGGY_API_CALL_INTERVAL = 1.5  # interval between API calls. (in seconds)

CONFIG_FILEPATH = os.path.join(
    str(Path.home()), '.swiggy-analytics-config.ini')
DB_FILEPATH = os.path.join(str(os.getcwd()), 'swiggy.db')

PROGRESS_BAR_STYLE = Style.from_dict({
    'label': 'bg:#FFA500 #000000',
    'percentage': 'bg:#FFA500 #000000',
    'current': '#448844',
    'bar': '',
})

PROGRESS_BAR_FORMATTER = [
    formatters.Label(),
    formatters.Text(': [', style='class:percentage'),
    formatters.Percentage(),
    formatters.Text(']', style='class:percentage'),
    formatters.Text(' '),
    formatters.Bar(sym_a='#', sym_b='#', sym_c='.'),
    formatters.Text('  '),
]

YES_ANSWER_CHOICES = ['y', 'yes', 'yeah', 'yup']
NO_ANSWER_CHOICES = ['n', 'no', 'nope']
Esempio n. 10
0
import threading
import time

# progress bar
from prompt_toolkit.shortcuts import ProgressBar
from prompt_toolkit.styles import Style
from prompt_toolkit.shortcuts.progress_bar import formatters

tab = '\t'.expandtabs(8)

style = Style.from_dict({
    '': 'orange',
})

custom_formatters = [
    formatters.Text(tab),
    formatters.Label(suffix=': '),
    formatters.Bar(start=' |', end='|', sym_a='#', sym_b='#', sym_c='.'),
    formatters.Text(' '),
    formatters.Progress(),
    formatters.Text(' '),
    formatters.Percentage(),
    formatters.Text(' [elapsed: '),
    formatters.TimeElapsed(),
    formatters.Text(' left: '),
    formatters.TimeLeft(),
    formatters.Text(']'),
    formatters.Text(tab),
]

Esempio n. 11
0
                                          bar_c=bar_c)

    def get_width(self, progress_bar):
        return formatters.D(min=9)


SCREEN_BANNER = HTML("<banner><b>PyTrain {}</b> - {}</banner>")
SCREEN_TOOLBAR = HTML("<b>[Control-L]</b> clear  <b>[Control-X]</b> quit")
SCREEN_STYLE = Style.from_dict({
    "bottom-toolbar": "fg:cyan",
    "banner": "fg:cyan",
    "title": "fg:white"
})
SCREEN_FORMATTERS = [
    formatters.Label(),
    formatters.Text(" "),
    "ShowBar",
    formatters.Text(" ETA ", style="class:time-left"),
    formatters.TimeLeft(),
]


class Application:
    def __init__(self, loop, device, registry):
        self.loop = loop
        self.device = device
        self.registry = registry
        self.losses = {}

        self._components = self.registry.create_components(self.device)
        self._datasets = self.registry.create_datasets()
Esempio n. 12
0
    ConsoleFormatter(fmt=LOGGING_FORMAT, datefmt=LOGGING_DATE_FORMAT))

logger.propagate = False
logger.handlers = [handler]

progress_styles = Style.from_dict({
    'label': '#ffffff',
    'percentage': '#ffffff',
    'current': '#448844',
    'bar': '#00dd00',
    'time': '#ffffff',
    'prefix': '#00dd00'
})

progress_formatters = custom_formatters = [
    formatters.Text('[/] ', style='class:prefix'),
    formatters.Label(),
    formatters.Text(': ', style='class:label'),
    formatters.Percentage(),
    formatters.Text(' '),
    formatters.Bar(sym_a='█', sym_b='█', sym_c='.'),
    formatters.Text('  '),
    formatters.TimeElapsed(),
]


def register_command(cmd):
    if cmd.name in commands:
        raise ValueError('Command \'%s\' already registered' % cmd.name)
    for alias in cmd.aliases:
        if alias in commands:
Esempio n. 13
0
        "3. Send empty response\n\t" \
        "   <ansiblue>manipulator response_type=empty</ansiblue>\n\t" \
        "4. Send stray response of lenght 12 and revert to normal after 2 responses\n\t" \
        "   <ansiblue>manipulator response_type=stray data_len=11 clear_after=2</ansiblue>\n\t" \
        "5. To disable response manipulation\n\t" \
        "   <ansiblue>manipulator response_type=normal</ansiblue>"
COMMAND_HELPS = {
    "manipulator": "Manipulate response from server.\nUsage: {}".format(USAGE),
    "clear": "Clears screen"
}

STYLE = Style.from_dict({"": "cyan"})
CUSTOM_FORMATTERS = [
    formatters.Label(suffix=": "),
    formatters.Bar(start="|", end="|", sym_a="#", sym_b="#", sym_c="-"),
    formatters.Text(" "),
    formatters.Text(" "),
    formatters.TimeElapsed(),
    formatters.Text("  "),
]


def info(message):
    if not isinstance(message, str):
        message = str(message)
    click.secho(message, fg="green")


def warning(message):
    click.secho(str(message), fg="yellow")
Esempio n. 14
0
    def download_footage(self, output_path=Path('downloaded_clips')):
        """
        - Search for footage & get ID values
        - Try to get the sizes for each clip
        - Download each clip on it's own
        - Name the clip and save it to disk in a folder for each camera
        """
        example = "/api/2.0/recording/5bb829e4b3a28701fe50b258/download"
        meta_cookies = {'cameras.isManagedFilterOn': 'false'}
        meta_cookies.update(self.session.cookies)
        # num_clips = len(self.clip_meta_data)
        url_id_params = str()

        # Progress Bar Styles and Format
        style = Style.from_dict({
            'label': 'bg:#000000 #ffffff',
            'percentage': 'bg:#000000 #ffffff',
            'current': '#448844',
            'bar': '',
        })

        custom_formatters = [
            formatters.Label(),
            formatters.Text(': [', style='class:percentage'),
            formatters.Percentage(),
            formatters.Text(']', style='class:percentage'),
            formatters.Text(' '),
            formatters.Bar(start='[', end=']', sym_a='#', sym_b='>',
                           sym_c='*'),
            formatters.Text('  '),
        ]

        # Create output if it doesn't exist yet
        self.outputPathCheck(output_path)

        # pprint(self.dict_info_clip, indent=4)
        num_clips = len(self.dict_info_clip)

        with ProgressBar(style=style, formatters=custom_formatters) as pb:
            for clip in pb(list(self.dict_info_clip),
                           label=f"Downloading {num_clips} Videos",
                           remove_when_done=False):
                req = requests.Request(
                    'GET',
                    f"{self.url}/api/2.0/recording/{self.dict_info_clip[clip].clip_id}/download",
                    cookies=meta_cookies)
                prepped = req.prepare()
                # print(prepped.url)
                self.logger.debug(
                    f'Attempting to download clip {self.dict_info_clip[clip].clip_id}'
                )

                r = self.session.send(prepped, stream=True)

                if r.status_code is 200:
                    self.logger.debug(
                        f'Successfully requested clip {self.dict_info_clip[clip].clip_id}'
                    )
                elif r.status_code is 401:
                    self.logger.critical(f'Unauthorized, exiting.')
                    sys.exit(1)
                else:
                    self.logger.critical(
                        f'Unexpected error occured: {r.status_code}. Exiting.')
                    # pprint(r.text)
                    sys.exit(1)

                total = r.headers.get('Content-Length')
                num_chunks = round(int(total) / self.chunk_size)

                file_path = Path(
                    output_path,
                    self.dict_info_clip[clip].cameraName.replace(' ', '_'),
                    self.dict_info_clip[clip].fullFileName)
                if not file_path.parent.exists():
                    file_path.parent.mkdir(exist_ok=True)

                with open(file_path, 'wb') as f:
                    for data in pb(
                            r.iter_content(chunk_size=self.chunk_size),
                            total=num_chunks,
                            label=f'Downloading',
                            remove_when_done=False,
                    ):
                        f.write(data)