-
Notifications
You must be signed in to change notification settings - Fork 0
/
closure.py
105 lines (83 loc) · 2.29 KB
/
closure.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env python
from os import chdir, getlogin
from logging import error
from shutil import copyfile
from subprocess import call
inst = ["iristestofalonglogin"]
full = ["iristest"]
all = full + inst
WORKDIR = "test/work/var/yp/src"
#SED = "/usr/sww/bin/sed"
SED = "/bin/sed"
#RCSDIFF = "/usr/local/bin/rcsdiff"
RCSDIFF = "/usr/bin/rcsdiff"
def sed(exp, target):
call([SED, "-i", exp, target])
return
def rcsdiff(target):
pass
def confirmchanges(target):
pass
def closeamdmapentry(user, target):
target = "amdmaps/amd.home.eecs"
copyfile(target, target + ".backup")
sed("/^" + user + "\b/d", target)
rcsdiff(target)
confirmchanges(target)
return
def closeautomapentry(user):
pass
def closeexportsentry(user):
pass
def closegroupentry(user):
pass
def closenetgroupentry(user):
pass
def checkout(files, user):
try:
for i in files:
program = ['co', '-l', i]
if call(program):
raise Exception(program)
except Exception as ex:
error('Exception in %s with file %s while closing account %s.' % (ex, i, user))
raise ex
def checkin(files, user):
try:
for i in files:
program = ['ci', '-u', '-m"Closing ' + user + '. (' + getlogin() +')"', i]
if call(program):
raise Exception(program)
except Exception as ex:
error('Exception in %s with file %s while closing account %s.' % (ex, i, user))
raise ex
files = ["automaps/auto.home.eecs", "amdmaps/amd.home.eecs",
"exports", "group", "netgroup"]
chdir(WORKDIR)
for i in all:
checkout(files, i)
closeautomapentry(i)
closeamdmapentry(i)
closeexportsentry(i)
closegroupentry(i)
closenetgroupentry(i)
checkin(files, i)
# for i in $all; do $i; $i; $i; done
# for i in $inst; do $i; $i; done
# for i in $inst; do co -l passwd.closed; ypmatch $i passwd >> passwd.closed; ci -u -m"closing $i ($USER)" passwd.closed; done
# for i in $inst; do sed -i "/^$i:/d" $PASSWD; done
# # iffy
# def foo():
# ret = fun()
# if ret:
# ret2 = bar(ret)
# if ret2:
# ret3 = baz(ret2)
# print ret
# # exceptional!
# def foo():
# try:
# baz(bar(fun))
# except:
# asdflkajs df
# print ret