comparison commons/core/launcher/JobScriptTemplateLight.py @ 31:0ab839023fe4

Uploaded
author m-zytnicki
date Tue, 30 Apr 2013 14:33:21 -0400
parents
children
comparison
equal deleted inserted replaced
30:5677346472b5 31:0ab839023fe4
1 #!/usr/bin/env python
2
3 import os
4 import sys
5 import time
6 import shutil
7 from commons.core.checker.RepetException import RepetException
8 try:
9 newDir = None
10 print os.uname()
11 beginTime = time.time()
12 print 'beginTime=%f' % beginTime
13 print "work in dir '@@tmpDir@@'"
14 sys.stdout.flush()
15 if not os.path.exists( "@@tmpDir@@" ):
16 raise IOError("ERROR: temporary directory '@@tmpDir@@' doesn't exist")
17
18 minFreeGigaInTmpDir = 1
19 freeSpace = os.statvfs("@@tmpDir@@")
20 if ((freeSpace.f_bavail * freeSpace.f_frsize) / 1073741824.0 < minFreeGigaInTmpDir):
21 raise RepetException("ERROR: less than %iG of free space in '@@tmpDir@@'" % minFreeGigaInTmpDir)
22
23 os.chdir("@@tmpDir@@")
24 newDir = "@@groupId@@_@@jobName@@_@@time@@"
25 if os.path.exists(newDir):
26 shutil.rmtree(newDir)
27 os.mkdir(newDir)
28 os.chdir(newDir)
29
30 @@cmdStart@@
31 if log != 0:
32 raise RepetException("ERROR: job returned %i" % log)
33 else:
34 print "job finished successfully"
35 sys.stdout.flush()
36 @@cmdFinish@@
37
38 os.chdir("..")
39 shutil.rmtree(newDir)
40 endTime = time.time()
41 print 'endTime=%f' % endTime
42 print 'executionTime=%f' % (endTime - beginTime)
43 print os.uname()
44 sys.stdout.flush()
45
46 except IOError, e :
47 print e
48 sys.stdout.flush()
49 sys.exit(1)