1 # Copyright (c) 2005 Fredrik Kuivinen <freku045@student.liu.se>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License version 2 as
5 # published by the Free Software Foundation.
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
12 # You should have received a copy of the GNU General Public License
13 # along with this program; if not, write to the Free Software
14 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 applicationName
= 'Commit Tool'
24 # PyQt3 and python 2.4 isn't currently available together on
25 # Debian/testing we do therefore use the following quite ugly work
26 # around. The module 'mysubprocess' is just a copy of the 'subprocess'
27 # module from the Python 2.4 distribution.
28 ver
= sys
.version_info
29 if ver
[0] < 2 or (ver
[0] == 2 and ver
[1] <= 3):
31 subprocess
= mysubprocess
38 class ProgramError(Exception):
39 def __init__(self
, program
, err
):
40 Exception.__init
__(self
)
41 self
.program
= program
44 def runProgram(prog
, input=None):
45 debug('runProgram prog: ' + str(prog
) + " input: " + str(input))
49 progStr
= ' '.join(prog
)
52 pop
= subprocess
.Popen(prog
,
53 shell
= type(prog
) is str,
54 stderr
=subprocess
.STDOUT
,
55 stdout
=subprocess
.PIPE
,
56 stdin
=subprocess
.PIPE
)
58 debug("strerror: " + e
.strerror
)
59 raise ProgramError(progStr
, e
.strerror
)
62 pop
.stdin
.write(input)
65 out
= pop
.stdout
.read()
68 debug("error output: " + out
)
69 raise ProgramError(progStr
, out
)
70 debug("output: " + out
.replace('\0', '\n'))