Page MenuHomeVyOS Platform

validate-value.py
No OneTemporary

Size
800 B
Referenced Files
None
Subscribers
None

validate-value.py

#!/usr/bin/env python3
import re
import os
import sys
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--regex', action='append')
parser.add_argument('--exec', action='append')
parser.add_argument('--value', action='store')
args = parser.parse_args()
debug = False
# Multiple arguments work like logical OR
try:
for r in args.regex:
if re.fullmatch(r, args.value):
sys.exit(0)
except Exception as exn:
if debug:
print(exn)
else:
pass
try:
for cmd in args.exec:
cmd = "{0} {1}".format(cmd, args.value)
if debug:
print(cmd)
res = os.system(cmd)
if res == 0:
sys.exit(0)
except Exception as exn:
if debug:
print(exn)
else:
pass
sys.exit(1)

File Metadata

Mime Type
text/x-script.python
Expires
Tue, Dec 9, 10:51 PM (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3093756
Default Alt Text
validate-value.py (800 B)

Event Timeline