当前位置: 首页>>代码示例>>Python>>正文


Python mozinstall.install函数代码示例

本文整理汇总了Python中mozinstall.install函数的典型用法代码示例。如果您正苦于以下问题:Python install函数的具体用法?Python install怎么用?Python install使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了install函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_binary

    def test_get_binary(self):
        """ Test mozinstall's get_binary method """

        if mozinfo.isLinux:
            installdir = mozinstall.install(self.bz2, self.tempdir)
            binary = os.path.join(installdir, 'firefox')
            self.assertEqual(binary, mozinstall.get_binary(installdir, 'firefox'))

        elif mozinfo.isWin:
            installdir_exe = mozinstall.install(self.exe,
                                                os.path.join(self.tempdir, 'exe'))
            binary_exe = os.path.join(installdir_exe, 'firefox', 'firefox',
                                      'firefox.exe')
            self.assertEqual(binary_exe, mozinstall.get_binary(installdir_exe,
                             'firefox'))

            installdir_zip = mozinstall.install(self.zipfile,
                                                os.path.join(self.tempdir, 'zip'))
            binary_zip = os.path.join(installdir_zip, 'firefox.exe')
            self.assertEqual(binary_zip, mozinstall.get_binary(installdir_zip,
                             'firefox'))

        elif mozinfo.isMac:
            installdir = mozinstall.install(self.dmg, self.tempdir)
            binary = os.path.join(installdir, 'Contents', 'MacOS', 'firefox')
            self.assertEqual(binary, mozinstall.get_binary(installdir, 'firefox'))
开发者ID:AutomatedTester,项目名称:mozbase,代码行数:26,代码来源:test.py

示例2: install_build

    def install_build(self, url):
        try:
            self.logger.info("Installing build from url: %s" % url)
            buildfile = os.path.abspath("b2gtarball.tar.gz")
            urllib.urlretrieve(url, buildfile)
        except:
            self.logger.exception("Failed to download build")

        try:
            self.logger.info("Untarring build")
            # Extract to the same local directory where we downloaded the build
            # to.  This defaults to the local directory where our script runs
            dest = os.path.join(os.path.dirname(buildfile), 'downloadedbuild')
            if (os.access(dest, os.F_OK)):
                shutil.rmtree(dest)
            install(buildfile, dest)
            # This should extract into a qemu directory
            qemu = os.path.join(dest, 'qemu')
            if os.path.exists(qemu):
                return qemu
            else:
                return None
        except:
            self.logger.exception("Failed to untar file")
        return None
开发者ID:AshishNamdev,项目名称:mozilla-central,代码行数:25,代码来源:automator.py

示例3: test_uninstall

    def test_uninstall(self):
        """ Test mozinstall's uninstall capabilites """
        # Uninstall after installing

        if mozinfo.isLinux:
            installdir = mozinstall.install(self.bz2, self.tempdir)
            mozinstall.uninstall(installdir)
            self.assertFalse(os.path.exists(installdir))

        elif mozinfo.isWin:
            # Exe installer for Windows
            installdir_exe = mozinstall.install(self.exe,
                                                os.path.join(self.tempdir, 'exe'))
            mozinstall.uninstall(installdir_exe)
            self.assertFalse(os.path.exists(installdir_exe))

            # Zip installer for Windows
            installdir_zip = mozinstall.install(self.zipfile,
                                                os.path.join(self.tempdir, 'zip'))
            mozinstall.uninstall(installdir_zip)
            self.assertFalse(os.path.exists(installdir_zip))

        elif mozinfo.isMac:
            installdir = mozinstall.install(self.dmg, self.tempdir)
            mozinstall.uninstall(installdir)
            self.assertFalse(os.path.exists(installdir))
开发者ID:AutomatedTester,项目名称:mozbase,代码行数:26,代码来源:test.py

