Permalink
Browse files

Tested and functioning on test server with Python 2.6

  • Loading branch information...
1 parent c6d6442 commit 7117531c052b21a35fa24f0f70319a1e243b6294 @sean-m committed Feb 8, 2013
Showing with 24 additions and 26 deletions.
  1. +24 −26 jira-init
View
@@ -19,35 +19,33 @@
import sys, os, subprocess, re, time
+
+'''
+Monkey-patch for subprocess.check_output from Python 2.7
+'''
+if "check_output" not in dir( subprocess ): # duck punch it in!
+ def f(*popenargs, **kwargs):
+ if 'stdout' in kwargs:
+ raise ValueError('stdout argument not allowed, it will be overridden.')
+ process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
+ output, unused_err = process.communicate()
+ retcode = process.poll()
+ if retcode:
+ cmd = kwargs.get("args")
+ if cmd is None:
+ cmd = popenargs[0]
+ raise subprocess.CalledProcessError(retcode, cmd)
+ return output
+ subprocess.check_output = f
+
+
'''
Adjust the following values to fit your application
'''
APP_NAME = 'JIRA'
APP_DIR = '/data/jira_main/jira-std/'
-APP_START = 'bin/start-jira.sh'
-APP_STOP = 'bin/stop-jira.sh'
-
-
-def check_output(*popenargs, **kwargs):
- """Run command with arguments and return its output as a byte string.
-
- Backported from Python 2.7 as it's implemented as pure python on stdlib.
-
- >>> check_output(['/usr/bin/python', '--version'])
- Python 2.6.2
- """
- process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
- output, unused_err = process.communicate()
- retcode = process.poll()
- if retcode:
- cmd = kwargs.get("args")
- if cmd is None:
- cmd = popenargs[0]
- error = subprocess.CalledProcessError(retcode, cmd)
- error.output = output
- raise error
- return output
-
+APP_START = 'bin/startup.sh'
+APP_STOP = 'bin/shutdown.sh'
def lock():
"""
@@ -91,7 +89,7 @@ def start():
lock()
except subprocess.CalledProcessError, e:
print('There was an error starting ' + APP_NAME)
- print(e.output)
+# print(e.output)
return e.returncode
status()
@@ -111,7 +109,7 @@ def stop():
unlock()
except subprocess.CalledProcessError, e:
print('There was an error stopping ' + APP_NAME)
- print(e.output)
+ # print(e.output)
return e.returncode
status()

0 comments on commit 7117531

Please sign in to comment.