Is now using argparse library
This commit is contained in:
parent
58c5429e5c
commit
7a7f386891
26
poster.py
26
poster.py
@ -6,12 +6,26 @@ from threading import Thread
|
|||||||
from time import time
|
from time import time
|
||||||
from traceback import format_exc
|
from traceback import format_exc
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
from modules.logging import logWrite
|
from modules.logging import logWrite
|
||||||
from modules.utils import configGet, jsonLoad, jsonSave, killProc, locale
|
from modules.utils import configGet, jsonLoad, jsonSave, killProc, locale
|
||||||
|
|
||||||
# Args =====================================================================================================================================
|
# Args =====================================================================================================================================
|
||||||
if "--move-sent" in argv:
|
parser = ArgumentParser(
|
||||||
|
prog = "Telegram Poster",
|
||||||
|
description = "Bot for posting some of your stuff and also receiving submissions."
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument("-m", "--move-sent", action="store_true")
|
||||||
|
parser.add_argument("-c", "--cleanup", action="store_true")
|
||||||
|
parser.add_argument("--confirm", action="store_true")
|
||||||
|
parser.add_argument("-i", "--cleanup-index", action="store_true")
|
||||||
|
parser.add_argument("-n", "--norun", action="store_true")
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.move_sent:
|
||||||
for entry in jsonLoad(configGet("index", "locations"))["sent"]:
|
for entry in jsonLoad(configGet("index", "locations"))["sent"]:
|
||||||
try:
|
try:
|
||||||
move(configGet("queue", "locations")+sep+entry, configGet("sent", "locations")+sep+entry)
|
move(configGet("queue", "locations")+sep+entry, configGet("sent", "locations")+sep+entry)
|
||||||
@ -21,8 +35,8 @@ if "--move-sent" in argv:
|
|||||||
logWrite(locale("move_sent_doesnt_exception", "console", locale=configGet("locale")).format(entry, exp))
|
logWrite(locale("move_sent_doesnt_exception", "console", locale=configGet("locale")).format(entry, exp))
|
||||||
logWrite(locale("move_sent_completed", "console", locale=configGet("locale")))
|
logWrite(locale("move_sent_completed", "console", locale=configGet("locale")))
|
||||||
|
|
||||||
if "--cleanup" in argv:
|
if args.cleanup:
|
||||||
if "--confirm" in argv:
|
if args.confirm:
|
||||||
index = jsonLoad(configGet("index", "locations"))
|
index = jsonLoad(configGet("index", "locations"))
|
||||||
for entry in index["sent"]:
|
for entry in index["sent"]:
|
||||||
try:
|
try:
|
||||||
@ -41,8 +55,8 @@ if "--cleanup" in argv:
|
|||||||
else:
|
else:
|
||||||
logWrite(locale("cleanup_unathorized", "console", locale=configGet("locale")))
|
logWrite(locale("cleanup_unathorized", "console", locale=configGet("locale")))
|
||||||
|
|
||||||
if "--cleanup-index" in argv:
|
if args.cleanup_index:
|
||||||
if "--confirm" in argv:
|
if args.confirm:
|
||||||
index = jsonLoad(configGet("index", "locations"))
|
index = jsonLoad(configGet("index", "locations"))
|
||||||
index["sent"] = []
|
index["sent"] = []
|
||||||
jsonSave(index, jsonLoad(configGet("index", "locations")))
|
jsonSave(index, jsonLoad(configGet("index", "locations")))
|
||||||
@ -50,7 +64,7 @@ if "--cleanup-index" in argv:
|
|||||||
else:
|
else:
|
||||||
logWrite(locale("cleanup_index_unathorized", "console", locale=configGet("locale")))
|
logWrite(locale("cleanup_index_unathorized", "console", locale=configGet("locale")))
|
||||||
|
|
||||||
if "--norun" in argv:
|
if args.norun:
|
||||||
logWrite(locale("passed_norun", "console", locale=configGet("locale")))
|
logWrite(locale("passed_norun", "console", locale=configGet("locale")))
|
||||||
exit()
|
exit()
|
||||||
#===========================================================================================================================================
|
#===========================================================================================================================================
|
||||||
|
Reference in New Issue
Block a user