How to use erase_line method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

TEST_gui.py

Source:TEST_gui.py Github

copy

Full Screen

1#!/usr/bin/env python2__import__('sys').path.append(__import__('os').path.join(__import__('os').path.dirname(__file__), ''))3__import__('testfwk').setup(__file__)4# - prolog marker5import logging6from testfwk import TestsuiteStream, cleanup_workflow, create_config, run_test, testfwk_create_workflow, try_catch7from grid_control.gui import GUI8from grid_control.stream_base import ActivityMonitor9from grid_control.utils.activity import Activity10from grid_control.utils.thread_tools import GCEvent11from grid_control_gui.ansi import ANSI, Console12from grid_control_gui.ge_base import GUIElement13def log_stuff():14 msg_list = ['SUCCESS', 'TEST'*10, 'SUCCESS', 'DONE'] * 2015 for msg in msg_list:16 logging.getLogger().info(msg)17class Test_GUI(object):18 """19 >>> workflow = testfwk_create_workflow({'jobs': {'jobs': 1}})20 Current task ID: GC000000000021 Task started on: 0000-00-0022 Using batch system: ---23 >>> gui = GUI.create_instance('GUI', create_config(), workflow)24 >>> gui.start_interface()25 >>> gui.end_interface()26 >>> redraw_event = GCEvent()27 >>> std_stream = TestsuiteStream(display_commands=True)28 >>> ge_base = GUIElement.create_instance('GUIElement', create_config(), 'name', workflow, redraw_event, std_stream)29 >>> try_catch(lambda: ge_base.get_height(), 'AbstractError')30 caught31 >>> try_catch(lambda: ge_base.redraw(), 'AbstractError')32 caught33 >>> span = GUIElement.create_instance('SpanGUIElement', create_config(), 'name', workflow, redraw_event, std_stream)34 >>> span.get_height()35 >>> user_log = GUIElement.create_instance('UserLogGUIElement', create_config(config_dict={'global': {'log dump': False}}), 'name', workflow, redraw_event, std_stream)36 >>> user_log.set_layout(2, 6, 30)37 >>> user_log.draw_startup()38 <erase_line><newline>39 <erase_line><newline>40 <erase_line><newline>41 <erase_line><newline>42 <erase_line><newline>43 <erase_line>44 >>> log_stuff()45 >>> user_log.redraw()46 <move:3,1>47 <bold><color_cyan>DONE<reset><reset><erase_line><newline>48 <bold><color_green>SUCCESS<reset><reset><erase_line><newline>49 TESTTESTTESTTESTTESTTESTTESTTE<reset><erase_line><newline>50 STTESTTEST<reset><erase_line><newline>51 <bold><color_green>SUCCESS<reset><reset><erase_line><newline>52 <bold><color_cyan>DONE<reset><reset><erase_line>53 >>> user_log.draw_finish()54 >>> activity_log = GUIElement.create_instance('ActivityGUIElement', create_config(config_dict={'global': {'activity interval': 0, 'activity stream': 'timed_stream'}}), 'name', workflow, redraw_event, std_stream)55 >>> activity_log.set_layout(41, 2, 30)56 >>> activity_log.draw_startup()57 <erase_line><newline>58 <erase_line>59 >>> activity_log.redraw()60 <move:42,1>61 <erase_line><newline>62 <erase_line>63 >>> activity1 = Activity('working1')64 >>> activity_log.redraw()65 <move:42,1>66 working1...<reset><erase_line><newline>67 <erase_line>68 >>> activity2 = Activity('working2')69 >>> activity_log.redraw()70 <move:42,1>71 working1...<reset><erase_line><newline>72 working2...<reset><erase_line>73 >>> activity3 = Activity('working3')74 >>> activity_log.redraw()75 <move:42,1>76 working1...<reset><erase_line><newline>77 working2...<reset><erase_line>78 >>> activity_log.set_layout(41, 3, 30)79 >>> activity_log.redraw()80 <move:42,1>81 <grayscale:250>working1...<reset><erase_line><reset><erase_line><newline>82 <grayscale:250>working2...<reset><erase_line><reset><erase_line><newline>83 <grayscale:250>working3...<reset><erase_line><reset><erase_line>84 >>> activity1.finish()85 >>> activity2.finish()86 >>> activity3.finish()87 >>> activity_log.redraw()88 >>> activity_log.draw_finish()89 """90class Test_Stream(object):91 """92 >>> std_stream = TestsuiteStream()93 >>> activity = Activity('work ongoing')94 >>> try_catch(lambda: ActivityMonitor.create_instance('ActivityMonitor', create_config(), std_stream).write('Hallo'), 'AbstractError', 'is an abstract function')95 caught96 >>> stream1 = ActivityMonitor.create_instance('null', create_config())97 >>> stream1.write('Hallo\\n')98 >>> stream1.write('Welt\\n')99 >>> stream1.flush()100 >>> std_stream = TestsuiteStream(display_commands=True)101 >>> stream2 = ActivityMonitor.create_instance('single_stream', create_config(), std_stream)102 >>> stream2.write('Hallo\\n')103 Hallo<newline>104 work ongoing...105 >>> stream2.write('Welt\\n')106 -----107 -----108 Welt<newline>109 work ongoing...110 >>> stream2.flush()111 >>> Console.getmaxyx() # default112 (24, 80)113 >>> stream3 = ActivityMonitor.create_instance('multi_stream', create_config(config_dict={'global': {'activity fold fraction': 0.1}}), std_stream)114 >>> stream3.write('Hallo\\n')115 Hallo<erase_line><newline>116 <erase_line><newline>117 <wrap_off>118 <erase_line><grayscale:255>work ongoing...<reset><newline>119 <erase_down><move_up:2><wrap_on>120 >>> stream3.write('Welt\\n')121 Welt<erase_line><newline>122 <erase_line><newline>123 <wrap_off>124 <erase_line><grayscale:255>work ongoing...<reset><newline>125 <erase_down><move_up:2><wrap_on>126 >>> activity1 = Activity('nested work ongoing', name='a1')127 >>> activity2 = Activity('nested nested work ongoing')128 >>> activity3 = Activity('nested nested nested work ongoing')129 >>> stream3.write('')130 <newline>131 <wrap_off>132 <erase_line><grayscale:255>work ongoing...<reset><newline>133 <erase_line> <grayscale:250>nested work ongoing...<reset><newline>134 <erase_down><move_up:3><wrap_on>135 >>> stream3 = ActivityMonitor.create_instance('multi_stream', create_config(config_dict={'global': {'activity fold fraction': 0.5}}), std_stream)136 >>> stream3.write('')137 <newline>138 <wrap_off>139 <erase_line><grayscale:255>work ongoing...<reset><newline>140 <erase_line> <grayscale:250>nested work ongoing...<reset><newline>141 <erase_line> <grayscale:245>nested nested work ongoing...<reset><newline>142 <erase_line> <grayscale:241>nested nested nested work ongoing...<reset><newline>143 <erase_down><move_up:5><wrap_on>144 >>> activity2x = Activity('2nd nested nested work ongoing', parent='a1')145 >>> stream3.write('')146 <newline>147 <wrap_off>148 <erase_line><grayscale:255>work ongoing...<reset><newline>149 <erase_line> <grayscale:250>nested work ongoing...<reset><newline>150 <erase_line> <grayscale:245>nested nested work ongoing...<reset><newline>151 <erase_line> <grayscale:241>nested nested nested work ongoing...<reset><newline>152 <erase_line> <grayscale:245>2nd nested nested work ongoing...<reset><newline>153 <erase_down><move_up:6><wrap_on>154 >>> stream4 = ActivityMonitor.create_instance('multi_stream', create_config(config_dict={'global': {'activity fold fraction': 0.2}}), std_stream)155 >>> stream4.write('')156 <newline>157 <wrap_off>158 <erase_line><grayscale:255>work ongoing...<reset><newline>159 <erase_line> <grayscale:250>nested work ongoing...<reset><newline>160 <erase_line> <grayscale:245>nested nested work ongoing...<reset><newline>161 <erase_line> <grayscale:245>2nd nested nested work ongoing...<reset><newline>162 <erase_down><move_up:5><wrap_on>163 >>> activity.finish()164 """165class Test_ANSI(object):166 """167 >>> tmp = '\x1b[0m\x1b[34mHello\x1b[0m'168 >>> ANSI.strip_fmt(tmp)169 'Hello'170 """...

