• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python ui.UI类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: post_install

 def post_install(self):
     """Add go necessary env variables"""
     add_env_to_user(
         self.name,
         {"PATH": {"value": os.path.join(self.install_path, "bin")}, "GOROOT": {"value": self.install_path}},
     )
     UI.delayed_display(DisplayMessage(_("You need to restart a shell session for your installation to work")))
开发者ID:fcole90,项目名称:ubuntu-make,代码行数:7,代码来源:go.py


示例2: get_metadata_and_check_license

    def get_metadata_and_check_license(self, result):
        logger.debug("Fetched download page, parsing.")

        page = result[self.download_page]

        error_msg = page.error
        if error_msg:
            logger.error("An error occurred while downloading {}: {}".format(self.download_page_url, error_msg))
            UI.return_main_screen(status_code=1)

        soup = BeautifulSoup(page.buffer)
        link = soup.find('a', text="HTTPS")
        if link is None:
            logger.error("Can't parse the download URL from the download page.")
            UI.return_main_screen(status_code=1)
        download_url = link.attrs['href']
        checksum_url = download_url + '.sha256'
        logger.debug("Found download URL: " + download_url)
        logger.debug("Downloading checksum first, from " + checksum_url)

        def checksum_downloaded(results):
            checksum_result = next(iter(results.values()))  # Just get the first.
            if checksum_result.error:
                logger.error(checksum_result.error)
                UI.return_main_screen(status_code=1)

            checksum = checksum_result.buffer.getvalue().decode('utf-8').split()[0]
            logger.info('Obtained SHA256 checksum: ' + checksum)

            self.download_requests.append(DownloadItem(download_url,
                                                       checksum=Checksum(ChecksumType.sha256, checksum),
                                                       ignore_encoding=True))
            self.start_download_and_install()

        DownloadCenter([DownloadItem(checksum_url)], on_done=checksum_downloaded, download=False)
开发者ID:ewmaina,项目名称:ubuntu-make,代码行数:35,代码来源:ide.py


示例3: get_metadata

    def get_metadata(self, result):
        """Download files to download + and download license license and check it"""
        logger.debug("Parse download metadata")

        error_msg = result[self.download_page].error
        if error_msg:
            logger.error("An error occurred while downloading {}: {}".format(self.download_page, error_msg))
            UI.return_main_screen(status_code=1)

        arch = platform.machine()
        download_re = r'\'linux64\': \'([^\']+)\''
        if arch == 'i686':
            download_re = r'\'linux32\': \'([^\']+)\''
        url = None
        for line in result[self.download_page].buffer:
            line = line.decode()
            p = re.search(download_re, line)
            with suppress(AttributeError):
                url = p.group(1)
                logger.debug("Found download link for {}".format(url))

        if url is None:
            logger.error("Download page changed its syntax or is not parsable")
            UI.return_main_screen(status_code=1)
        self.download_requests.append(DownloadItem(url, Checksum(self.checksum_type, None), headers=self.headers))

        if not self.auto_accept_license:
            logger.debug("Downloading License page")
            DownloadCenter([DownloadItem(self.license_url, headers=self.headers)], self.check_external_license,
                           download=False)
        else:
            self.start_download_and_install()
开发者ID:pombredanne,项目名称:ubuntu-make,代码行数:32,代码来源:web.py


示例4: _display

 def _display(self, contentType):
     # print depending on the content type
     while True:
         try:
             if isinstance(contentType, InputText):
                 contentType.run_callback(result=rlinput(contentType.content, contentType.default_input))
             elif isinstance(contentType, LicenseAgreement):
                 print(contentType.content)
                 contentType.choose(answer=input(contentType.input))
             elif isinstance(contentType, TextWithChoices):
                 contentType.choose(answer=input(contentType.prompt))
             elif isinstance(contentType, DisplayMessage):
                 print(contentType.text)
             elif isinstance(contentType, UnknownProgress):
                 if not contentType.bar:
                     contentType.bar = ProgressBar(widgets=[BouncingBar()])
                 with suppress(StopIteration):
                     # pulse and add a timeout callback
                     contentType.bar(contentType._iterator()).next()
                     UI.delayed_display(contentType)
                 # don't recall the callback
                 return False
             else:
                 logger.error("Unexcepted content type to display to CLI UI: {}".format(contentType))
                 MainLoop().quit(status_code=1)
             break
         except InputError as e:
             logger.error(str(e))
             continue
