def __init__( self, goanna_host, goanna_port, project, branch=None, goanna_hosted_path=None, paths=[], category=None, pollInterval=60 * 10, pollinterval=-2, proxy_host=None, proxy_port=None, proxy_username=None, proxy_password=None, ): # for backward compatibility; official buildbot ChangSource pollers # used to provide "pollinterval" in older versions but newer versions # now prefer "pollInterval". We allow for both. if pollinterval != -2: pollInterval = pollinterval # Goanna Timestamp of the last revision acted upon. This is used # during each poll to retrieve revisions newer than the timestamp. # - On startup, this value is set based on the last known state # (see self.startService() # - If not previous states are found, we query Goanna for the # latest revision and use that as the initial state # - This value is updated (and the state stored) each time changes # are found. self.lastRevTimestamp = None self.project = project self.branch = branch self.category = category self.web_client = ProxyWebClient(proxy_host, proxy_port, proxy_username, proxy_password, timeout=pollInterval) if not goanna_hosted_path: goanna_hosted_path = "" self.query_url = "http://%s:%s%s/query/%s" % (goanna_host, goanna_port, goanna_hosted_path, project) if branch: self.query_url += "/%s" % branch if isinstance(paths, basestring): paths = [paths] self.paths = sorted(set(normalise_path(p) for p in paths)) if any("|" in p for p in paths): config.error("GoannaPoller: invalid value given as path") # older versions of PollingChangeSource does not have __init__() if hasattr(base.PollingChangeSource, "__init__"): base.PollingChangeSource.__init__(self, name=self.query_url, pollInterval=pollInterval)
def _is_relevant_change(self, change): if not self.paths: # if unfiltered, all changes are relevant return True changed_files = change["files"] assert isinstance(changed_files, list) files = (normalise_path(f) for f in sorted(changed_files)) paths = (p for p in self.paths) # already sorted and normalised try: f = next(files) p = next(paths) while True: if is_subdir(f, p): return True if p > f: f = next(files) else: p = next(paths) except StopIteration: return False