我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用app.App()。
def main_menu(): while True: clear() menu_items = [ {"title": "Browse app library", "function": store}, {"title": "Update apps and libs", "function": update}, {"title": "Remove app", "function": remove} ] option = dialogs.prompt_option(menu_items, none_text="Exit", text="What do you want to do?", title="TiLDA App Library") if option: option["function"]() else: return
def update(): clear() connect() with dialogs.WaitingMessage(text="Downloading full list of library files", title="TiLDA App Library") as message: message.text="Downloading full list of library files" master = http_client.get("http://api.badge.emfcamp.org/firmware/master-lib.json").raise_for_status().json() libs_to_update = [] for lib, expected_hash in master.items(): if expected_hash != filesystem.calculate_hash("lib/" + lib): libs_to_update.append({ "url": "http://api.badge.emfcamp.org/firmware/master/lib/" + lib, "target": "lib/" + lib, "expected_hash": expected_hash, "title": lib }) download_list(libs_to_update, message) apps = get_local_apps() for i, app in enumerate(apps): message.text = "Updating app %s" % app if app.fetch_api_information(): download_app(app, message) dialogs.notice("Everything is up-to-date")
def store(): global apps_by_category while True: empty_local_app_cache() clear() connect() with dialogs.WaitingMessage(text="Fetching app library...", title="TiLDA App Library"): categories = get_public_app_categories() category = dialogs.prompt_option(categories, text="Please select a category", select_text="Browse", none_text="Back") if category: store_category(category) else: return
def __init__(self, ip, port, agent_port, username, password, pub_key_auth, tools): # Setup params self._ip = ip self._port = port self._agent_port = agent_port self._username = username self._password = password self._pub_key_auth = bool(pub_key_auth) self._tools_local = tools # Init related objects self.app = App(self) self.local_op = LocalOperations() self.remote_op = RemoteOperations(self) self.printer = Printer() self.agent = NeedleAgent(self) # ================================================================================================================== # UTILS - USB # ==================================================================================================================
def connect(): wifi.connect( wait=True, show_wait_message=True, prompt_on_fail=True, dialog_title='TiLDA App Library' ) ### VIEWS ###
def store_details(category, app): clear() empty_local_app_cache() with dialogs.WaitingMessage(text="Fetching app information...", title="TiLDA App Library"): app.fetch_api_information() clear() if dialogs.prompt_boolean(app.description, title = str(app), true_text = "Install", false_text="Back"): install(app) dialogs.notice("%s has been successfully installed" % app)
def remove(): clear() app = dialogs.prompt_option(get_local_apps(), title="TiLDA App Library", text="Please select an app to remove", select_text="Remove", none_text="Back") if app: clear() with dialogs.WaitingMessage(text="Removing %s\nPlease wait..." % app, title="TiLDA App Library"): for file in os.listdir(app.folder_path): os.remove(app.folder_path + "/" + file) os.remove(app.folder_path) remove()
def __init__(self, app): self.app = App(app)
def initializeGL(self): self.app = App()