Exemplo n.º 1
0
    def run_command_clone(self, options, args):
        if len(args) < 3:
            logger.error("Unrecognized command line argument: ( 'pythonbrew venv clone <source> <target>' )")
            sys.exit(1)
        if not os.access(PATH_VENVS, os.W_OK):
            logger.error("Can not clone a virtual environment in %s.\nPermission denied." % PATH_VENVS)
            sys.exit(1)
        if not self._pkgname:
            logger.error("Unknown python version: ( 'pythonbrew venv clone <source> <target> -p VERSION' )")
            sys.exit(1)

        source, target = args[1], args[2]
        source_dir = os.path.join(self._workon_home, source)
        target_dir = os.path.join(self._workon_home, target)

        if not os.path.isdir(source_dir):
            logger.error('%s does not exist.' % source_dir)
            sys.exit(1)

        if os.path.isdir(target_dir):
            logger.error('Can not overwrite %s.' % target_dir)
            sys.exit(1)

        logger.info("Cloning `%s` environment into `%s` on %s" % (source, target, self._workon_home))

        # Copies source to target
        cmd = [self._py, self._venv_clone, source_dir, target_dir]
        s = Subprocess()
        s.call(cmd)
Exemplo n.º 2
0
    def run_command_create(self, options, args):
        if not os.access(PATH_VENVS, os.W_OK):
            logger.error(
                "Can not create a virtual environment in %s.\nPermission denied."
                % PATH_VENVS)
            sys.exit(1)
        if not self._pkgname:
            logger.error(
                "Unknown python version: ( 'pythonbrew venv create <project> -p VERSION' )"
            )
            sys.exit(1)

        virtualenv_options = []
        if options.no_site_packages:
            virtualenv_options.append('--no-site-packages')

        for arg in args[1:]:
            target_dir = os.path.join(self._workon_home, arg)
            logger.info("Creating `%s` environment into %s" %
                        (arg, self._workon_home))
            # make command
            cmd = [self._py, self._venv, '-p', self._target_py]
            cmd.extend(virtualenv_options)
            cmd.append(target_dir)
            # create environment
            s = Subprocess(verbose=True)
            s.call(cmd)
Exemplo n.º 3
0
 def make(self):
     jobs = self.options.jobs
     make = ((jobs > 0 and 'make -j%s' % jobs) or 'make')
     s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose)
     s.check_call(make)
     if not self.options.no_test:
         if self.options.force:
             # note: ignore tests failure error.
             s.call("make test")
         else:
             s.check_call("make test")
Exemplo n.º 4
0
 def make(self):
     jobs = self.options.jobs
     make = ((jobs > 0 and 'make -j%s' % jobs) or 'make')
     s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose)
     s.check_call(make)
     if self.options.test:
         if self.options.force:
             # note: ignore tests failure error.
             s.call("make test")
         else:
             s.check_call("make test")
Exemplo n.º 5
0
    def run_command_create(self, options, args):
        if not os.access(PATH_VENVS, os.W_OK):
            logger.error("Can not create a virtual environment in %s.\nPermission denied." % PATH_VENVS)
            sys.exit(1)

        virtualenv_options = []
        if options.no_site_packages:
            virtualenv_options.append('--no-site-packages')
        
        for arg in args[1:]:
            target_dir = os.path.join(self._workon_home, arg)
            logger.info("Creating `%s` environment into %s" % (arg, self._workon_home))
            # make command
            cmd = [self._py, self._venv, '-p', self._target_py]
            cmd.extend(virtualenv_options)
            cmd.append(target_dir)
            # create environment
            s = Subprocess(verbose=True)
            s.call(cmd)