开发者ID:Ubuntu420,项目名称:ubuntu-make,代码行数:29,代码来源:__init__.py


示例5: post_install

    def post_install(self):
        """Add necessary environment variables"""
        add_env_to_user(self.name, {"ANDROID_HOME": {"value": self.install_path, "keep": False}})
        # add "platform-tools" to PATH to ensure "adb" can be run once the platform tools are installed via
        # the SDK manager
        add_env_to_user(
            self.name,
            {
                "PATH": {
                    "value": [os.path.join("$ANDROID_HOME", "tools"), os.path.join("$ANDROID_HOME", "platform-tools")]
                }
            },
        )
        UI.delayed_display(
            DisplayMessage(
                _("You need to restart your current shell session for your {} installation " "to work properly").format(
                    self.name
                )
            )
        )

        # print wiki page message
        UI.delayed_display(
            DisplayMessage(
                "SDK installed in {}. More information on how to use it on {}".format(
                    self.install_path, "https://developer.android.com/sdk/installing/adding-packages.html"
                )
            )
        )
开发者ID:oijazsh,项目名称:ubuntu-make,代码行数:29,代码来源:android.py


示例6: get_metadata

    def get_metadata(self, result):
        """Download files to download + and download license license and check it"""
        logger.debug("Parse download metadata")

        error_msg = result[self.download_page].error
        if error_msg:
            logger.error("An error occurred while downloading {}: {}".format(self.download_page, error_msg))
            UI.return_main_screen()

        url = None
        for line in result[self.download_page].buffer:
            line = line.decode()
            p = re.search(r'<a.*href="(.*)">.*for Linux.*', line)
            with suppress(AttributeError):
                url = p.group(1)
                logger.debug("Found download link for {}".format(url))

        if url is None:
            logger.error("Download page changed its syntax or is not parsable")
            UI.return_main_screen()
        self.download_requests.append(DownloadItem(url, Checksum(self.checksum_type, None), headers=self.headers))

        logger.debug("Downloading License page")
        DownloadCenter([DownloadItem(self.license_url, headers=self.headers)], self.check_external_license,
                       download=False)
开发者ID:anywolf,项目名称:ubuntu-make,代码行数:25,代码来源:web.py


示例7: get_metadata_and_check_license

    def get_metadata_and_check_license(self, result):
        logger.debug("Fetched download page, parsing.")

        page = result[self.download_page]

        error_msg = page.error
        if error_msg:
            logger.error("An error occurred while downloading {}: {}".format(self.download_page, error_msg))
            UI.return_main_screen(status_code=1)

        try:
            key, content = json.loads(page.buffer.read().decode()).popitem()
            download_url = content[0]['downloads']['linux']['link']
            checksum_url = content[0]['downloads']['linux']['checksumLink']
        except (json.JSONDecodeError, IndexError):
            logger.error("Can't parse the download URL from the download page.")
            UI.return_main_screen(status_code=1)
        logger.debug("Found download URL: " + download_url)
        logger.debug("Downloading checksum first, from " + checksum_url)

        def checksum_downloaded(results):
            checksum_result = next(iter(results.values()))  # Just get the first.
            if checksum_result.error:
                logger.error(checksum_result.error)
                UI.return_main_screen(status_code=1)

            checksum = checksum_result.buffer.getvalue().decode('utf-8').split()[0]
            logger.info('Obtained SHA256 checksum: ' + checksum)

            self.download_requests.append(DownloadItem(download_url,
                                                       checksum=Checksum(ChecksumType.sha256, checksum),
                                                       ignore_encoding=True))
            self.start_download_and_install()

        DownloadCenter([DownloadItem(checksum_url)], on_done=checksum_downloaded, download=False)
开发者ID:shanenelson,项目名称:ubuntu-make,代码行数:35,代码来源:ide.py


