source: PSPA/madxPSPA/testing/stayAlive.py @ 430

Last change on this file since 430 was 430, checked in by touze, 11 years ago

import madx-5.01.00

File size: 1.2 KB
Line 
1#!/usr/bin/python
2import threading
3import os
4import time
5
6class 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
34th = updateTokensThread()
35th.start()
36
37while True:
38    pass
39
40th.kill()
Note: See TracBrowser for help on using the repository browser.