Skip to content

Commit

Permalink
Merge branch 'p4env_vars' of git://github.com/krajaratnam/buildbot
Browse files Browse the repository at this point in the history
* 'p4env_vars' of git://github.com/krajaratnam/buildbot:
  P4Poller: pass through important environment variables (fixes buildbot#625)
  • Loading branch information
Dustin J. Mitchell committed Jan 27, 2010
2 parents 36aa204 + bc44cbe commit d7910cd
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions buildbot/changes/p4poller.py
Expand Up @@ -4,6 +4,7 @@

import re
import time
import os

from twisted.python import log, failure
from twisted.internet import defer, reactor
Expand All @@ -30,6 +31,9 @@ class P4Source(base.ChangeSource, util.ComparableMixin):
compare_attrs = ["p4port", "p4user", "p4passwd", "p4base",
"p4bin", "pollinterval"]

env_vars = ["P4CLIENT", "P4PORT", "P4PASSWD", "P4USER",
"P4CHARSET"]

changes_line_re = re.compile(
r"Change (?P<num>\d+) on \S+ by \S+@\S+ '.*'$")
describe_header_re = re.compile(
Expand Down Expand Up @@ -117,6 +121,11 @@ def _finished_failure(self, res):
log.msg('P4 poll failed: %s' % res)
return None

def _get_process_output(self, args):
env = dict([(e, os.environ.get(e)) for e in self.env_vars if os.environ.get(e)])
d = getProcessOutput(self.p4bin, args, env)
return d

def _get_changes(self):
args = []
if self.p4port:
Expand All @@ -130,8 +139,7 @@ def _get_changes(self):
args.extend(['%s...@%d,now' % (self.p4base, self.last_change+1)])
else:
args.extend(['-m', '1', '%s...' % (self.p4base,)])
env = {}
return getProcessOutput(self.p4bin, args, env)
return self._get_process_output(args)

def _process_changes(self, result):
last_change = self.last_change
Expand Down Expand Up @@ -165,9 +173,7 @@ def _get_describe(self, dummy, num):
if self.p4passwd:
args.extend(['-P', self.p4passwd])
args.extend(['describe', '-s', str(num)])
env = {}
d = getProcessOutput(self.p4bin, args, env)
return d
return self._get_process_output(args)

def _process_describe(self, result, num):
lines = result.split('\n')
Expand Down

0 comments on commit d7910cd

Please sign in to comment.