]> Frank Brehm's Git Trees - pixelpark/puppetmaster-webhooks.git/commitdiff
Merge branch 'master' into develop
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 27 Mar 2019 10:11:02 +0000 (11:11 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 27 Mar 2019 10:11:02 +0000 (11:11 +0100)
Conflicts:
lib/webhooks/__init__.py
lib/webhooks/deploy.py

1  2 
lib/webhooks/deploy.py

index b1a55e9a925617e70bfcc4c62a5bd48bc36fd8e5,b6d066dccbfae1a5846ba59a21301c06143b7f11..a9f5188d5cfb5bbd0d6cd69a2d3cf285798e8634
@@@ -235,77 -236,72 +236,128 @@@ class WebhookDeployApp(BaseHookApp)
                  cmd = ['git', 'clone', self.git_ssh_url, workdir]
                  if branch:
                      cmd += ['-b', branch]
+                 has_cloned = True
  
 -            (ret_val, stdoutdata, stderrdata) = self.handler.call(cmd, sudo=self.do_sudo)
 +            proc = self.handler.call(cmd, sudo=self.do_sudo, quiet=True)
  
 -            if stdoutdata:
 -                msg = "Output:\n{}".format(to_str(stdoutdata))
 +            if proc.stdout:
 +                msg = _("Output:") + "\n{}".format(proc.stdout)
                  self.print_out(msg)
              else:
                  LOG.debug("No output.")
  
 -            if stderrdata:
 -                cmd_str = ' '.join(map(lambda x: pipes.quote(x), cmd))
 -                msg = "Error messages on '{c}':\n{e}".format(c=cmd_str, e=to_str(stderrdata))
 -                if ret_val:
 -                    self.error_data.append(msg)
 +            if proc.stderr:
 +                cmd_str = ' '.join(map(lambda x: pipes.quote(x), proc.args))
 +                msg = _("Error messages on {c!r}:\n{e}").format(c=cmd_str, e=proc.stderr)
 +                msg_rc = _("Returncode was {}.").format(proc.returncode)
                  self.print_out(msg)
 +                if proc.returncode:
 +                    self.print_out(msg_rc)
 +                    self.error_data.append(msg)
 +                    self.error_data.append(msg_rc)
  
+             if has_cloned:
+                 os.chdir(workdir)
+             # Handling Submodules ...
+             if os.path.isfile('.gitmodules'):
+                 self.handle_submodules()
          finally:
              os.chdir(cur_dir)
  
 -        LOG.info("Initializing GIT submodules in working directory {!r}.".format(os.getcwd()))
 +    # -------------------------------------------------------------------------
 +    def compile_i18n_msgs(self, workdir):
 +
 +        cur_dir = os.getcwd()
 +
 +        try:
 +            os.chdir(workdir)
 +
 +            xlate_script = pathlib.Path('compile-xlate-msgs.sh')
 +            if not xlate_script.exists():
 +                if self.verbose > 2:
 +                    LOG.debug("Script {!r} does not exists.".format(str(xlate_script)))
 +                return
 +            if not xlate_script.is_file():
 +                LOG.warn(_("Script {!r} exists, but is not a regular file.").format(
 +                    str(xlate_script)))
 +                return
 +            if not os.access(str(xlate_script), os.X_OK):
 +                LOG.warn(_("Script {!r} exists, but is not executable..").format(
 +                    str(xlate_script)))
 +                return
 +
 +            script_abs = str(xlate_script.resolve())
 +            LOG.info(_("Compiling language catalogues by calling {!r} ...").format(
 +                str(xlate_script)))
 +            cmd = [script_abs]
 +            proc = self.handler.call(cmd, sudo=self.do_sudo, quiet=True)
 +
 +            if proc.stdout:
 +                msg = _("Output:") + "\n{}".format(proc.stdout)
 +                self.print_out(msg)
 +            else:
 +                LOG.debug("No output.")
 +
 +            if proc.stderr:
 +                cmd_str = ' '.join(map(lambda x: pipes.quote(x), proc.args))
 +                msg = _("Error messages on {c!r}:\n{e}").format(c=cmd_str, e=proc.stderr)
 +                msg_rc = _("Returncode was {}.").format(proc.returncode)
 +                self.print_out(msg)
 +                if proc.returncode:
 +                    self.print_out(msg_rc)
 +                    self.error_data.append(msg)
 +                    self.error_data.append(msg_rc)
 +
 +        finally:
 +            os.chdir(cur_dir)
 +
+     # -------------------------------------------------------------------------
+     def handle_submodules(self):
+         # Initialize the submodules recorded in the index
 -        (ret_val, stdoutdata, stderrdata) = self.handler.call(cmd, sudo=self.do_sudo)
 -        if stdoutdata:
 -            msg = "Output:\n{}".format(to_str(stdoutdata))
++        LOG.info(_("Initializing GIT submodules in working directory {!r}.").format(os.getcwd()))
+         cmd = ['git', 'submodule', 'init']
 -        if stderrdata:
 -            cmd_str = ' '.join(map(lambda x: pipes.quote(x), cmd))
 -            msg = "Error messages on '{c}':\n{e}".format(c=cmd_str, e=to_str(stderrdata))
 -            if ret_val:
 -                self.error_data.append(msg)
++        proc = self.handler.call(cmd, sudo=self.do_sudo, quiet=True)
++        if proc.stdout:
++            msg = _("Output:") + "\n{}".format(proc.stdout)
+             self.print_out(msg)
+         else:
+             LOG.debug("No output.")
 -        LOG.info("Updating GIT submodules in working directory {!r}.".format(os.getcwd()))
++        if proc.stderr:
++            cmd_str = ' '.join(map(lambda x: pipes.quote(x), proc.args))
++            msg = _("Error messages on {c!r}:\n{e}").format(c=cmd_str, e=proc.stderr)
++            msg_rc = _("Returncode was {}.").format(proc.returncode)
+             self.print_out(msg)
++            if proc.returncode:
++                self.print_out(msg_rc)
++                self.error_data.append(msg)
++                self.error_data.append(msg_rc)
+         # Update the registered submodules to match what the superproject expects
 -        (ret_val, stdoutdata, stderrdata) = self.handler.call(cmd, sudo=self.do_sudo)
 -        if stdoutdata:
 -            msg = "Output:\n{}".format(to_str(stdoutdata))
++        LOG.info(_("Updating GIT submodules in working directory {!r}.").format(os.getcwd()))
+         cmd = ['git', 'submodule', 'update', '--init', '--recursive']
 -        if stderrdata:
 -            cmd_str = ' '.join(map(lambda x: pipes.quote(x), cmd))
 -            msg = "Error messages on '{c}':\n{e}".format(c=cmd_str, e=to_str(stderrdata))
 -            if ret_val:
 -                self.error_data.append(msg)
++        proc = self.handler.call(cmd, sudo=self.do_sudo, quiet=True)
++        if proc.stdout:
++            msg = _("Output:") + "\n{}".format(proc.stdout)
+             self.print_out(msg)
+         else:
+             LOG.debug("No output.")
 -# =============================================================================
++        if proc.stderr:
++            cmd_str = ' '.join(map(lambda x: pipes.quote(x), proc.args))
++            msg = _("Error messages on {c!r}:\n{e}").format(c=cmd_str, e=proc.stderr)
++            msg_rc = _("Returncode was {}.").format(proc.returncode)
+             self.print_out(msg)
++            if proc.returncode:
++                self.print_out(msg_rc)
++                self.error_data.append(msg)
++                self.error_data.append(msg_rc)
  
 +# =============================================================================
  if __name__ == "__main__":
  
      pass