def engage( self ): if not self.silent: pyprel.print_line() # logo if self.display_logo: if not self.silent: log.info(pyprel.center_string(text = self.logo)) pyprel.print_line() # engage alert if self.name: if not self.silent: log.info("initiate {name}".format( name = self.name )) # version if self.version: if not self.silent: log.info("version: {version}".format( version = self.version )) if not self.silent: log.info("initiation time: {time}".format( time = clock.start_time() ))
def main(options): global program program = propyte.Program( options = options, name = name, version = version, logo = logo ) global log from propyte import log interval = float(options["--interval"]) clock_restart = shijian.Clock(name = "restart") log.info("\nrestart interval: {interval} s".format(interval = interval)) while True: log.info("\ncurrent run time: {run_time}".format(run_time = clock_restart.time())) log.info("restart yet? (i.e. current run time >= interval): {restart}".format(restart = clock_restart.time() >= interval)) if clock_restart.time() >= interval: print(pyprel.center_string(text = pyprel.render_banner(text = "restart"))) propyte.restart() time.sleep(1)
def main(options): global program program = propyte.Program(options=options, name=name, version=version, logo=logo) global log from propyte import log interval = float(options["--interval"]) clock_restart = shijian.Clock(name="restart") log.info("\nrestart interval: {interval} s".format(interval=interval)) while True: log.info("\ncurrent run time: {run_time}".format( run_time=clock_restart.time())) log.info("restart yet? (i.e. current run time >= interval): {restart}". format(restart=clock_restart.time() >= interval)) if clock_restart.time() >= interval: print( pyprel.center_string(text=pyprel.render_banner( text="restart"))) propyte.restart() time.sleep(1)
def main(options): interval = float(options["--interval"]) print(pyprel.center_string(text = pyprel.render_banner(text = "start"))) clock_restart = shijian.Clock(name = "restart") print("restart interval: {interval} s".format(interval = interval)) while True: print("\ncurrent run time: {run_time}".format(run_time = clock_restart.time())) print("restart yet? (i.e. current run time >= interval): {restart}".format(restart = clock_restart.time() >= interval)) if clock_restart.time() >= interval: print(pyprel.center_string(text = pyprel.render_banner(text = "restart"))) os.execv(__file__, sys.argv) time.sleep(1)
def engage(self): pyprel.print_line() # logo if self.display_logo: log.info(pyprel.center_string(text=self.logo)) pyprel.print_line() # engage alert if self.name: log.info("initiate {name}".format(name=self.name)) # version if self.version: log.info("version: {version}".format(version=self.version)) log.info("initiation time: {time}".format(time=clock.start_time()))
def main(): scalar.setup() scalar.room.backfill_previous_messages(limit=20) scalar.room.add_listener(on_message) scalar.client.start_listener_thread() display_refresh() while True: message = get_input() if message.lower() in ["exit", "quit"]: terminal_flash_clear() line() print(pyprel.center_string("EXIT")) line() time.sleep(0.5) line() terminal_flash_clear() sys.exit(0) else: scalar.room.send_text(message) time.sleep(0.1)
def logo(): line() print(pyprel.center_string(text=name + " VERSION " + __version__)) line()
def main(): print("\nexample: printout of dictionary") get_input("Press Enter to continue.") information = { "sample information": { "ID": 169888, "name": "ttH", "number of events": 124883, "cross section": 0.055519, "k factor": 1.0201, "generator": "pythia8", "variables": { "trk_n": 147, "zappo_n": 9001 } } } pyprel.print_line() pyprel.print_dictionary(dictionary = information) pyprel.print_line() print(pyprel.dictionary_string(dictionary = information)) pyprel.print_line() print("\nexample: printout of existing logo") get_input("Press Enter to continue.") text = ( " ____ _ _____ _ \n" " / ___|___ | | ___ _ __| ___| | _____ __ \n" " | | / _ \| |/ _ \| '__| |_ | |/ _ \ \ /\ / / \n" " | |__| (_) | | (_) | | | _| | | (_) \ V V / \n" " \____\___/|_|\___/|_| |_| |_|\___/ \_/\_/ " ) pyprel.print_center(text = text) print("\nexample: rendering and printout of logo") get_input("Press Enter to continue.") name = "aria" logo = pyprel.render_banner( text = name.upper() ) pyprel.print_line() print(pyprel.center_string(text = logo)) pyprel.print_line() print("\nexample: rendering and printout segment display") get_input("Press Enter to continue.") print(pyprel.render_segment_display(text = "0123456789")) print("\nexample: printout of tables") get_input("Press Enter to continue.") table_contents = [ ["heading 1", "heading 2"], ["some text", "some more text"], ["lots and lots and lots and lots and lots of text", "some more text"] ] print( pyprel.Table( contents = table_contents, column_width = 25 ) ) print( pyprel.Table( contents = table_contents, table_width_requested = 30 ) ) print( pyprel.Table( contents = table_contents, table_width_requested = 30, hard_wrapping = True ) ) print( pyprel.Table( contents = table_contents ) ) pyprel.print_center( text = pyprel.Table( contents = table_contents, table_width_requested = 30 ).__str__() ) print( pyprel.Table( contents = table_contents, column_width = 25, column_delimiter = "||" ) ) print( pyprel.Table( contents = table_contents, column_width = 25, row_delimiter = "~" ) ) table_contents = [ [ "heading 1", "heading 2", "heading 3" ], [ "some text", "some more text", "even more text" ], [ "lots and lots and lots and lots and lots of text", "some more text", "some more text" ] ] print( pyprel.Table( contents = table_contents ) ) table_contents = [ [ "heading 1", "heading 2", "heading 3", "heading 4" ], [ "some text", "some more text", "even more text", "yeah more text" ], [ "lots and lots and lots and lots and lots of text", "some more text", "some more text", "some more text" ] ] print( pyprel.Table( contents = table_contents ) )