Skip to content

Commit

Permalink
command line script to set moa job status
Browse files Browse the repository at this point in the history
  • Loading branch information
mfiers committed Nov 8, 2012
1 parent 8876a9f commit 3dabf67
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions moa/cli/setstatus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env python

import os
import sys
import argparse
import subprocess as sp

parser = argparse.ArgumentParser(description='set moa status, needs to ' +
'be executed in a moa job directory')

parser.add_argument('status', help='status to set')
args = parser.parse_args()


def setstatus():

if not os.path.exists('.moa') and os.path.isdir('.moa'):
sys.stderr.write("must be executed in a moa job directory\n")
sys.exit(-1)

statusFile = os.path.join('.moa', 'status')
pidFile = os.path.join('.moa', 'pid')

status = args.status.lower()

if not status in 'waiting running success error interrupted'.split():
sys.stderr.write('invalid status: %s\n' % status)
sys.exit(-1)

if status != 'run':
if os.path.exists(pidFile):
os.unlink(pidFile)

with open(statusFile, 'w') as F:
F.write(status)


if __name__ == '__main__':
setstatus()

0 comments on commit 3dabf67

Please sign in to comment.