From c461c6ff6fcde2e89be9b16de8c8e97a67c03690 Mon Sep 17 00:00:00 2001 From: dbarzin Date: Thu, 16 Jun 2022 13:24:36 +0200 Subject: [PATCH] configuration file --- pandorabox.ini | 15 +++++++++++++++ pandorabox.py | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 pandorabox.ini diff --git a/pandorabox.ini b/pandorabox.ini new file mode 100644 index 0000000..84efa0e --- /dev/null +++ b/pandorabox.ini @@ -0,0 +1,15 @@ +[DEFAULT] + +; Set USB_AUTO_MOUNT to true is if the OS mount automaticaly mount USB keys +USB_AUTO_MOUNT = True + +; Set NO_SCAN to true to skip the scan process +NO_SCAN = True + +; Set PANDORA_ROOT_URL to the URL of the Pandora server +; the default value is "http://127.0.0.1:6100" +PANDORA_ROOT_URL = "http://127.0.0.1:6100" + +; Set FAKE_SCAN to true to fake the scan process +FAKE_SCAN = True + diff --git a/pandorabox.py b/pandorabox.py index 04203f9..5bd4828 100755 --- a/pandorabox.py +++ b/pandorabox.py @@ -12,15 +12,28 @@ import psutil import os import logging import time +import configparser # ----------------------------------------------------------- # Config variables # ----------------------------------------------------------- NO_SCAN = True -USB_AUTO_MOUNT = True +USB_AUTO_MOUNT = False PANDORA_ROOT_URL = "http://127.0.0.1:6100" -FAKE_SCAN = True +FAKE_SCAN = False + +""" read configuration file """ +def config(): + # intantiate a ConfirParser + config = configparser.ConfigParser() + # read the config file + config.read('pandorabox.ini') + # set values + NO_SCAN=config['DEFAULT']['NO_SCAN'] + USB_AUTO_MOUNT=config['DEFAULT']['USB_AUTO_MOUNT'] + PANDORA_ROOT_URL=config['DEFAULT']['PANDORA_ROOT_URL'] + FAKE_SCAN=config['DEFAULT']['FAKE_SCAN'] # ---------------------------------------------------------- @@ -161,6 +174,18 @@ s[7] = " ░░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ s[8] = " ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ " s[9] = " ░ ░ " +s[0] = " ██▓███ ▄▄▄ ███▄ █ ▓█████▄ ▒█████ ██▀███ ▄▄▄ ▄▄▄▄ ▒█████ ▒██ ██▒" +s[1] = " ▓██░ ██▒▒████▄ ██ ▀█ █ ▒██▀ ██▌▒██▒ ██▒▓██ ▒ ██▒▒████▄ ▓█████▄ ▒██▒ ██▒▒▒ █ █ ▒░" +s[2] = " ▓██░ ██▓▒▒██ ▀█▄ ▓██ ▀█ ██▒░██ █▌▒██░ ██▒▓██ ░▄█ ▒▒██ ▀█▄ ▒██▒ ▄██▒██░ ██▒░░ █ ░" +s[3] = " ▒██▄█▓▒ ▒░██▄▄▄▄██ ▓██▒ ▐▌██▒░▓█▄ ▌▒██ ██░▒██▀▀█▄ ░██▄▄▄▄██ ▒██░█▀ ▒██ ██░ ░ █ █ ▒ " +s[4] = " ▒██▒ ░ ░ ▓█ ▓██▒▒██░ ▓██░░▒████▓ ░ ████▓▒░░██▓ ▒██▒ ▓█ ▓██▒ ░▓█ ▀█▓░ ████▓▒░▒██▒ ▒██▒" +s[5] = " ▒▓▒░ ░ ░ ▒▒ ▓▒█░░ ▒░ ▒ ▒ ▒▒▓ ▒ ░ ▒░▒░▒░ ░ ▒▓ ░▒▓░ ▒▒ ▓▒█░ ░▒▓███▀▒░ ▒░▒░▒░ ▒▒ ░ ░▓ ░" +s[6] = " ░▒ ░ ▒ ▒▒ ░░ ░░ ░ ▒░ ░ ▒ ▒ ░ ▒ ▒░ ░▒ ░ ▒░ ▒ ▒▒ ░ ▒░▒ ░ ░ ▒ ▒░ ░░ ░▒ ░" +s[7] = " ░░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ ▒ ░░ ░ ░ ▒ ░ ░ ░ ░ ░ ▒ ░ ░ " +s[8] = " ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ " +s[9] = " ░ ░ " + + """Print main screen""" def print_screen(): global status_win @@ -376,11 +401,14 @@ def scan(mount_point, used): def main(stdscr): try : init_log() + config() intit_curses() print_screen() while True: device_loop() except Exception as e : + end_curses() + print("Unexpected error: ", e) logging.error("Unexpected error: ", e) # logging.error(traceback.format_exc()) finally: