"""Constructor."""
self.ignore_projects = []
+ self.r10k_bin = None
self.description = textwrap.dedent('''\
Receives push events as JSON-Data and synchronizes
the local repository and deploys it with r10k.
super(R10kHookApp, self).__init__(
appname=appname, verbose=verbose, version=version)
+ self.search_r10k_bin()
+
# -------------------------------------------------------------------------
def as_dict(self):
"""
return res
+ # -------------------------------------------------------------------------
+ def search_r10k_bin(self):
+
+ path_list = []
+ cmd = 'r10k'
+
+ search_path = os.environ.get('PATH', None)
+ if not search_path:
+ search_path = os.defpath
+
+ search_path_list = [
+ '/opt/pixelpark/bin',
+ '/www/bin',
+ ]
+
+ search_path_list += search_path.split(os.pathsep)
+
+ default_path = [
+ '/usr/local/sbin',
+ '/usr/local/bin',
+ '/usr/sbin',
+ '/usr/bin',
+ '/sbin',
+ '/bin',
+ ]
+ search_path_list += default_path
+
+ for d in search_path_list:
+ if not os.path.exists(d):
+ continue
+ if not os.path.isdir(d):
+ continue
+ d_abs = os.path.realpath(d)
+ if d_abs not in path_list:
+ path_list.append(d_abs)
+
+ if self.verbose > 1:
+ LOG.debug("Searching for command {c!r} in:\n{p}".format(
+ c=cmd, p=pp(path_list)))
+
+ for d in path_list:
+ p = os.path.join(d, cmd)
+ if os.path.exists(p):
+ if self.verbose > 2:
+ LOG.debug("Found {!r} ...".format(p))
+ if os.access(p, os.X_OK):
+ self.r10k_bin = p
+ break
+ else:
+ LOG.debug("Command {!r} is not executable.".format(p))
+
+ if self.r10k_bin:
+ LOG.debug("Found {c!r} in {p!r}.".format(c=cmd, p=self.r10k_bin))
+ else:
+ LOG.error("Command {!r} not found.".format(cmd))
+ sys.exit(9)
+
# -------------------------------------------------------------------------
def evaluate_config(self, config, yaml_file):