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()
class SpecterTestCase(BaseTestCase): SPECTER_OPTIONS = {} def setup_app(self, app): pass def setup(self): # Create application, and set it up. app = Bottle(catchall=False) self.setup_app(app) evt = threading.Event() # Start our application thread. thread = self.thread = ServerThread(app, ready_event=evt) thread.start() # Create Specter instance. self.s = Specter(**self.SPECTER_OPTIONS) # Wait for thread to be ready. evt.wait() # Get info about the server. self.port = self.thread.port self.host = self.thread.host self.baseUrl = "http://%s:%d" % (self.host, self.port) def teardown(self): # Tell our thread to stop. self.thread.stop() # ---------------------------------------------------------------------- # Utility functions # ---------------------------------------------------------------------- def open(self, path, wait=True): """Helper that prefixes with our local address.""" prefix = "http://%s:%d/" % (self.host, self.port) url = prefix + path.lstrip('/') ret = self.s.open(url) if wait: self.s.wait_for_page_load() return ret
def create_app(): if getattr(sys, 'frozen', False): template_folder = os.path.join(os.path.realpath(__file__), 'templates') static_folder = os.path.join(os.path.realpath(__file__), 'static') app = Flask(__name__, template_folder=template_folder, static_folder=static_folder) else: app = Flask(__name__, template_folder="templates", static_folder="static") QRcode(app) # enable qr codes generation specter = Specter(DATA_FOLDER) specter.check() # Attach specter instance so child views (e.g. hwi) can access it app.specter = specter app.register_blueprint(hwi_views, url_prefix='/hwi') with app.app_context(): import controller return app
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 specter_regtest_configured(bitcoin_regtest): # Make sure that this folder never ever gets a reasonable non-testing use-case data_folder = './test_specter_data_3456778' shutil.rmtree(data_folder, ignore_errors=True) config = { "rpc": { "autodetect": False, "user": bitcoin_regtest.rpcuser, "password": bitcoin_regtest.rpcpassword, "port": bitcoin_regtest.rpcport, "host": bitcoin_regtest.ipaddress, "protocol": "http" }, } yield Specter(data_folder=data_folder, config=config) shutil.rmtree(data_folder, ignore_errors=True)
def loadSpecterFromFiles(self): self.dirPath = QtGui.QFileDialog.getExistingDirectory( self.main_frame, "Open Directory", "D:") fileList = glob.glob(self.dirPath + '\*.asc') for fileName in fileList: self.specter.append( Specter(np.loadtxt(fileName), fileName, self.specterCenter, self.windowLength)) if len(self.specter) > 0: self.currentSpecter = 0 self.updateSpecterInput() for specNum in range(0, len(self.specter)): self.statusBar().showMessage('Busy...') self.computeAbelTransform(specNum) self.statusBar().showMessage('Ready') self.on_draw()
def setup(self): # Create application, and set it up. app = Bottle(catchall=False) self.setup_app(app) evt = threading.Event() # Start our application thread. thread = self.thread = ServerThread(app, ready_event=evt) thread.start() # Create Specter instance. self.s = Specter(**self.SPECTER_OPTIONS) # Wait for thread to be ready. evt.wait() # Get info about the server. self.port = self.thread.port self.host = self.thread.host self.baseUrl = "http://%s:%d" % (self.host, self.port)
from specter import Specter screen = Specter() df = ['Press ENTER to select', 'Press ESC to quit'] # Default footer def mainPage(): h=['Main Page'] t=[{'t': "Overview Functions", 'a': functions}, {'t': "Markdown", 'a': markdownExample}] screen.scroll(t, header=h, footer=df, cursor=True) def functions(): h=['Overview Functions'] t=[{'t': "scroll", 'm': 'title'}, {'t': "======", 'm': 'title'}, {'t': "'scroll' is able to scroll through large texts, in different modes."}, {'t': "The parameters of the function are explained below:"}, {'t': " * text - Required - A list of dictionaries representing the content."}, {'t': " -> Press Enter here to see an example", 'm': 'bold', 'a': textExample}, {'t': " * header - Optional - A list of strings, representing a header."}, {'t': " * footer - Optional - A list of strings, representing a footer."}, {'t': " * cursor - default False - Change to cursor mode."}, {'t': " Cursor mode allows the user to select a line and trigger functions"}, {'t': " that are assigned to that line."}, {'t': " * blocking - default True - Blocks the user from entering any other keys"}, {'t': " that are not the ESC or the up/down/left/right nav keys"}, {'t': " -> NOTE: left and right currently not supported", 'm': 'bold'}, {'t': " * nav - Optional - A dictionary with default nav keys as keys"}, {'t': " allows to extend the default nav keys (up/down/left/right/enter/esc)"}, {'t': " -> Press Entr here to see an more information and examples"},
from specter import Specter screen = Specter() def popup(): screen.popup(["This is a", "multiline popup"]) def example2(p): screen.splash(p) def example(): screen.splash([{'t': 'This is an example :)'}]) def justified(): someText = ["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. I'm coding this on a small laptop, so for me it doesn't fit", {'t': "This is the second line of text", 'm': "bold"}] 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"]},