mirror of
https://github.com/dbarzin/pandora-box.git
synced 2025-08-05 05:45:22 +02:00
code quality
This commit is contained in:
parent
ad87e9c61f
commit
40492fac00
2 changed files with 15 additions and 17 deletions
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
|
@ -21,11 +21,9 @@ jobs:
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@master
|
uses: actions/setup-python@master
|
||||||
with:
|
with:
|
||||||
python-version: 3.8
|
python-version: 3.10
|
||||||
|
|
||||||
- name: code quality checkout
|
- name: code quality checkout
|
||||||
run: |
|
run: |
|
||||||
pip install pylint
|
pip install pylint
|
||||||
ls main
|
|
||||||
pylint ./main/pandora-box.py
|
pylint ./main/pandora-box.py
|
||||||
|
|
||||||
|
|
|
@ -392,7 +392,7 @@ def scan(mount_point, used):
|
||||||
res = pandora.submit_from_disk(full_path)
|
res = pandora.submit_from_disk(full_path)
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
loop = 0
|
loop = 0
|
||||||
while True and (loop < 960):
|
while loop < 960:
|
||||||
res = pandora.task_status(res["taskId"])
|
res = pandora.task_status(res["taskId"])
|
||||||
status = res["status"]
|
status = res["status"]
|
||||||
if status != "WAITING":
|
if status != "WAITING":
|
||||||
|
@ -400,11 +400,11 @@ def scan(mount_point, used):
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
loop += 1
|
loop += 1
|
||||||
file_scan_end_time = time.time()
|
file_scan_end_time = time.time()
|
||||||
log("file=%s, size=%s, status=%s, duration=%ds" % (
|
log(
|
||||||
file,
|
f"file = { file } , "\
|
||||||
human_readable_size(file_size),
|
f"size={human_readable_size(file_size)}, "\
|
||||||
status,
|
f"status={status}, "\
|
||||||
(file_scan_end_time - file_scan_start_time)))
|
f"duration={int(file_scan_end_time - file_scan_start_time)}")
|
||||||
scanned += os.path.getsize(full_path)
|
scanned += os.path.getsize(full_path)
|
||||||
file_count += 1
|
file_count += 1
|
||||||
update_bar(scanned * 100 // used)
|
update_bar(scanned * 100 // used)
|
||||||
|
@ -416,7 +416,7 @@ def scan(mount_point, used):
|
||||||
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(f"Unexpected error: {e}")
|
||||||
log("Scan failed !")
|
log("Scan failed !")
|
||||||
if not CURSES:
|
if not CURSES:
|
||||||
display_image("ERROR")
|
display_image("ERROR")
|
||||||
|
@ -476,7 +476,7 @@ def mount():
|
||||||
# Mount device
|
# Mount device
|
||||||
mount_point = mount_device()
|
mount_point = mount_device()
|
||||||
log('Partition mounted at %s' % mount_point)
|
log('Partition mounted at %s' % mount_point)
|
||||||
if mount_point == None:
|
if mount_point is None:
|
||||||
# no partition
|
# no partition
|
||||||
if not CURSES:
|
if not CURSES:
|
||||||
display_image("WAIT")
|
display_image("WAIT")
|
||||||
|
@ -484,7 +484,7 @@ def mount():
|
||||||
try:
|
try:
|
||||||
os.statvfs(mount_point)
|
os.statvfs(mount_point)
|
||||||
except Exception as e :
|
except Exception as e :
|
||||||
log("error=%s" % e)
|
log(f"error={e}")
|
||||||
logging.info("An exception was thrown!", exc_info=True)
|
logging.info("An exception was thrown!", exc_info=True)
|
||||||
if not CURSES:
|
if not CURSES:
|
||||||
display_image("WAIT")
|
display_image("WAIT")
|
||||||
|
@ -498,7 +498,7 @@ def scan_device():
|
||||||
try:
|
try:
|
||||||
statvfs=os.statvfs(mount_point)
|
statvfs=os.statvfs(mount_point)
|
||||||
except Exception as e :
|
except Exception as e :
|
||||||
log("error=%s" % e)
|
log(f"error={e}")
|
||||||
logging.info("An exception was thrown!", exc_info=True)
|
logging.info("An exception was thrown!", exc_info=True)
|
||||||
if not CURSES:
|
if not CURSES:
|
||||||
display_image("WAIT")
|
display_image("WAIT")
|
||||||
|
@ -514,7 +514,7 @@ def clean():
|
||||||
global infected_files
|
global infected_files
|
||||||
# Clean files
|
# Clean files
|
||||||
if len(infected_files) > 0:
|
if len(infected_files) > 0:
|
||||||
log('%d infected files found !' % len(infected_files))
|
log(f"infeted_files={len(infected_files)}")
|
||||||
if not CURSES:
|
if not CURSES:
|
||||||
display_image("BAD")
|
display_image("BAD")
|
||||||
waitMouseClick()
|
waitMouseClick()
|
||||||
|
@ -525,9 +525,9 @@ def clean():
|
||||||
for file in infected_files:
|
for file in infected_files:
|
||||||
try :
|
try :
|
||||||
os.remove(file)
|
os.remove(file)
|
||||||
log('%s removed' % file)
|
log(f"{file} removed")
|
||||||
except Exception as e :
|
except Exception as e :
|
||||||
log("Unexpected error: %s" % str(e))
|
log(f"Unexpected error: {e}")
|
||||||
logging.info("An exception was thrown!", exc_info=True)
|
logging.info("An exception was thrown!", exc_info=True)
|
||||||
os.system("sync")
|
os.system("sync")
|
||||||
log("Clean done.")
|
log("Clean done.")
|
||||||
|
@ -579,7 +579,7 @@ def loop(state):
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
|
|
||||||
"""Main entry point"""
|
"""Main entry point"""
|
||||||
def main():
|
def main(unused):
|
||||||
try :
|
try :
|
||||||
state="START"
|
state="START"
|
||||||
while state!="STOP":
|
while state!="STOP":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue