def display(text): header=["Press ESC to quit. Use the keys to navigate, or use the hotkeys:", "(h)ome, (e)nd, (n)ext, (p)revious, page_(u)p and page_(d)own"] nav={"home": "h", "end": "e", "next": "n", "prev": "p", "pg_up": "u", "pg_dn": "d"} screen = Specter() screen.start() screen.scroll(text, header=header, nav=nav) screen.stop()
def main(apps=None, network='test'): # create virtual file system /sdram # for temp untrusted data storage rampath = platform.mount_sdram() # define hosts - USB, QR, SDCard # each hosts gets it's own RAM folder for data hosts = [ QRHost(rampath + "/qr"), USBHost(rampath + "/usb"), # SDHost(rampath+"/sd"), # not implemented yet ] # define GUI gui = SpecterGUI() # folder where keystore will store it's data keystore_path = platform.fpath("/flash/keystore") # define KeyStore keystore = FlashKeyStore(keystore_path) # loading apps if apps is None: apps = load_apps() # make Specter instance settings_path = platform.fpath("/flash") specter = Specter(gui=gui, keystore=keystore, hosts=hosts, apps=apps, settings_path=settings_path, network=network) specter.start()
def main(apps=None, network="main", keystore_cls=None): """ apps: list of apps to load network: default network to operate keystores: list of KeyStore classes that can be used """ # create virtual file system /sdram # for temp untrusted data storage rampath = platform.mount_sdram() # define hosts - USB, QR, SDCard # each hosts gets it's own RAM folder for data Host.SETTINGS_DIR = platform.fpath("/qspi/hosts") hosts = [ USBHost(rampath + "/usb"), QRHost(rampath + "/qr"), SDHost(rampath + "/sd"), ] # temp storage in RAM for host commands processing BaseApp.TEMPDIR = rampath + "/tmp" # define GUI if not platform.simulator: gui = SpecterGUI() else: # this GUI can simulate user actions for automated testing from gui.tcp_gui import TCPGUI gui = TCPGUI() # inject the folder where keystore stores it's data KeyStore.path = platform.fpath("/flash/keystore") # detect keystore to use if keystore_cls is not None: keystores = [keystore_cls] else: keystores = [ MemoryCard, SDKeyStore, ] # loading apps if apps is None: apps = load_apps() # make Specter instance settings_path = platform.fpath("/flash") specter = Specter( gui=gui, keystores=keystores, hosts=hosts, apps=apps, settings_path=settings_path, network=network, ) specter.start()
def main(apps=None, network="test", keystore_cls=None): """ apps: list of apps to load network: default network to operate keystores: list of KeyStore classes that can be used """ # create virtual file system /sdram # for temp untrusted data storage rampath = platform.mount_sdram() # define hosts - USB, QR, SDCard # each hosts gets it's own RAM folder for data hosts = [ QRHost(rampath + "/qr"), USBHost(rampath + "/usb"), # SDHost(rampath+"/sd"), # not implemented yet ] # define GUI gui = SpecterGUI() # inject the folder where keystore stores it's data KeyStore.path = platform.fpath("/flash/keystore") # detect keystore to use if keystore_cls is not None: keystores = [keystore_cls] else: keystores = [ SDKeyStore, # uncomment this if you want to # enable smartcard support: # MemoryCard, ] # loading apps if apps is None: apps = load_apps() # make Specter instance settings_path = platform.fpath("/flash") specter = Specter( gui=gui, keystores=keystores, hosts=hosts, apps=apps, settings_path=settings_path, network=network, ) specter.start()
def display(text): header = [ "Press ESC to quit. Use the keys to navigate, or use the hotkeys:", "(h)ome, (e)nd, (n)ext, (p)revious, page_(u)p and page_(d)own" ] nav = { "home": "h", "end": "e", "next": "n", "prev": "p", "pg_up": "u", "pg_dn": "d" } screen = Specter() screen.start() screen.scroll(text, header=header, nav=nav) screen.stop()
to_print = screen._justify(someText) screen.splash(to_print) def userinput(): inp = screen.userInput("Type some text") screen.splash([inp]) longString = '''This is a very long line. So long, it shouldn't fit on most screens. You should consider yourself lucky if this fits on a single screen.''' text = [{'t': "this is a test", 'm':'bold'}] splash = [{'t': 'random splash screen', 'm': 'title'}, {'t': 'random text filling the screen'}, {'t': ' '}, {'t': ' [ Press enter to continue ]', 'm': 'bold'}] table = [{'tn': 'table1', 'tc': [{'t': "Head1", 'm': 'title'}, "Head2", "Head3", "Head4"]}, {'tn': 'table1', 'tc': ["val1", "val2", "val3", "val 4" ]}, {'tn': 'table1', 'tc': ["value1", "value__2", "value3", "value4" ]}] text.extend(table) for i in range(1, 11): text.extend([{'t': "line "+ str(i)}]) text.extend([{'t': longString}]) text.extend([{'t': 'Press e or u for examples of functions bound to keys'}]) text.extend([{'t': 'Press Enter here to perform a function with args', 'a': example2, 'p': ["Some text"]}]) text.extend([{'t': 'Press Enter here to show text in a justified splash screen', 'a': justified}]) screen.start() screen.splash(splash) screen.scroll(text, functions={'e': example, 'u': userinput, 'p': popup}, cursor=True) screen.stop()