parse --limit

This commit is contained in:
histausse 2021-09-25 12:05:50 +02:00
parent 72df2665d5
commit 33a3f20f89

15
main.py
View file

@ -262,10 +262,21 @@ class Switch:
post_reboot = requests.post(url_reboot, data=json.dumps(data), headers=self.headers) post_reboot = requests.post(url_reboot, data=json.dumps(data), headers=self.headers)
limit = False
if "--limit" in sys.argv: if "--limit" in sys.argv:
list_index = sys.argv.index("--limit") + 1 limit = True
if len(sys.argv) >= list_index: limit_list_index = sys.argv.index("--limit") + 1
if len(sys.argv) <= limit_list_index:
raise RuntimeError("--limit must be followeb by a comma separated list of switch") raise RuntimeError("--limit must be followeb by a comma separated list of switch")
limit_switchs = set(
filter(
bool,
map(
lambda x: x.strip(),
sys.argv[limit_list_index].split(',')
)
)
)
#if "--force" in sys.argv: #if "--force" in sys.argv:
# sw = Switch() # sw = Switch()