示例4: install

    def install(self, dest=None, channel="nightly"):
        """Install Firefox."""

        branch = {
            "nightly": "mozilla-central",
            "beta": "mozilla-beta",
            "stable": "mozilla-stable"
        }
        scraper = {
            "nightly": "daily",
            "beta": "release",
            "stable": "release"
        }
        version = {
            "stable": "latest",
            "beta": "latest-beta",
            "nightly": "latest"
        }
        if channel not in branch:
            raise ValueError("Unrecognised release channel: %s" % channel)

        from mozdownload import FactoryScraper
        import mozinstall

        platform = {
            "Linux": "linux",
            "Windows": "win",
            "Darwin": "mac"
        }.get(uname[0])

        if platform is None:
            raise ValueError("Unable to construct a valid Firefox package name for current platform")

        if dest is None:
            # os.getcwd() doesn't include the venv path
            dest = os.path.join(os.getcwd(), "_venv")

        dest = os.path.join(dest, "browsers", channel)

        filename = FactoryScraper(scraper[channel],
                                  branch=branch[channel],
                                  version=version[channel],
                                  destination=dest).download()

        try:
            mozinstall.install(filename, dest)
        except mozinstall.mozinstall.InstallError:
            if platform == "mac" and os.path.exists(os.path.join(dest, "Firefox Nightly.app")):
                # mozinstall will fail if nightly is already installed in the venv because
                # mac installation uses shutil.copy_tree
                mozinstall.uninstall(os.path.join(dest, "Firefox Nightly.app"))
                mozinstall.install(filename, dest)
            else:
                raise

        os.remove(filename)
        return self.find_binary_path(dest)
开发者ID:shadowkun,项目名称:servo,代码行数:57,代码来源:browser.py

示例5: download_b2g_sdk

def download_b2g_sdk(b2g_sdk):
    system = platform.system()
    if system == "Linux":
        url = "https://queue.taskcluster.net/v1/task/YamDhuDgTWa_kWXcSedDHA/artifacts/public/build/target.linux-x86_64.tar.bz2"
    elif system == "Darwin":
        url = "http://ftp.mozilla.org/pub/mozilla.org/b2g/nightly/2015/09/2015-09-02-03-02-03-mozilla-central/b2g-43.0a1.en-US.mac64.dmg"
    elif system == "Windows":
        url = "http://ftp.mozilla.org/pub/mozilla.org/b2g/nightly/2015/09/2015-09-02-03-02-03-mozilla-central/b2g-43.0a1.en-US.win32.zip"
    else:
        raise Exception('Unable to download b2g_sdk for %s' % system)

    if not os.path.isdir(b2g_sdk):
        os.mkdir(b2g_sdk)

    b2g_path = os.path.join(b2g_sdk, "b2g")
    if not os.path.isdir(b2g_path):
        file_path = os.path.join(b2g_sdk, os.path.basename(urlparse.urlparse(url).path))

        import requests

        with open(file_path, "wb") as b2g:
            print("Downloading %s" % url)
            response = requests.get(url, stream=True)
            total_length = response.headers.get("content-length")

            if total_length is None: # no content length header
                b2g.write(response.content)
            else:
                download_length = 0
                total_length = int(total_length)
                for data in response.iter_content(8192):
                    download_length += len(data)
                    b2g.write(data)
                    print("\r%10d / %10d [%3.2f%%]" %
                            (download_length,
                            total_length,
                            download_length * 100. / total_length),
                            end = "")
            b2g.close()

        print()
        print("Extract %s..." % file_path)

        import mozinstall
        mozinstall.install(file_path, os.path.join(b2g_sdk))

        if system == "Darwin":
            os.symlink(os.path.join(b2g_sdk, "B2G.app", "Contents", "MacOS"), b2g_path)

    return b2g_path
开发者ID:151706061,项目名称:B2G,代码行数:50,代码来源:mach_b2g_bootstrap.py

示例6: startTestRunner

def startTestRunner(runner_class, options, tests):
    install_folder = None

    try:
        # Prepare the workspace path so that all temporary data can be stored inside it.
        if options.workspace_path:
            path = os.path.expanduser(options.workspace_path)
            options.workspace = os.path.abspath(path)

            if not os.path.exists(options.workspace):
                os.makedirs(options.workspace)
        else:
            options.workspace = tempfile.mkdtemp(".{}".format(os.path.basename(sys.argv[0])))

        options.logger.info('Using workspace for temporary data: "{}"'.format(options.workspace))

        # If the specified binary is an installer it needs to be installed
        if options.installer:
            installer = os.path.realpath(options.installer)

            dest_folder = os.path.join(options.workspace, "binary")
            options.logger.info('Installing application "%s" to "%s"' % (installer, dest_folder))
            install_folder = mozinstall.install(installer, dest_folder)
            options.binary = mozinstall.get_binary(install_folder, "firefox")

        runner = runner_class(**vars(options))
        runner.run_tests(tests)

    finally:
        # Ensure to uninstall the binary if it has been installed before
        if install_folder and os.path.exists(install_folder):
            options.logger.info('Uninstalling application at "%s"' % install_folder)
            mozinstall.uninstall(install_folder)

    return runner
