ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbb/python/qstat.py
Revision: 1.3
Committed: Fri Apr 5 13:35:00 2013 UTC (12 years, 1 month ago) by peller
Content type: text/x-python
Branch: MAIN
CVS Tags: lhcp_UnblindFix, hcp_Unblind, lhcp_11April, LHCP_PreAppFixAfterFreeze, HEAD
Changes since 1.2: +6 -0 lines
Log Message:
gracefully exit

File Contents

# User Rev Content
1 peller 1.1 #!/usr/bin/env python
2     import os,sys
3     from time import sleep
4 peller 1.3 import signal
5     def signal_handler(signal, frame):
6     print 'ciao!'
7     sys.exit(0)
8     signal.signal(signal.SIGINT, signal_handler)
9    
10 peller 1.2 p = sys.argv
11     p[0] = 'qstat'
12     pj = ' '.join(p)
13 peller 1.1 class progbar:
14     def __init__(self,width):
15     self.width=width
16     sys.stdout.write("\033[1;47m%s\033[1;m" % (" " * width))
17     sys.stdout.flush()
18     sys.stdout.write("\b" * (width+1))
19     def move(self):
20     sys.stdout.write("\033[1;42m \033[1;m")
21     sys.stdout.flush()
22     def getnum():
23 peller 1.2 q=os.popen(pj)
24 peller 1.1 num=len(q.readlines())
25     if num > 2: return num-2
26     else: return 0
27     num = getnum()
28     print 'You have %s jobs in total'%num
29     progress = progbar(num)
30     while num > 0:
31     sleep(5)
32     num2 = getnum()
33     diff=num-num2
34     if diff > 0:
35     for i in range(0,diff): progress.move()
36     num=num2
37     print '\ndone! :)'