summaryrefslogtreecommitdiffstats
path: root/GitAutoDeploy.py
diff options
context:
space:
mode:
authorAlexander Nestorov <alexandernst@gmail.com>2014-10-15 14:59:51 +0200
committerAlexander Nestorov <alexandernst@gmail.com>2014-10-15 14:59:51 +0200
commit573fedc48fb12b68a0da8cc2927f7830901e9a24 (patch)
treed12cfe3b7d87ce2d9131281fe57a1ca635d04e59 /GitAutoDeploy.py
parentfb674b80617aaab7771fb42c7595b6926c20bfb5 (diff)
downloadGit-Auto-Deploy-573fedc48fb12b68a0da8cc2927f7830901e9a24.zip
Git-Auto-Deploy-573fedc48fb12b68a0da8cc2927f7830901e9a24.tar.gz
Git-Auto-Deploy-573fedc48fb12b68a0da8cc2927f7830901e9a24.tar.bz2
Play nicer with some shells and exit code/status
Diffstat (limited to 'GitAutoDeploy.py')
-rwxr-xr-xGitAutoDeploy.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/GitAutoDeploy.py b/GitAutoDeploy.py
index 4ad013d..0b4aff8 100755
--- a/GitAutoDeploy.py
+++ b/GitAutoDeploy.py
@@ -19,23 +19,28 @@ class GitAutoDeploy(BaseHTTPRequestHandler):
try:
configString = open(myClass.CONFIG_FILEPATH).read()
except:
- sys.exit('Could not load ' + myClass.CONFIG_FILEPATH + ' file')
+ print "Could not load %s file" % myClass.CONFIG_FILEPATH
+ sys.exit(2)
try:
myClass.config = json.loads(configString)
except:
- sys.exit(myClass.CONFIG_FILEPATH + ' file is not valid json')
+ print "%s file is not valid JSON" % myClass.CONFIG_FILEPATH
+ sys.exit(2)
for repository in myClass.config['repositories']:
if(not os.path.isdir(repository['path'])):
- sys.exit('Directory ' + repository['path'] + ' not found')
+ print "Directory %s not found" % repository['path']
+ sys.exit(2)
if(not os.path.isdir(repository['path'] + '/.git')):
- sys.exit('Directory ' + repository['path'] + ' is not a Git repository')
+ print "Directory %s is not a Git repository" % repository['path']
+ sys.exit(2)
return myClass.config
def do_POST(self):
urls = self.parseRequest()
+ self.respond()
Timer(1.0, self.do_process, [urls]).start()
def do_process(self, urls):
@@ -44,7 +49,6 @@ class GitAutoDeploy(BaseHTTPRequestHandler):
for path in paths:
self.pull(path)
self.deploy(path)
- self.respond()
def parseRequest(self):
length = int(self.headers.getheader('content-length'))
@@ -125,7 +129,7 @@ class GitAutoDeployMain:
if(GitAutoDeploy.daemon):
pid = os.fork()
if(pid != 0):
- sys.exit()
+ sys.exit(1)
os.setsid()
self.create_pidfile()
@@ -235,7 +239,7 @@ class GitAutoDeployMain:
elif(signum == 6):
print 'Requested close by SIGABRT (process abort signal). Code 6.'
- self.exit()
+ self.exit(1)
if __name__ == '__main__':
gadm = GitAutoDeployMain()