Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,94 @@
|
|
| 1 |
import random
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
|
| 4 |
-
def
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
return history, history
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
)
|
| 16 |
-
if __name__ == "__main__":
|
| 17 |
-
demo.launch(enable_queue = True)
|
| 18 |
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import random
|
| 2 |
import gradio as gr
|
| 3 |
+
import easy_db
|
| 4 |
|
| 5 |
+
def process_request(id_textbox, installer_textbox,boot_state_textbox,verify_textbox,patch_level_textbox,
|
| 6 |
+
oem_textbox,brand_textbox,model_textbox,unlocked_textbox,debug_enabled_textbox,
|
| 7 |
+
primary_certificate_textbox,emulator_textbox,fingerprint_status_textbox,storage_encryption_status_textbox,
|
| 8 |
+
market_apps_enabled_textbox,adb_enabled_textbox,lock_screen_timeout_textbox,
|
| 9 |
+
lock_screen_type_textbox,notification_visibility_textbox):
|
| 10 |
|
| 11 |
+
db = easy_db.DataBase('device_data.db')
|
|
|
|
| 12 |
|
| 13 |
+
print(id_textbox, installer_textbox,boot_state_textbox,verify_textbox,patch_level_textbox,
|
| 14 |
+
oem_textbox,brand_textbox,model_textbox,unlocked_textbox,debug_enabled_textbox,
|
| 15 |
+
primary_certificate_textbox,emulator_textbox,fingerprint_status_textbox,storage_encryption_status_textbox,
|
| 16 |
+
market_apps_enabled_textbox,adb_enabled_textbox,lock_screen_timeout_textbox,
|
| 17 |
+
lock_screen_type_textbox,notification_visibility_textbox)
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
|
| 20 |
+
|
| 21 |
+
dict_of_device_data_to_save = {"id_textbox":id_textbox,
|
| 22 |
+
"installer_textbox":installer_textbox,
|
| 23 |
+
"boot_state_textbox":boot_state_textbox,
|
| 24 |
+
"verify_textbox":verify_textbox,
|
| 25 |
+
"patch_level_textbox":patch_level_textbox,
|
| 26 |
+
"oem_textbox":oem_textbox,
|
| 27 |
+
"brand_textbox":brand_textbox,
|
| 28 |
+
"model_textbox":model_textbox,
|
| 29 |
+
"unlocked_textbox":unlocked_textbox,
|
| 30 |
+
"debug_enabled_textbox":debug_enabled_textbox,
|
| 31 |
+
"primary_certificate_textbox":primary_certificate_textbox,
|
| 32 |
+
"emulator_textbox":emulator_textbox,
|
| 33 |
+
"fingerprint_status_textbox":fingerprint_status_textbox,
|
| 34 |
+
"storage_encryption_status_textbox":storage_encryption_status_textbox,
|
| 35 |
+
"market_apps_enabled_textbox":market_apps_enabled_textbox,
|
| 36 |
+
"adb_enabled_textbox":adb_enabled_textbox,
|
| 37 |
+
"lock_screen_timeout_textbox":lock_screen_timeout_textbox,
|
| 38 |
+
"lock_screen_type_textbox":lock_screen_type_textbox,
|
| 39 |
+
"notification_visibility_textbox":notification_visibility_textbox}
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
db.append('devices', [dict_of_device_data_to_save])
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
history = []
|
| 46 |
+
history.append(["Initialisation error!", "Please tune the model by using the above options"])
|
| 47 |
+
return history
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
block = gr.Blocks(css=".container { max-width: 800px; margin: auto; } h1 { margin: 0px; padding: 5px 0; line-height: 50px; font-size: 60pt; }.close-heading {margin: 0px; padding: 0px;} .close-heading p { margin: 0px; padding: 0px;}", title="Boudica")
|
| 53 |
+
|
| 54 |
+
with block:
|
| 55 |
+
chatbot = gr.Chatbot().style(color_map=("green", "pink"))
|
| 56 |
+
# ID
|
| 57 |
+
id_textbox = gr.Textbox(label="Android Secure ID")
|
| 58 |
+
# Misc
|
| 59 |
+
installer_textbox = gr.Textbox(label="Installer")
|
| 60 |
+
debug_enabled_textbox = gr.Textbox(label="Debug Enabled")
|
| 61 |
+
primary_certificate_textbox = gr.Textbox(label="primary_certificate")
|
| 62 |
+
emulator_textbox = gr.Textbox(label="Emulator")
|
| 63 |
+
# Device Data
|
| 64 |
+
boot_state_textbox = gr.Textbox(label="Verify Boot State")
|
| 65 |
+
verify_textbox = gr.Textbox(label="Verify Mode")
|
| 66 |
+
patch_level_textbox = gr.Textbox(label="Security Patch Level")
|
| 67 |
+
oem_textbox = gr.Textbox(label="OEM Unlock Supported")
|
| 68 |
+
brand_textbox = gr.Textbox(label="Product Brand")
|
| 69 |
+
model_textbox = gr.Textbox(label="Product Model")
|
| 70 |
+
unlocked_textbox = gr.Textbox(label="OEM Unlock Status")
|
| 71 |
+
# Settings
|
| 72 |
+
fingerprint_status_textbox = gr.Textbox(label="Fingerprint Status")
|
| 73 |
+
storage_encryption_status_textbox = gr.Textbox(label="Storage Encryption Status")
|
| 74 |
+
market_apps_enabled_textbox = gr.Textbox(label="Market Apps Enabled")
|
| 75 |
+
adb_enabled_textbox = gr.Textbox(label="ADB Enabled")
|
| 76 |
+
lock_screen_timeout_textbox = gr.Textbox(label="Lock Screen Timeout")
|
| 77 |
+
lock_screen_type_textbox = gr.Textbox(label="Lock Screen Type")
|
| 78 |
+
notification_visibility_textbox = gr.Textbox(label="Lock Screen Type")
|
| 79 |
+
|
| 80 |
+
btn = gr.Button(label="Submit Data")
|
| 81 |
+
btn.click(fn=process_request, inputs=[id_textbox, installer_textbox,boot_state_textbox,verify_textbox,patch_level_textbox,
|
| 82 |
+
oem_textbox,brand_textbox,model_textbox,unlocked_textbox,debug_enabled_textbox,
|
| 83 |
+
primary_certificate_textbox,emulator_textbox,fingerprint_status_textbox,storage_encryption_status_textbox,
|
| 84 |
+
market_apps_enabled_textbox,adb_enabled_textbox,lock_screen_timeout_textbox,
|
| 85 |
+
lock_screen_type_textbox,notification_visibility_textbox],
|
| 86 |
+
outputs=[chatbot],api_name="submit")
|
| 87 |
+
|
| 88 |
+
# Setup callback for when page loads (used to set a new Twitter auth target webspage)
|
| 89 |
+
block.__enter__()
|
| 90 |
+
|
| 91 |
+
#block.attach_load_events()
|
| 92 |
+
|
| 93 |
+
# Launcg the page
|
| 94 |
+
block.launch(enable_queue = True)
|