blob: 2625663a20998199074b4ef07c1f17add34238e2 (
plain)
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
|
#!/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')
args = parser.parse_args()
debug = False
# Multiple arguments work like logical OR
try:
for r in args.regex:
if re.match(r, args.value):
sys.exit(0)
except Exception as exn:
if debug:
print(exn)
else:
pass
try:
for cmd in args.exec:
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)
|