Full Screen

Full Screen

__main__.py

Source:__main__.py Github

copy

Full Screen

1#!/usr/bin/env python2#3# by Siddharth Dushantha 20204#5import sys6import argparse7import requests8from colorama import Fore, Style9from . import utils10# This magic spell lets me erase the current line.11# I can use this to show for example "Downloading..."12# and then "Downloaded" on the line where13# "Downloading..." was.14ERASE_LINE = '\033[2K'15GOOD = f"{Fore.GREEN}✔{Style.RESET_ALL}"16BAD = f"{Fore.RED}✘{Style.RESET_ALL}"17class Cursor:18 def hide():19 print("\033[?25l", end="\r", flush=True)20 def show():21 print("\033[?25h", end="\r", flush=True)22def main():23 parser = argparse.ArgumentParser(description="A very simple command line Browser Extension Downloader")24 parser.add_argument('url', action="store")25 args = parser.parse_args()26 url = args.url27 Cursor.hide()28 if utils.get_browser(url) == "chrome":29 print(f"{GOOD} Valid Chrome Web Store url")30 print("Getting webpage source code...", end="\r", flush=True)31 extension_data = utils.get_chrome_extension(url)32 print(ERASE_LINE, end="\r", flush=True)33 print(f"{GOOD} Fetched webpage code code")34 file_extension = "crx"35 browser = "chrome"36 elif utils.get_browser(url) == "firefox":37 print(f"{GOOD} Valid Firefox addon url")38 print("Getting webpage source code...", end="\r", flush=True)39 extension_data = utils.get_firefox_extension(url)40 print(ERASE_LINE, end="\r", flush=True)41 print(f"{GOOD} Fetched webpage code code")42 file_extension = "xpi"43 browser = "firefox"44 elif utils.get_browser(url) == "opera":45 print(f"{GOOD} Valid Opera addon url")46 print("Getting webpage source code...", end="\r", flush=True)47 extension_data = utils.get_opera_extension(url)48 print(ERASE_LINE, end="\r", flush=True)49 print(f"{GOOD} Fetched webpage code code")50 file_extension = "crx"51 browser = "opera"52 else:53 print(f"{BAD} Invalid url")54 Cursor.show()55 sys.exit(1)56 file_url = extension_data[0]57 extension_name = extension_data[1]58 extension_version = extension_data[2]59 file_name = f"{browser}_{extension_name}_{extension_version}.{file_extension}"60 print(f"Downloading {file_name}...", end="\r", flush=True)61 response = requests.get(file_url)62 with open(file_name, "wb") as f:63 f.write(response.content)64 print(ERASE_LINE, end="\r", flush=True)65 print(f"{GOOD} Download complete: {file_name}")66 Cursor.show()67if __name__ == "__main__":...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

