1
0
Fork 0
mirror of https://github.com/dbarzin/pandora-box.git synced 2025-07-19 05:19:40 +02:00

configuration file

This commit is contained in:
dbarzin 2022-06-16 13:24:36 +02:00
parent 9f68da0094
commit c461c6ff6f
2 changed files with 45 additions and 2 deletions

15
pandorabox.ini Normal file
View file

@ -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

View file

@ -12,15 +12,28 @@ import psutil
import os import os
import logging import logging
import time import time
import configparser
# ----------------------------------------------------------- # -----------------------------------------------------------
# Config variables # Config variables
# ----------------------------------------------------------- # -----------------------------------------------------------
NO_SCAN = True NO_SCAN = True
USB_AUTO_MOUNT = True USB_AUTO_MOUNT = False
PANDORA_ROOT_URL = "http://127.0.0.1:6100" 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[8] = " ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ "
s[9] = " ░ ░ " 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""" """Print main screen"""
def print_screen(): def print_screen():
global status_win global status_win
@ -376,11 +401,14 @@ def scan(mount_point, used):
def main(stdscr): def main(stdscr):
try : try :
init_log() init_log()
config()
intit_curses() intit_curses()
print_screen() print_screen()
while True: while True:
device_loop() device_loop()
except Exception as e : except Exception as e :
end_curses()
print("Unexpected error: ", e)
logging.error("Unexpected error: ", e) logging.error("Unexpected error: ", e)
# logging.error(traceback.format_exc()) # logging.error(traceback.format_exc())
finally: finally: