Added --cleanup arg
This commit is contained in:
parent
8039685e6b
commit
9cac021854
25
main.py
25
main.py
@ -23,18 +23,21 @@ if "--move-sent" in sys.argv:
|
|||||||
logWrite(f"Could not move sent file '{entry}' to '{configGet('sent', 'locations')}' due to {exp}")
|
logWrite(f"Could not move sent file '{entry}' to '{configGet('sent', 'locations')}' due to {exp}")
|
||||||
|
|
||||||
if "--cleanup" in sys.argv:
|
if "--cleanup" in sys.argv:
|
||||||
for entry in jsonLoad(configGet("index", "locations"))["sent"]:
|
if "--confirm" in sys.argv:
|
||||||
try:
|
for entry in jsonLoad(configGet("index", "locations"))["sent"]:
|
||||||
try:
|
try:
|
||||||
os.remove(configGet("queue", "locations")+os.sep+entry)
|
try:
|
||||||
except FileNotFoundError:
|
os.remove(configGet("queue", "locations")+os.sep+entry)
|
||||||
pass
|
except FileNotFoundError:
|
||||||
try:
|
pass
|
||||||
os.remove(configGet("sent", "locations")+os.sep+entry)
|
try:
|
||||||
except FileNotFoundError:
|
os.remove(configGet("sent", "locations")+os.sep+entry)
|
||||||
pass
|
except FileNotFoundError:
|
||||||
except Exception as exp:
|
pass
|
||||||
logWrite(f"Could not remove '{entry}' due to {exp}")
|
except Exception as exp:
|
||||||
|
logWrite(f"Could not remove '{entry}' due to {exp}")
|
||||||
|
else:
|
||||||
|
logWrite(f"Requested cleanup of sent files but not authorized. Please pass '--confirm' to perform that")
|
||||||
|
|
||||||
if "--norun" in sys.argv:
|
if "--norun" in sys.argv:
|
||||||
logWrite("Argument --norun passed, not running the main script")
|
logWrite("Argument --norun passed, not running the main script")
|
||||||
|
Reference in New Issue
Block a user