示例8: get_metadata_and_check_license

    def get_metadata_and_check_license(self, result):
        """Get latest version and append files to download"""
        logger.debug("Set download metadata")

        error_msg = result[self.download_page].error
        if error_msg:
            logger.error("An error occurred while downloading {}: {}".format(self.download_page, error_msg))
            UI.return_main_screen(status_code=1)

        version = ''
        version_re = r'Dart SDK (.*) api docs'
        for line in result[self.download_page].buffer:
            p = re.search(version_re, line.decode())
            with suppress(AttributeError):
                version = p.group(1)
                break
        else:
            logger.error("Download page changed its syntax or is not parsable")
            UI.return_main_screen(status_code=1)

        tag_machine = 'x64'
        if platform.machine() == 'i686':
            tag_machine = 'ia32'

        url = "https://storage.googleapis.com/dart-archive/channels/stable/release/{}/sdk/dartsdk-linux-{}-release.zip"\
            .format(version, tag_machine)
        logger.debug("Found download link for {}".format(url))

        self.download_requests.append(DownloadItem(url, None))
        self.start_download_and_install()
开发者ID:rridhan,项目名称:ubuntu-make,代码行数:30,代码来源:dart.py


示例9: post_install

 def post_install(self):
     """Add rust necessary env variables"""
     add_env_to_user(self.name, {"PATH": {"value": "{}:{}".format(os.path.join(self.install_path, "rustc", "bin"),
                                                                  os.path.join(self.install_path, "cargo", "bin"))},
                                 "LD_LIBRARY_PATH": {"value": os.path.join(self.install_path, "rustc", "lib")}})
     UI.delayed_display(DisplayMessage(_("You need to restart your current shell session for your {} installation "
                                         "to work properly").format(self.name)))
开发者ID:pombredanne,项目名称:ubuntu-make,代码行数:7,代码来源:rust.py


示例10: get_metadata_and_check_license

    def get_metadata_and_check_license(self, result):
        """Get the latest version and trigger the download of the download_page file.
        :param result: the file downloaded by DownloadCenter, contains a web page
        """
        # Processing the string to obtain metadata (version)
        try:
            url_version_str = result[self.download_page].buffer.read().decode('utf-8')
        except AttributeError:
            # The file could not be parsed or there is no network connection
            logger.error("The download page changed its syntax or is not parsable")
            UI.return_main_screen(status_code=1)

        preg = re.compile(".*/images_www/v6/download/.*")
        for line in url_version_str.split("\n"):
            if preg.match(line):
                line = line.replace("var PAGE_ARTIFACTS_LOCATION = \"/images"
                                    "_www/v6/download/", "").replace("/\";", "").replace('/final', '')
                self.version = line.strip()

        if not self.version:
            # Fallback
            logger.error("Could not determine latest version")
            UI.return_main_screen(status_code=1)

        self.version_download_page = "https://netbeans.org/images_www/v6/download/" \
                                     "{}/final/js/files.js".format(self.version)
        DownloadCenter([DownloadItem(self.version_download_page)], self.parse_download_page_callback, download=False)
开发者ID:jravetch,项目名称:ubuntu-make,代码行数:27,代码来源:ide.py


示例11: confirm_path

    def confirm_path(self, path_dir=""):
        """Confirm path dir"""

        if not path_dir:
            logger.debug("No installation path provided. Requesting one.")
            UI.display(InputText("Choose installation path:", self.confirm_path, self.install_path))
            return

        logger.debug("Installation path provided. Checking if exists.")
        with suppress(FileNotFoundError):
            if os.listdir(path_dir):
                # we already told we were ok to overwrite as it was the previous install path
                if path_dir not in self._paths_to_clean:
                    if path_dir == "/":
                        logger.error("This doesn't seem wise. We won't let you shoot in your feet.")
                        self.confirm_path()
                        return
                    self.install_path = path_dir  # we don't set it before to not repropose / as installation path
                    UI.display(YesNo("{} isn't an empty directory, do you want to remove its content and install "
                                     "there?".format(path_dir), self.set_installdir_to_clean, UI.return_main_screen))
                    return
        self.install_path = path_dir
        if self.desktop_filename:
            self.exec_path = os.path.join(self.install_path, self.required_files_path[0])
        # if self.exec_rel_path:
        #     self.exec_path = os.path.join(self.install_path, self.exec_rel_path)
        self.download_provider_page()
