-
Notifications
You must be signed in to change notification settings - Fork 2
/
reproc.py
executable file
·61 lines (41 loc) · 939 Bytes
/
reproc.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
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
"""Code to re-create /proc data files from parsed records"""
# pylint: disable=W0614,W0401
import ProcHandlers as PH
import sys
from regentest import *
import regentest as RG
# ---
PFC = PH.ProcFieldConstants
# ---
if __name__ == "__main__":
NOFUNC = 0
if len(sys.argv) > 1:
TARGET = sys.argv[1]
else:
TARGET = "/proc/net/tcp6"
if len(sys.argv) > 2:
CNAME = sys.argv[2]
else:
CNAME = TARGET
HANDLER = PH.GET_HANDLER(CNAME)
try:
RECREATE = RG.RECREATOR[HANDLER]
except KeyError:
RECREATE = NOFUNC
if type(NOFUNC) == type(RECREATE):
print "There's no recreator code available for file '{inp}' yet".\
format(inp=TARGET)
else:
ACTIVE = HANDLER(TARGET)
RECREATE(ACTIVE)
# ---
# pylint: disable=W0702
try:
sys.stdout.close()
except:
pass
try:
sys.stderr.close()
except:
pass