示例#1
0
 def install_env_requires(self, config, pip_cmd):
     required = config['project']['requires']
     if required:
         warn('The requires attribute is deprecated and will be removed in a '
              'future release.')
     for requirement in required:
         sh('%s %s' % (pip_cmd, requirement))
    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:
示例#3
0
 def install_requirements_files(self, config, pip_cmd):
     requirements_files = config['project']['requirements']
     for fname in requirements_files:
         if os.path.exists(fname):
             sh('%s -r %s' % (pip_cmd, fname))
         else:
             warn('Requirements file %s not found.  Skipping.' % fname)
示例#4
0
    def run(self, args, config):
        for parcel in config.parcels:
            cmd_text_list = parcel.get(self.name)
            if cmd_text_list is None:
                default = self._section.get('default')
                if not default:
                    msg = "Parcel %s doesn't have required option %s" % (
                        parcel.name,
                        self.name)

                    assert not self._section['required'], msg
                    continue
                else:
                    cmd_text_list = [self._percent_escape(parcel, cmd)
                                     for cmd in default]
            elif not isinstance(cmd_text_list, list):
                cmd_text_list = [cmd_text_list]
            cwd = self._section['working_dir']
            cwd = self._percent_escape(parcel, cwd)
            # NOTE:  deprecated
            # Single $ here since this will have already been run
            # through string interpolation
            cwd = cwd.replace('$PARCEL_WD', os.path.abspath(parcel['dir']))
            for cmd_text in cmd_text_list:
                sh(cmd_text, cwd = cwd)
示例#5
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"])
示例#6
0
 def run(self, args, config):
     if not args.no_create:
         venv_opts = config['project']['virtualenv-args']
         sh('virtualenv ' + venv_opts)
     pip_cmd = self.get_pip_cmd(config, args)
     self.install_env_requires(config, pip_cmd)
     self.install_requirements_files(config, pip_cmd)
     config.run_command('setup', required=False)
示例#7
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)
示例#8
0
    def run(self, args, config):
        for parcel in config.parcels:
            cmd_text = parcel.get(self._name)
            if cmd_text is None:
                default = self._section.get('default')
                if not default:
                    msg = "Parcel %s doesn't have required option %s" % (
                        parcel.name,
                        self._name)

                    assert not self._section['required'], msg
                    continue
                else:
                    cmd_text = default
            cwd = self._section['working_dir']
            # Single $ here since this will have already been run
            # through string interpolation
            cwd = cwd.replace('$PARCEL_WD', os.path.abspath(parcel.name))
            sh(cmd_text, cwd = cwd)
示例#9
0
 def run(self, args, config):
     sh('virtualenv --no-site-packages .')
     requirements = config['project']['requires']
     easy_install = config['project']['easy_install'] 
     sh('%s pip' % easy_install)
     for requirement in requirements:
         sh('%s %s' % (easy_install, requirement))
     for parcel in config.parcels:
         build_cmds = parcel['setup']
         if not isinstance(build_cmds, (list, tuple)):
             build_cmds = [build_cmds]
         for build_cmd in build_cmds:
             sh(build_cmd, cwd=os.path.abspath(parcel['name']))
示例#10
0
    def run_command(self, cmd, cwd=None, parcels=None):
        """
        Run a command on all parcels.  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:
            run_steps = parcel[cmd]
            if not isinstance(run_steps, (tuple, list)):
                run_steps = [run_steps]
            try:
                for step in run_steps:

                    if cwd is None:
                        sh(step, join('.', parcel['name']))
                    else:
                        sh(step, cwd)
            except subprocess.CalledProcessError:
                failed.append(parcel['name'])
        return failed
示例#11
0
 def run(self, args, config):
     sh("echo 'Hello, world!'")
示例#12
0
 def run(self, args, config):
     for parcel in config.parcels:
         cmd = parcel['checkout']
         sh(cmd)