开发者ID:om26er,项目名称:ubuntu-make,代码行数:27,代码来源:baseinstaller.py


示例12: download_and_requirements_done

    def download_and_requirements_done(self):
        # wait for both side to be done
        if self._download_done_callback_called or (not self.result_download or not self.result_requirement):
            return
        self._download_done_callback_called = True

        self.pbar.finish()
        # display eventual errors
        error_detected = False
        if self.result_requirement.error:
            logger.error("Package requirements can't be met: {}".format(self.result_requirement.error))
            error_detected = True

        # check for any errors and collect fds
        fds = []
        for url in self.result_download:
            if self.result_download[url].error:
                logger.error(self.result_download[url].error)
                error_detected = True
            fds.append(self.result_download[url].fd)
        if error_detected:
            UI.return_main_screen(status_code=1)

        # now decompress
        self.decompress_and_install(fds)
开发者ID:collinsnji,项目名称:ubuntu-make,代码行数:25,代码来源:baseinstaller.py


示例13: download_provider_page

    def download_provider_page(self):

        # grab initial download link from homepage
        response = urllib.request.urlopen('https://processing.org/download/?processing')
        htmlDocument = response.read()
        soupDocument = BeautifulSoup(htmlDocument, 'html.parser')

        arch = platform.machine()
        plat = ''
        if arch == 'i686':
            plat = 'linux32'
        elif arch == 'x86_64':
            plat = 'linux64'
        else:
            logger.error("Unsupported architecture: {}".format(arch))
            UI.return_main_screen()

        downloads = soupDocument.body.find('div', attrs={'class': 'downloads'})
        self.version = downloads.find('span', attrs={'class': 'version'}).text
        dl = downloads.find('ul', attrs={'class': 'current-downloads'})

        fileURL = ''
        for link in dl.find_all('a'):
            url = link.get('href')
            if plat in url:
                fileURL = url
                break

        self.download_requests.append(DownloadItem(fileURL))
        self.start_download_and_install()
开发者ID:mbkulik,项目名称:umake-misc,代码行数:30,代码来源:misc.py


示例14: check_gpg_and_start_download

    def check_gpg_and_start_download(self, download_result):
        asc_content = download_result.pop(self.asc_url).buffer.getvalue().decode('utf-8')
        sig_url = list(download_result.keys())[0]
        res = download_result[sig_url]
        sig = res.buffer.getvalue().decode('utf-8').split()[0]

        # When we install new packages, we are executing as root and then dropping
        # as the user for extracting and such. However, for signature verification,
        # we use gpg. This one doesn't like priviledge drop (if uid = 0 and
        # euid = 1000) and asserts if uid != euid.
        # Importing the key as root as well creates new gnupg files owned as root if
        # new keys weren't imported first.
        # Consequently, run gpg as root if we needed root access or as the user
        # otherwise. We store the gpg public key in a temporary gnupg directory that
        # will be removed under the same user rights (this directory needs to be owned
        # by the same user id to not be rejected by gpg).Z
        if self.need_root_access:
            with as_root():
                with tempfile.TemporaryDirectory() as tmpdirname:
                    self._check_gpg_signature(tmpdirname, asc_content, sig)
        else:
            with tempfile.TemporaryDirectory() as tmpdirname:
                self._check_gpg_signature(tmpdirname, asc_content, sig)

        # you get and store self.download_url
        url = re.sub('.sig', '', sig_url)
        if url is None:
            logger.error("Download page changed its syntax or is not parsable (missing url)")
            UI.return_main_screen(status_code=1)
        logger.debug("Found download link for {}".format(url))
        self.download_requests.append(DownloadItem(url, None))
        self.start_download_and_install()
开发者ID:EdRondon,项目名称:ubuntu-make,代码行数:32,代码来源:swift.py


