Пример #1
0
    def run(self, args, config):
        unsuccessful = []
        for parcel in config.parcels:
            if not parcel.get('no-nose', False):
                nose_opts=parcel.get('nose', {})
                writer = SafeConfigParser()
                writer.add_section('nosetests')
                for key, value in nose_opts.iteritems():
                    if self.nose_has_option(key):
                        writer.set('nosetests', key, value)
                config_file = tempfile.NamedTemporaryFile(delete=False)
                try:
                    writer.write(config_file)
                finally:
                    config_file.close()

                    options = ['{BINDIR}/nosetests', '-c %s' % config_file.name]
                    options.extend(args.nose_arguments)
                try:
                    sh(' '.join(options), cwd=parcel['dir'])
                except SystemExit, e:
                    unsuccessful.append(parcel['name'])
                    notify('Continuing to next parcel')
                finally:
                    if args.keep_config_file:
Пример #2
0
def handle_command_path(config):
    for path in config['project']['command-path']:
        sys.path.append(path)
    try:
        import builtins
    except ImportError, i:
        notify('WARNING:  unable to find builtin commands')
Пример #3
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"])
Пример #4
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")
Пример #5
0
 def handle_dependencies(self, args):
     """
     Install any python dependencies that are not findable by
     pkg_resources.require.
     """
     for dependency in self.py_dependencies:
         try:
             pkg_resources.require(dependency)
         except pkg_resources.DistributionNotFound:
             notify('Installing %s' % dependency)
             sh("pip install '%s'" % dependency)
         except pkg_resources.VersionConflict:
             notify('Upgrading %s' % dependency)
             sh("pip install -U '%s'" % dependency)
Пример #6
0
 def report(self, unsuccessful):
     if unsuccessful:
         notify('The following parcels had failed tests:')
         for name in unsuccessful:
             notify(name)
     else:
         notify('All parcels successful')
Пример #7
0
 def run(self, args, config):
     notify('Hello, world!')
Пример #8
0
 def run(self, args, config):
     notify('Hello, %s!' % args.name)