Line | |
---|
1 | #!/usr/bin/python |
---|
2 | import threading |
---|
3 | import os |
---|
4 | import time |
---|
5 | |
---|
6 | class updateTokensThread(threading.Thread): |
---|
7 | def __init__(self): |
---|
8 | threading.Thread.__init__(self) |
---|
9 | def run(self): |
---|
10 | while True: |
---|
11 | try: |
---|
12 | os.system('/usr/sue/bin/kinit -k -t /extra/home/nougaret/MadTestScriptAuth'+ |
---|
13 | '/mykeytab nougaret') |
---|
14 | os.system('/usr/bin/aklog') |
---|
15 | outfile = "stayAlive.out" |
---|
16 | os.system('/usr/kerberos/bin/klist > ' + outfile) |
---|
17 | f = open(outfile,'r') |
---|
18 | lines = f.readlines() |
---|
19 | msg2 = '' |
---|
20 | for line in lines: |
---|
21 | msg2 = msg2 + line + '\n' |
---|
22 | f.close() |
---|
23 | os.system('rm '+outfile) |
---|
24 | print('klist contents:' + msg2) |
---|
25 | except: |
---|
26 | print('failed to refresh tokens!') |
---|
27 | for sec in range(1,30): # sleep 30 seconds |
---|
28 | time.sleep(1) # 1 sec |
---|
29 | if self.kill == True: |
---|
30 | return |
---|
31 | def kill(self): |
---|
32 | self.kill = True # work-around: not yet able to kill Python threads |
---|
33 | |
---|
34 | th = updateTokensThread() |
---|
35 | th.start() |
---|
36 | |
---|
37 | while True: |
---|
38 | pass |
---|
39 | |
---|
40 | th.kill() |
---|
Note: See
TracBrowser
for help on using the repository browser.