开发者ID:myrdd,项目名称:firefox-ui-tests,代码行数:35,代码来源:runtests.py

示例7: prepare_application

    def prepare_application(self, binary):
        # Prepare the binary for the test run
        if application.is_installer(self.binary, self.options.application):
            install_path = os.path.join(self.workspace, 'binary')

            print "*** Installing build: %s" % self.binary
            self._folder = mozinstall.install(self.binary, install_path)

            binary_name = APPLICATION_BINARY_NAMES[self.options.application]
            self._application = mozinstall.get_binary(self._folder,
                                                      binary_name)
        else:
            if os.path.isdir(self.binary):
                self._folder = self.binary
            else:
                if mozinfo.isMac:
                    # Ensure that self._folder is the app bundle on OS X
                    p = re.compile('.*\.app/')
                    self._folder = p.search(self.binary).group()
                else:
                    self._folder = os.path.dirname(self.binary)

            binary_name = APPLICATION_BINARY_NAMES[self.options.application]
            self._application = mozinstall.get_binary(self._folder,
                                                      binary_name)
开发者ID:andreieftimie,项目名称:mozmill-automation,代码行数:25,代码来源:testrun.py

示例8: install

 def install(self):
     if not self.name:
         raise NotImplementedError("Can't invoke abstract base class")
     self.remove_tempdir()
     self.tempdir = tempfile.mkdtemp()
     self.binary = mozinstall.get_binary(mozinstall.install(src=self.dest, dest=self.tempdir), self.name)
     return True
开发者ID:AaronMT,项目名称:mozregression,代码行数:7,代码来源:runnightly.py

示例9: test_install

    def test_install(self):
        """ Test mozinstall's install capability """

        if mozinfo.isLinux:
            installdir = mozinstall.install(self.bz2, self.tempdir)
            self.assertEqual(os.path.join(self.tempdir, "firefox"), installdir)

        elif mozinfo.isWin:
            installdir_exe = mozinstall.install(self.exe, os.path.join(self.tempdir, "exe"))
            self.assertEqual(os.path.join(self.tempdir, "exe", "firefox"), installdir_exe)

            installdir_zip = mozinstall.install(self.zipfile, os.path.join(self.tempdir, "zip"))
            self.assertEqual(os.path.join(self.tempdir, "zip", "firefox"), installdir_zip)

        elif mozinfo.isMac:
            installdir = mozinstall.install(self.dmg, self.tempdir)
            self.assertEqual(os.path.join(os.path.realpath(self.tempdir), "FirefoxStub.app"), installdir)
开发者ID:JasonGross,项目名称:mozjs,代码行数:17,代码来源:test.py

示例10: _install

 def _install(self, dest):
     self.tempdir = tempfile.mkdtemp()
     try:
         self.binary = mozinstall.get_binary(
             mozinstall.install(src=dest, dest=self.tempdir),
             self.app_name
         )
     except:
         rmtree(self.tempdir)
         raise
开发者ID:JohanLorenzo,项目名称:mozregression,代码行数:10,代码来源:launchers.py

示例11: test_get_binary

    def test_get_binary(self):
        """ Test mozinstall's get_binary method """

        if mozinfo.isLinux:
            installdir = mozinstall.install(self.bz2, self.tempdir)
            binary = os.path.join(installdir, "firefox")
            self.assertEqual(binary, mozinstall.get_binary(installdir, "firefox"))

        elif mozinfo.isWin:
            installdir_exe = mozinstall.install(self.exe, os.path.join(self.tempdir, "exe"))
            binary_exe = os.path.join(installdir_exe, "firefox", "firefox", "firefox.exe")
            self.assertEqual(binary_exe, mozinstall.get_binary(installdir_exe, "firefox"))

            installdir_zip = mozinstall.install(self.zipfile, os.path.join(self.tempdir, "zip"))
            binary_zip = os.path.join(installdir_zip, "firefox.exe")
            self.assertEqual(binary_zip, mozinstall.get_binary(installdir_zip, "firefox"))

        elif mozinfo.isMac:
            installdir = mozinstall.install(self.dmg, self.tempdir)
            binary = os.path.join(installdir, "Contents", "MacOS", "firefox")
            self.assertEqual(binary, mozinstall.get_binary(installdir, "firefox"))