...10# ------------------------------------------------------------11# Create a maze by randomly deleting either 12# the "Eastern" (left) or "Southern" (bottom) wall of every cell.13#14# Your code, ENCAPSULATED IN A FUNCTION, will replace the erase_line() 15# calls below, which you need to comment out before running your function.16#17# ------------------------------------------------------------18print ("\n Maze erase commands:\n")19'''maze.erase_line(0, 'South')20maze.erase_line(1, 'East')21maze.erase_line(2, 'South')22maze.erase_line(3, 'East')23maze.erase_line(4, 'South')24maze.erase_line(5, 'South')25maze.erase_line(6, 'East')26maze.erase_line(7, 'East')27maze.erase_line(8, 'None')'''28def create_maze():29 ''' Erases lines to create a maze '''30 31 maze_size = columns * rows32 33 #Creates a list of cells in the bottom row34 bottom_row = []35 for i in range(maze_size - columns, maze_size):36 bottom_row.append(i)37 38 #Creates a list of cells in the far-right column39 right_column = []40 for l in range(rows):41 right_column.append((l * columns)-1)42 43 for cell in range(0, maze_size-1):44 if cell in right_column:45 maze.erase_line(cell, 'South')46 elif cell in bottom_row:47 maze.erase_line(cell, 'East')48 else:49 maze.erase_line(cell, choice(['East', 'South']))50 maze.erase_line(maze_size-1, "None")51 52create_maze()53# Don't modify the code below:54# Print square numbers for each cell of the maze: color = "red", "blue", etc., or,55#maze.assign_square_numbers(color = "none") # no numbers are displayed56maze.assign_square_numbers("blue")57# Following code prevents graphics window from closing automatically when the program completes58import turtle...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Lemoncheesecake automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful