This repository has been archived by the owner on Oct 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
argument.py
50 lines (37 loc) · 1.63 KB
/
argument.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from sys import exit
from json import dump
from getpass import getpass
from base64 import b64encode
from argparse import Action, ArgumentParser, RawDescriptionHelpFormatter
from environment import download_chrome_driver, set_user_file, del_user_file
class DownloadChromeDriver(Action):
def __call__(self, parser, namespace, values, option_string):
download_chrome_driver(overwrite=True)
exit("The Chrome Driver has downloaded.")
class ResetUserFile(Action):
def __call__(self, parser, namespace, values, option_string):
set_user_file()
exit("The user file has been reset.")
class ClearUserFile(Action):
def __call__(self, parser, namespace, values, option_string):
del_user_file()
exit("The user file has been deleted.")
parser = ArgumentParser(
prog="cdx-extender",
formatter_class=RawDescriptionHelpFormatter,
description="The Solution to Extend the Deadline for the Virtual Machines on CDX",
epilog="It's better to work with cron(crontab) on Linux.")
parser.add_argument(
"-H", "--headless", dest="headless",
action="store_true", help="set headless browser")
group = parser.add_mutually_exclusive_group()
group.add_argument(
"-D", "--download-chromedriver", dest="download_chromedriver", nargs=0,
action=DownloadChromeDriver, help=" download and overwrite(if any) the ChromeDriver and exit")
group.add_argument(
"--reset", dest="reset", nargs=0,
action=ResetUserFile, help="reset the user data and exit")
group.add_argument(
"--clear", dest="clear", nargs=0,
action=ClearUserFile, help="clear the user data and exit")
args = parser.parse_args()