예제 #1
0
    def run_command(self, cmd, cwd=None, parcels=None, required=True):
        """
        Run a command on parcels selected from the command-line via the -p flag.
        The argument cmd specifies the config option name of the
        command, and cwd is the working directory to run the command
        from within.  If cwd is not specified or None, it will be the
        name of the parcel.
        """
        if parcels is None:
            parcels = self.parcels
        failed = []
        for parcel in parcels:
            try:
                run_steps = parcel[cmd]
            except KeyError, e:
                if required:
                    msg_template = 'Section "%s" missing required option %s'
                    terminate(msg_template % (parcel["name"], cmd))
                else:
                    notify("Skipping %s" % parcel["name"])
                    continue

            if not isinstance(run_steps, (tuple, list)):
                run_steps = [run_steps]
            try:
                for step in run_steps:
                    if step:
                        if cwd is None:
                            sh(step, join(".", parcel["dir"]))
                        else:
                            sh(step, cwd)
            except subprocess.CalledProcessError:
                failed.append(parcel["name"])
예제 #2
0
 def _handle_missing_interp(self, e, path=None):
     if self.args and self.args.verbose:
         traceback.print_exc()
     else:
         notify(str(e))
     if path:
         terminate("While merging file %s" % path)
     else:
         terminate("File unknown")