def _uninstall_version(self, version):
        'Install the major.minor full version of python.'
        check.check_string(version)
        assert python_version.is_version(version)

        np = native_package(self.blurber)

        to_delete_package_names = self._python_package_names_for_version(
            version)
        if np.has_any_package(to_delete_package_names):
            self._sudo_validate('sudo password for uninstall:')

        result = False
        for package_name in to_delete_package_names:
            if np.has_package(package_name):
                result = True
                self.blurb_verbose('uninstalling {} - {}'.format(
                    version, package_name))
                np.remove(package_name, False)

        garbage = [
            '/Applications/Python {}'.format(version),
            '/Library/Frameworks/Python.framework/Versions/{}'.format(version),
        ]

        for next_garbage in garbage:
            if path.exists(next_garbage):
                rv = True
                self._sudo_validate('sudo password for uninstall:')
                args = ['rm', '-rf', next_garbage]
                sudo.call_sudo(args)
        return result
    def install_package(self, package_filename):
        'Install a python package directly.  Not always supported.'
        check.check_string(package_filename)

        np = native_package(self.blurber)
        np.install(package_filename)

        self._run_commands(np, version)
        self._cleanup_links()
    def installed_versions(self):
        'Return a list of installed python versions.'

        result = []
        np = native_package(self.options.blurber)
        all_packages = np.installed_packages()
        for package_name in all_packages:
            if 'PythonFramework' in package_name:
                exe = self._python_exe_for_package(np, package_name)
                if not exe:
                    raise python_installer_error(
                        'Failed to determine the python executable for possibly corrupted package: "{}"'
                        .format(package_name))
                full_version = python_exe.full_version(exe)
                result.append(full_version)
        return sorted(result)
    def _uninstall_full_version(self, full_version):
        'Install the major.minor.revision full version of python.'
        check.check_string(full_version)
        assert python_version.is_full_version(full_version)

        version = python_version.version(full_version)
        np = native_package(self.blurber)
        package_name = 'org.python.Python.PythonFramework-{}'.format(version)
        if np.has_package(package_name):
            exe = self._python_exe_for_package(np, package_name)
            if not exe:
                raise python_installer_error(
                    'Failed to determine the python executable for possibly corrupted package: "{}"'
                    .format(package_name))
            actual_full_version = python_exe.full_version(exe)
            if actual_full_version != full_version:
                raise python_installer_error(
                    'Python version mismatch.  expected={} actual={}'.format(
                        full_version, actual_full_version))

        return self._uninstall_version(version)
Пример #5
0
 def test_installed_packages(self):
     np = native_package()
     self.assertTrue(len(np.installed_packages()) > 0)
Пример #6
0
 def test_owner_macos(self):
     np = native_package()
     pkg = self._macos_example_pkg()
     manifest = np.package_files(pkg)
     self.assertEqual(pkg, np.owner(manifest[0]))
Пример #7
0
 def test_owner_linux(self):
     np = native_package()
     self.assertEqual('coreutils', np.owner('/bin/ls'))
     self.assertEqual('bash', np.owner('/bin/bash'))
Пример #8
0
 def test_is_installed_linux(self):
     np = native_package()
     self.assertTrue(np.is_installed('bash'))
     self.assertFalse(np.is_installed('foosomethingnottherelikely'))
Пример #9
0
 def test_is_installed_macos(self):
     np = native_package()
     self.assertFalse(np.is_installed('bash'))
     self.assertTrue(np.is_installed(self._macos_example_pkg()))
Пример #10
0
 def test_package_info_macos(self):
     np = native_package()
     info = np.package_info(self._macos_example_pkg())
     self.assertTrue(len(info) > 0)
Пример #11
0
 def test_package_files_macos(self):
     np = native_package()
     files = np.package_files(self._macos_example_pkg())
     self.assertTrue(len(files) > 0)
Пример #12
0
 def test_package_manifest_macos(self):
     np = native_package()
     manifest = np.package_files(self._macos_example_pkg())
     self.assertTrue(len(manifest) > 0)