From e518bc9b6804e07045a94ee736773140d2ea336f Mon Sep 17 00:00:00 2001 From: Sindre Myren Date: Fri, 25 Mar 2011 11:08:18 +0100 Subject: [PATCH] Updated gitserve.py to work with python 3.x --- scripts/gitserve.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/gitserve.py b/scripts/gitserve.py index 78a5b57..a955a99 100644 --- a/scripts/gitserve.py +++ b/scripts/gitserve.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# +# # ***** BEGIN LICENSE BLOCK ***** # This file is part of InDefero, an open source project management application. # Copyright (C) 2008 CĂ©ondo Ltd and contributors. @@ -23,14 +23,17 @@ import os import sys -import commands -import traceback +import subprocess + +SCRIPTDIR = os.path.abspath(__file__).rsplit(os.path.sep, 1)[0] +GITSERVEPHP = '%s/gitserve.php' % SCRIPTDIR +process = subprocess.Popen(['php', GITSERVEPHP, sys.argv[1]], + stdout=subprocess.PIPE, stderr=subprocess.PIPE) +output = str.encode("\n").join(process.communicate()).strip() +status = process.wait() -n = len("/gitserve.py") -GITSERVEPHP = '%s/gitserve.php' % traceback.extract_stack(limit=1)[0][0][0:-n] -status, output = commands.getstatusoutput('php %s %s' % (GITSERVEPHP, sys.argv[1])) if status == 0: os.execvp('git', ['git', 'shell', '-c', output.strip()]) else: - sys.stderr.write("%s\n" % output) + sys.stderr.write("%s\n" % output.strip()) sys.exit(1)