parse --limit
This commit is contained in:
parent
72df2665d5
commit
33a3f20f89
1 changed files with 13 additions and 2 deletions
15
main.py
15
main.py
|
@ -262,10 +262,21 @@ class Switch:
|
|||
|
||||
post_reboot = requests.post(url_reboot, data=json.dumps(data), headers=self.headers)
|
||||
|
||||
limit = False
|
||||
if "--limit" in sys.argv:
|
||||
list_index = sys.argv.index("--limit") + 1
|
||||
if len(sys.argv) >= list_index:
|
||||
limit = True
|
||||
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")
|
||||
limit_switchs = set(
|
||||
filter(
|
||||
bool,
|
||||
map(
|
||||
lambda x: x.strip(),
|
||||
sys.argv[limit_list_index].split(',')
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
#if "--force" in sys.argv:
|
||||
# sw = Switch()
|
||||
|
|
Loading…
Reference in a new issue