Mercurial > repos > yufei-luo > s_mart
comparison commons/core/launcher/JobScriptTemplateLight.py @ 6:769e306b7933
Change the repository level.
author | yufei-luo |
---|---|
date | Fri, 18 Jan 2013 04:54:14 -0500 |
parents | |
children | 94ab73e8a190 |
comparison
equal
deleted
inserted
replaced
5:ea3082881bf8 | 6:769e306b7933 |
---|---|
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 input file 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) |