annotate commons/core/launcher/JobScriptTemplateLight.py @ 16:6135c3075bc5

Deleted selected files
author m-zytnicki
date Mon, 22 Apr 2013 11:09:41 -0400
parents 769e306b7933
children 94ab73e8a190
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1 #!/usr/bin/env python
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
2
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
3 import os
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
4 import sys
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
5 import time
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
6 import shutil
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
7 from commons.core.checker.RepetException import RepetException
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
8 try:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
9 newDir = None
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
10 print os.uname()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
11 beginTime = time.time()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
12 print 'beginTime=%f' % beginTime
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
13 print "work in dir '@@tmpDir@@'"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
14 sys.stdout.flush()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
15 if not os.path.exists( "@@tmpDir@@" ):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
16 raise IOError("ERROR: temporary directory '@@tmpDir@@' doesn't exist")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
17
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
18 minFreeGigaInTmpDir = 1
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
19 freeSpace = os.statvfs("@@tmpDir@@")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
20 if ((freeSpace.f_bavail * freeSpace.f_frsize) / 1073741824.0 < minFreeGigaInTmpDir):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
21 raise RepetException("ERROR: less than %iG of input file in '@@tmpDir@@'" % minFreeGigaInTmpDir)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
22
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
23 os.chdir("@@tmpDir@@")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
24 newDir = "@@groupId@@_@@jobName@@_@@time@@"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
25 if os.path.exists(newDir):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
26 shutil.rmtree(newDir)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
27 os.mkdir(newDir)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
28 os.chdir(newDir)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
29
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
30 @@cmdStart@@
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
31 if log != 0:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
32 raise RepetException("ERROR: job returned %i" % log)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
33 else:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
34 print "job finished successfully"
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
35 sys.stdout.flush()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
36 @@cmdFinish@@
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
37
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
38 os.chdir("..")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
39 shutil.rmtree(newDir)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
40 endTime = time.time()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
41 print 'endTime=%f' % endTime
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
42 print 'executionTime=%f' % (endTime - beginTime)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
43 print os.uname()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
44 sys.stdout.flush()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
45
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
46 except IOError, e :
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
47 print e
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
48 sys.stdout.flush()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
49 sys.exit(1)