def _lldp_rename_get_fstr(): rtxt = "[bright_blue]RESULT: [/bright_blue]" point_txt = "[bright_blue]-->[/bright_blue]" lldp_rename_text = f""" [bright_green]Auto rename APs based on LLDP:[/] [bold cyan]This function will automatically rename APs based on a combination of information from the upstream switch (via LLDP) and from the AP itself.[/] [cyan]Use the following field indicators:[reset] %h: switch hostname %m: AP MAC %p: switch port %M: AP model %S: site %s: AP serial [cyan]Values used in the examples below:[/] switch hostname (%h): 'SNAN-IDF3-sw1' switch port (%p): 7 AP mac (%m): aa:bb:cc:dd:ee:ff AP model (%M): 655 site (%S): WadeLab [italic]Note: serial (%s) not shown as examples but follow same format.[/] [bold bright_green]Format String Syntax:[/] '%h[1:2]' will use the first 2 characters of the switches hostname. {rtxt} 'SN' '%h[2:4]' will use characters 2 through 4 of the switches hostname. {rtxt} 'NAN' '%h-1' will split the hostname into parts separating on '-' and use the firt segment. {rtxt} 'SNAN '%p' represents the interface. {rtxt} '7' '%p/3' seperates the port string on / and uses the 3rd segment. {rtxt} (given port 1/1/7): '7' '%M' represents the the AP model. {rtxt} '655' '%m[-4]' The last 4 digits of the AP MAC [italic]NOTE: delimiters ':' are stripped from MAC[/] {rtxt} 'eeff' [bold bright_green]Examples:[/] %h-1-AP%M-%m[-4] {point_txt} [cyan]SNAN-AP535-eeff[/] %h[1-4]-%h-2%h-3.p%p.%M-ap {point_txt} [cyan]SNAN-IDF3sw1.p7.535-ap[/] %S-%h-1-%M-%m[-4]-ap {point_txt} [cyan]WadeLab-SNAN-655-eeff-ap[/] %h-1-%M.%m[-4]-ap {point_txt} [cyan]SNAN-535.eeff-ap[/] [italic bright_red]Note:[/][italic] Automation will only apply to APs that are [bright_green]Up[/]. [italic]Use[/] [cyan]'cencli show aps --down'[/] to see APs that were excluded. """ while True: print(lldp_rename_text) fstr = typer.prompt("Enter Desired format string",) if "%%" in fstr: typer.clear() print(f"\n[cyan]{fstr}[/] appears to be invalid. Should never be 2 consecutive '%'.") else: return fstr
def list(group_name: Optional[str] = None): """List the navigation destinations.""" typer.clear() if group_name is not None: print(parsed_groups.filter([group_name])) else: print(parsed_groups)
def cli( pomodoros_to_run: int = 5, work_minutes: int = 25, short_break: int = 5, long_break: int = 30, set_size: int = 4, ): session_stats = { "total": pomodoros_to_run, "done": 0, "todo": pomodoros_to_run } global stats stats = update_session_stats(session_stats) typer.clear() all_pomodoros = list(range(1, pomodoros_to_run + 1)) pomodoro_sets = sets_of_pomodoros(all_pomodoros, set_size) for pomo_set in pomodoro_sets: run_pomodoro_set(pomo_set, work_minutes, short_break, long_break)
def _lldp_rename_get_fstr(): rtxt = typer.style("RESULT: ", fg=typer.colors.BRIGHT_BLUE) while True: typer.secho("Rename APs based on LLDP:", fg="bright_green") typer.echo( " This function will automatically rename APs based on a combination of\n" " information from the upstream switch (via LLDP) and from the AP itself.\n\n" " Values used in the examples below: \n" " switch hostname (%h): 'SNAN-IDF3-sw1'\n" " switch port (%p): 7\n" " AP mac (%m): aa:bb:cc:dd:ee:ff\n" " AP model (%M): 535\n\n" f"{typer.style('Format String Syntax:', fg='bright_green')}\n" " '%h[1:2]' will use the first 2 characters of the switches hostname.\n" f" {rtxt} 'SN'\n" " '%h[2:4]' will use characters 2 through 4 of the switches hostname.\n" f" {rtxt} 'NAN'\n" " '%h-1' will split the hostname into parts separating on '-' and use\n" " the firt segment.\n" f" {rtxt} 'SNAN\n" " '%p' represents the interface.\n" f" {rtxt} '7'\n" " '%p/3' seperates the port string on / and uses the 3rd segment.\n" f" {rtxt} (given port 1/1/7): '7'\n" f" '%M' represents the the AP model.\n" f" {rtxt} '535'\n" " '%m' The MAC of the AP NOTE: delimiters ':' are stripped from MAC\n" " '%m[-4]' The last 4 digits of the AP MAC\n" f" {rtxt} 'eeff'\n\n" f"{typer.style('Examples:', fg='bright_green')}\n" f" %h-1-AP%M-%m[-4] {rtxt} SNAN-AP535-eeff\n" f" %h[1-4]-%h-2%h-3.p%p.%M-ap {rtxt} SNAN-IDF3sw1.p7.535-ap\n" f" %h-1-%M.%m[-4]-ap {rtxt} SNAN-535.eeff-ap\n" ) fstr = typer.prompt("Enter Desired format string",) if "%%" in fstr: typer.clear() typer.secho(f"\n{fstr} appears to be invalid. Should never be 2 consecutive '%'.\n", fg="red") else: return fstr
def groups(): """List all the groups.""" typer.clear() for group in parsed_groups.list_groups(): print(group)
def render(self, mode='rgb_array'): if mode == 'rgb_array': tile_color_map = { 2: (255, 255, 0), 4: (255, 0, 0), 8: (255, 0, 255), 16: (0, 0, 255), 32: (0, 255, 255), 64: (0, 255, 0), 128: (128, 128, 0), 256: (128, 0, 0), 512: (128, 0, 128), 1024: (0, 0, 128), 2048: (0, 128, 128), 4096: (0, 128, 0), 8192: (0, 0, 0), } ts = 100 bs = self.board_size * ts import pyglet from gym.envs.classic_control import rendering class DrawText: def __init__(self, label:pyglet.text.Label): self.label=label def render(self): self.label.draw() if self.viewer is None: self.viewer = rendering.Viewer(bs[1], bs[0]) self.viewer = rendering.Viewer(bs[1], bs[0]) self.viewer.set_bounds(0, bs[1], 0, bs[0]) for row in range(self.board_size[0]): for col in range(self.board_size[1]): value = 2**int(self.state[row, col]) if value == 1: continue rectangle_coords = [ (ts*(col+0.05), ts*(row+0.05)), (ts*(col+0.95), ts*(row+0.05)), (ts*(col+0.95), ts*(row+0.95)), (ts*(col+0.05), ts*(row+0.95)), ] color = tile_color_map[value] text = str(value) label = pyglet.text.Label(text, font_size=25, x=ts*(col+0.5), y=ts*(row+0.5), anchor_x='center', anchor_y='center', color=(0, 0, 0, 255)) label.draw() #self.viewer.add_geom(DrawText(label)) self.viewer.draw_polygon(rectangle_coords, color=color) return self.viewer.render(return_rgb_array = mode=='rgb_array') if mode == "console": typer.clear() cols = self.board_size[1] rows = self.board_size[0] row_divider = "-----".join(["+"]*(cols+1)) row_padder = " ".join(["|"]*(cols+1)) values = (2**self.state).tolist() str_values = [[str(value).rjust(3).ljust(5) if value != 1 else " " for value in row] for row in values] typer.echo(row_divider) for row in str_values: typer.echo(row_padder) typer.echo("|"+"|".join(row)+"|") typer.echo(row_padder) typer.echo(row_divider)