Ejemplo n.º 1
0
    def test_install_permission_denied(self):
        # if we don't have access to the installation path, we should abort
        # immediately
        project = os.path.join(os.path.dirname(__file__), 'package.tgz')

        # when running from an uninstalled build, a warning is emitted and the
        # installation is not attempted
        if is_python_build():
            self.assertFalse(install.install(project))
            self.assertEqual(1, len(self.get_logs(logging.ERROR)))
            return

        install_path = self.mkdtemp()
        old_get_path = install.get_path
        install.get_path = lambda path: install_path
        old_mod = os.stat(install_path).st_mode
        os.chmod(install_path, 0)
        try:
            self.assertFalse(install.install(project))
        finally:
            os.chmod(install_path, old_mod)
            install.get_path = old_get_path
Ejemplo n.º 2
0
    def test_install_permission_denied(self):
        # if we don't have access to the installation path, we should abort
        # immediately
        project = os.path.join(os.path.dirname(__file__), "package.tgz")

        # when running from an uninstalled build, a warning is emitted and the
        # installation is not attempted
        if is_python_build():
            self.assertFalse(install.install(project))
            self.assertEqual(1, len(self.get_logs(logging.ERROR)))
            return

        install_path = self.mkdtemp()
        old_get_path = install.get_path
        install.get_path = lambda path: install_path
        old_mod = os.stat(install_path).st_mode
        os.chmod(install_path, 0)
        try:
            self.assertFalse(install.install(project))
        finally:
            os.chmod(install_path, old_mod)
            install.get_path = old_get_path
Ejemplo n.º 3
0
 def test_install(self):
     # making sure install returns 0 or 1 exit codes
     project = os.path.join(os.path.dirname(__file__), 'package.tgz')
     install_path = self.mkdtemp()
     old_get_path = install.get_path
     install.get_path = lambda path: install_path
     old_mod = os.stat(install_path).st_mode
     os.chmod(install_path, 0)
     old_stderr = sys.stderr
     sys.stderr = StringIO()
     try:
         self.assertFalse(install.install(project))
         self.assertEqual(main(['install', 'blabla']), 1)
     finally:
         sys.stderr = old_stderr
         os.chmod(install_path, old_mod)
         install.get_path = old_get_path
Ejemplo n.º 4
0
 def test_install(self):
     # making sure install returns 0 or 1 exit codes
     project = os.path.join(os.path.dirname(__file__), 'package.tgz')
     install_path = self.mkdtemp()
     old_get_path = install.get_path
     install.get_path = lambda path: install_path
     old_mod = os.stat(install_path).st_mode
     os.chmod(install_path, 0)
     old_stderr = sys.stderr
     sys.stderr = StringIO()
     try:
         self.assertFalse(install.install(project))
         self.assertEqual(main(['install', 'blabla']), 1)
     finally:
         sys.stderr = old_stderr
         os.chmod(install_path, old_mod)
         install.get_path = old_get_path
Ejemplo n.º 5
0
def _install(dispatcher, args, **kw):
    # first check if we are in a source directory
    if len(args) < 2:
        # are we inside a project dir?
        if os.path.isfile('setup.cfg') or os.path.isfile('setup.py'):
            args.insert(1, os.getcwd())
        else:
            logger.warning('No project to install.')
            return 1

    target = args[1]
    # installing from a source dir or archive file?
    if os.path.isdir(target) or _is_archive_file(target):
        return not install_local_project(target)
    else:
        # download from PyPI
        return not install(target)
Ejemplo n.º 6
0
def _install(dispatcher, args, **kw):
    # first check if we are in a source directory
    if len(args) < 2:
        # are we inside a project dir?
        if os.path.isfile('setup.cfg') or os.path.isfile('setup.py'):
            args.insert(1, os.getcwd())
        else:
            logger.warning('No project to install.')
            return 1

    target = args[1]
    # installing from a source dir or archive file?
    if os.path.isdir(target) or _is_archive_file(target):
        return not install_local_project(target)
    else:
        # download from PyPI
        return not install(target)