开发者ID:JasonGross,项目名称:mozjs,代码行数:21,代码来源:test.py

示例12: firefox

def firefox(pytestconfig, tmpdir_factory):
    binary = os.getenv('MOZREGRESSION_BINARY',
                       pytestconfig.getoption('firefox'))
    if binary is None:
        cache_dir = str(pytestconfig.cache.makedir('firefox'))
        scraper = FactoryScraper('daily', destination=cache_dir)
        build_path = scraper.download()
        install_path = str(tmpdir_factory.mktemp('firefox'))
        install_dir = mozinstall.install(src=build_path, dest=install_path)
        binary = mozinstall.get_binary(install_dir, 'firefox')
    version = mozversion.get_version(binary)
    if hasattr(pytestconfig, '_metadata'):
        pytestconfig._metadata.update(version)
    return binary
开发者ID:99arobe,项目名称:firefox-ios,代码行数:14,代码来源:conftest.py

示例13: install

    def install(self, dest=None):
        """Install Firefox."""

        from mozdownload import FactoryScraper
        import mozinstall

        platform = {
            "Linux": "linux",
            "Windows": "win",
            "Darwin": "mac"
        }.get(uname[0])

        if platform is None:
            raise ValueError("Unable to construct a valid Firefox package name for current platform")

        if dest is None:
            # os.getcwd() doesn't include the venv path
            dest = os.path.join(os.getcwd(), "_venv")

        dest = os.path.join(dest, "browsers")

        filename = FactoryScraper("daily", branch="mozilla-central", destination=dest).download()

        try:
            mozinstall.install(filename, dest)
        except mozinstall.mozinstall.InstallError as e:
            if platform == "mac" and os.path.exists(os.path.join(dest, "Firefox Nightly.app")):
                # mozinstall will fail if nightly is already installed in the venv because
                # mac installation uses shutil.copy_tree
                mozinstall.uninstall(os.path.join(dest, "Firefox Nightly.app"))
                mozinstall.install(filename, dest)
            else:
                raise

        os.remove(filename)
        return self.find_binary_path(dest)
开发者ID:Jayflux,项目名称:servo,代码行数:36,代码来源:browser.py

示例14: binary

def binary():
    """Return a Firefox binary"""
    try:
        return build.get_binary_path()
    except Exception:
        pass

    app = 'firefox'
    bindir = os.path.join(os.environ['PYTHON_TEST_TMP'], app)
    if os.path.isdir(bindir):
        try:
            return mozinstall.get_binary(bindir, app_name=app)
        except Exception:
            pass

    if 'GECKO_INSTALLER_URL' in os.environ:
        bindir = mozinstall.install(
            os.environ['GECKO_INSTALLER_URL'], os.environ['PYTHON_TEST_TMP'])
        return mozinstall.get_binary(bindir, app_name='firefox')
开发者ID:luke-chang,项目名称:gecko-1,代码行数:19,代码来源:fixtures.py

示例15: prepare_application

    def prepare_application(self, binary):
        # Prepare the binary for the test run
        if mozinstall.is_installer(self.binary):
            install_path = tempfile.mkdtemp(".binary")

            print "Install build: %s" % self.binary
            self._folder = mozinstall.install(self.binary, install_path)
            self._application = mozinstall.get_binary(self._folder, self.options.application)
        else:
            if os.path.isdir(self.binary):
                self._folder = self.binary
            else:
                if sys.platform == "darwin":
                    # Ensure that self._folder is the app bundle on OS X
                    p = re.compile(".*\.app/")
                    self._folder = p.search(self.binary).group()
                else:
                    self._folder = os.path.dirname(self.binary)

            self._application = mozinstall.get_binary(self._folder, self.options.application)
开发者ID:smillaedler,项目名称:mozmill-automation,代码行数:20,代码来源:testrun.py


注:本文中的mozinstall.install函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。