-
Notifications
You must be signed in to change notification settings - Fork 0
/
job_mgmt.py
executable file
·47 lines (38 loc) · 1.08 KB
/
job_mgmt.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
#!/usr/bin/env python
#
# This script implements a class which manages all the jobs in LiteLab.
#
# Liang Wang @ Dept. Computer Science, University of Helsinki, Finland
# 2012.04.17 created
#
import os
import re
import sys
import time
import pickle
import threading
from multiprocessing import *
from dynamic_common import *
class JobMgmt(object):
def __init__(self):
self.jobs = {}
self.logfn = '%s/log_job.txt' % os.path.dirname(os.path.realpath(__file__))
pass
def add_job(self, jobid, config_fn, nodes):
self.jobs[jobid] = {'timestamp':time.ctime(), 'config':config_fn, 'nodes':nodes}
pass
def delete_job(self, jobid):
if self.jobs.has_key(jobid):
self.jobs.pop(jobid)
pass
def update_stat(self):
logh = open(self.logfn, 'wb+')
for jobid, v in self.jobs.items():
logh.write('%s\t%i\t%s\t%s\n' %
(v['timestamp'], jobid, v['config'], str(sorted(v['nodes']))))
pass
logh.close()
pass
pass
if __name__=="__main__":
sys.exit()