示例15: get_metadata_and_check_license

    def get_metadata_and_check_license(self, result):
        """Download files to download + license and check it"""
        logger.debug("Parse download metadata")

        error_msg = result[self.download_page].error
        if error_msg:
            logger.error("An error occurred while downloading {}: {}".format(self.download_page, error_msg))
            UI.return_main_screen(status_code=1)
        in_download = False
        sig_url = None
        for line in result[self.download_page].buffer:
            line_content = line.decode()
            (new_sig_url, in_download) = self.parse_download_link(line_content, in_download)
            if str(new_sig_url) > str(sig_url):
                # Avoid fetching development snapshots
                if 'DEVELOPMENT-SNAPSHOT' not in new_sig_url:
                    tmp_release = re.search("ubuntu(.....).tar", new_sig_url).group(1)
                    if tmp_release <= get_current_ubuntu_version():
                        sig_url = new_sig_url
        if not sig_url:
            logger.error("Download page changed its syntax or is not parsable")
            UI.return_main_screen(status_code=1)

        DownloadCenter(urls=[DownloadItem(sig_url, None), DownloadItem(self.asc_url, None)],
                       on_done=self.check_gpg_and_start_download, download=False)
开发者ID:ubuntu,项目名称:ubuntu-make,代码行数:25,代码来源:swift.py


示例16: post_install

    def post_install(self):
        """Add necessary environment variables"""
        add_env_to_user(self.name, {"NDK_ROOT": {"value": self.install_path, "keep": False}})

        # print wiki page message
        UI.display(DisplayMessage("NDK installed in {}. More information on how to use it on {}".format(
                                  self.install_path,
                                  "https://developer.android.com/tools/sdk/ndk/index.html#GetStarted")))
开发者ID:jravetch,项目名称:ubuntu-make,代码行数:8,代码来源:android.py


示例17: post_install

 def post_install(self):
     """Add nodejs necessary env variables and move module folder"""
     subprocess.call([os.path.join(self.install_path, "bin", "npm"), "config", "set", "prefix", "~/.node_modules"])
     add_env_to_user(self.name, {"PATH": {"value": "{}:{}".format(os.path.join(self.install_path, "bin"),
                                                                  os.path.join(os.path.expanduser('~'),
                                                                               ".node_modules", "bin"))}})
     UI.delayed_display(DisplayMessage(_("You need to restart your current shell session for your {} installation "
                                         "to work properly").format(self.name)))
开发者ID:EdRondon,项目名称:ubuntu-make,代码行数:8,代码来源:nodejs.py


示例18: setup

    def setup(self, arg_install_path=None):
        self.arg_install_path = arg_install_path
        super().setup()

        # first step, check if installed
        if self.is_installed:
            UI.display(YesNo("{} is already installed on your system, do you want to reinstall "
                             "it anyway?".format(self.name), self.reinstall, UI.return_main_screen))
        else:
            self.confirm_path(arg_install_path)
开发者ID:Ubuntu420,项目名称:ubuntu-make,代码行数:10,代码来源:baseinstaller.py


示例19: post_install

    def post_install(self):
        """Add nodejs necessary env variables and move module folder"""
        if not self.prefix_set():
            with open(os.path.join(os.environ['HOME'], '.npmrc'), 'a+') as file:
                file.write("prefix = ${HOME}/.npm_modules\n")

        add_env_to_user(self.name, {"PATH": {"value": "{}:{}".format(os.path.join(self.install_path, "bin"),
                                                                     os.path.join(os.path.expanduser('~'),
                                                                                  ".npm_modules", "bin"))}})
        UI.delayed_display(DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
开发者ID:ubuntu,项目名称:ubuntu-make,代码行数:10,代码来源:nodejs.py


示例20: test_call_display

    def test_call_display(self, mocksys):
        """We call the display method from the UIPlug"""
        UI.display(self.contentType)
        self.start_glib_mainloop()
        self.wait_for_mainloop_shutdown()

        self.assertTrue(self.mockUIPlug._display.called)
        self.assertIsNotNone(self.mainloop_thread)
        self.assertIsNotNone(self.display_thread)
        self.assertEqual(self.mainloop_thread, self.display_thread)
开发者ID:EdRondon,项目名称:ubuntu-make,代码行数:10,代码来源:test_ui.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap