1
0
Fork 0
mirror of https://github.com/dbarzin/pandora-box.git synced 2025-07-28 17:59:46 +02:00

handle errors

This commit is contained in:
Didier 2022-06-30 12:36:46 +00:00
parent 6e974ca2df
commit f596ed0ebc

View file

@ -72,6 +72,8 @@ def display_image(status):
image = "images/pandora-box3.png" image = "images/pandora-box3.png"
elif status=="BAD": elif status=="BAD":
image = "images/pandora-box4.png" image = "images/pandora-box4.png"
elif status=="ERROR":
image = "images/pandora-box5.png"
else: else:
return return
os.system("convert -resize %s -background black -gravity center -extent %s %s bgra:/dev/fb0" % (SCREEN_SIZE, SCREEN_SIZE, image)) os.system("convert -resize %s -background black -gravity center -extent %s %s bgra:/dev/fb0" % (SCREEN_SIZE, SCREEN_SIZE, image))
@ -304,6 +306,9 @@ def umount_device():
"""Main device loop""" """Main device loop"""
def device_loop(): def device_loop():
# First unmount remaining device
umount_device()
# Loop
context = pyudev.Context() context = pyudev.Context()
monitor = pyudev.Monitor.from_netlink(context) monitor = pyudev.Monitor.from_netlink(context)
monitor.filter_by("block") monitor.filter_by("block")
@ -414,9 +419,9 @@ def scan(mount_point, used):
quanrantine_folder = os.path.join(QUARANTINE_FOLDER,datetime.now().strftime("%y%m%d-%H%M")) quanrantine_folder = os.path.join(QUARANTINE_FOLDER,datetime.now().strftime("%y%m%d-%H%M"))
if not FAKE_SCAN: if not FAKE_SCAN:
pandora = pypandora.PyPandora(root_url=PANDORA_ROOT_URL) pandora = pypandora.PyPandora(root_url=PANDORA_ROOT_URL)
try:
for root, dirs, files in os.walk(mount_point): for root, dirs, files in os.walk(mount_point):
for file in files: for file in files:
try :
status = None status = None
full_path = os.path.join(root,file) full_path = os.path.join(root,file)
file_size = os.path.getsize(full_path) file_size = os.path.getsize(full_path)
@ -455,9 +460,12 @@ def scan(mount_point, used):
if not os.path.isdir(quanrantine_folder) : if not os.path.isdir(quanrantine_folder) :
os.mkdir(quanrantine_folder) os.mkdir(quanrantine_folder)
shutil.copyfile(full_path, os.path.join(quanrantine_folder,file)) shutil.copyfile(full_path, os.path.join(quanrantine_folder,file))
except Exception as e : except Exception as e :
log("Unexpected error: %s" % e) log("Unexpected error: %s" % e)
if not CURSES:
display_image("ERROR")
waitMouseClick()
raise
update_bar(100) update_bar(100)
log("Scan done in %ds, %d files scanned, %d files infected" % log("Scan done in %ds, %d files scanned, %d files infected" %
((time.time() - scan_start_time),file_count,len(infected_files))) ((time.time() - scan_start_time),file_count,len(infected_files)))