[Svnmerge] svnmerge.py breaks in cron
Alan Barrett
apb at cequrux.com
Wed Oct 24 10:59:02 PDT 2007
On Wed, 24 Oct 2007, Dustin J. Mitchell wrote:
> + # Parse the output of stty -a, if we have a terminal
> + if os.environ.get('TERM', ''):
> + out = os.popen("stty -a").read()
> + m = re.search(r"columns (\d+);", out)
> + if m:
> + return int(m.group(1))
1. This needs to be in a try/except block, in case popen fails or stty
exits with an error, or something.
2. It's possible for TERM to be defined even if there's no terminal
available. I'd suggest using os.isatty(), or simply relying on
try/except to catch any error (and not bothering with any sort of
pre-test).
3. You should probably set LC_ALL="C". (Or is that already done at a
higher level?)
4. Even if stty works, there's no guarantee that it the output will
include the number of columns. I see that you are already handling
that case.
--apb (Alan Barrett)
More information about the Svnmerge
mailing list