1 |
#!/usr/bin/env python
|
2 |
import os,sys
|
3 |
from time import sleep
|
4 |
class progbar:
|
5 |
def __init__(self,width):
|
6 |
self.width=width
|
7 |
sys.stdout.write("\033[1;47m%s\033[1;m" % (" " * width))
|
8 |
sys.stdout.flush()
|
9 |
sys.stdout.write("\b" * (width+1))
|
10 |
def move(self):
|
11 |
sys.stdout.write("\033[1;42m \033[1;m")
|
12 |
sys.stdout.flush()
|
13 |
def getnum():
|
14 |
q=os.popen('qstat')
|
15 |
num=len(q.readlines())
|
16 |
if num > 2: return num-2
|
17 |
else: return 0
|
18 |
num = getnum()
|
19 |
print 'You have %s jobs in total'%num
|
20 |
progress = progbar(num)
|
21 |
while num > 0:
|
22 |
sleep(5)
|
23 |
num2 = getnum()
|
24 |
diff=num-num2
|
25 |
if diff > 0:
|
26 |
for i in range(0,diff): progress.move()
|
27 |
num=num2
|
28 |
print '\ndone! :)'
|