本文整理汇总了Python中umake.ui.UI.return_main_screen方法的典型用法代码示例。如果您正苦于以下问题:Python UI.return_main_screen方法的具体用法?Python UI.return_main_screen怎么用?Python UI.return_main_screen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类umake.ui.UI
的用法示例。
在下文中一共展示了UI.return_main_screen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_metadata
# 需要导入模块: from umake.ui import UI [as 别名]
# 或者: from umake.ui.UI import return_main_screen [as 别名]
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)
示例2: get_metadata_and_check_license
# 需要导入模块: from umake.ui import UI [as 别名]
# 或者: from umake.ui.UI import return_main_screen [as 别名]
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)
示例3: get_metadata
# 需要导入模块: from umake.ui import UI [as 别名]
# 或者: from umake.ui.UI import return_main_screen [as 别名]
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()
示例4: get_metadata_and_check_license
# 需要导入模块: from umake.ui import UI [as 别名]
# 或者: from umake.ui.UI import return_main_screen [as 别名]
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)
示例5: download_provider_page
# 需要导入模块: from umake.ui import UI [as 别名]
# 或者: from umake.ui.UI import return_main_screen [as 别名]
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()
示例6: get_metadata_and_check_license
# 需要导入模块: from umake.ui import UI [as 别名]
# 或者: from umake.ui.UI import return_main_screen [as 别名]
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()
示例7: check_gpg_and_start_download
# 需要导入模块: from umake.ui import UI [as 别名]
# 或者: from umake.ui.UI import return_main_screen [as 别名]
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()
示例8: check_external_license
# 需要导入模块: from umake.ui import UI [as 别名]
# 或者: from umake.ui.UI import return_main_screen [as 别名]
def check_external_license(self, result):
"""Check external license which is in a separate page (can be factorized in BaseInstaller)"""
logger.debug("Parse license page")
error_msg = result[self.license_url].error
if error_msg:
logger.error("An error occurred while downloading {}: {}".format(self.license_url, error_msg))
UI.return_main_screen(status_code=1)
with StringIO() as license_txt:
in_license = False
for line in result[self.license_url].buffer:
line = line.decode()
if ('SOFTWARE LICENSE TERMS' in line):
in_license = True
if in_license and "<strong>* * *</strong>" in line:
in_license = False
continue
if in_license:
license_txt.write(line.strip() + "\n")
if license_txt.getvalue() != "":
logger.debug("Check license agreement.")
UI.display(LicenseAgreement(strip_tags(license_txt.getvalue()).strip(),
self.start_download_and_install,
UI.return_main_screen))
else:
logger.error("We were expecting to find a license, we didn't.")
UI.return_main_screen(status_code=1)
示例9: get_metadata_and_check_license
# 需要导入模块: from umake.ui import UI [as 别名]
# 或者: from umake.ui.UI import return_main_screen [as 别名]
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)
示例10: get_metadata_and_check_license
# 需要导入模块: from umake.ui import UI [as 别名]
# 或者: from umake.ui.UI import return_main_screen [as 别名]
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)
示例11: download_and_requirements_done
# 需要导入模块: from umake.ui import UI [as 别名]
# 或者: from umake.ui.UI import return_main_screen [as 别名]
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)
示例12: run_for
# 需要导入模块: from umake.ui import UI [as 别名]
# 或者: from umake.ui.UI import return_main_screen [as 别名]
def run_for(self, args):
"""Running commands from args namespace"""
# try to call default framework if any
if not args.framework:
if not self.default_framework:
message = "A default framework for category {} was requested where there is none".format(self.name)
logger.error(message)
UI.return_main_screen(status_code=1)
self.default_framework.run_for(args)
return
self.frameworks[args.framework].run_for(args)
示例13: _check_gpg_signature
# 需要导入模块: from umake.ui import UI [as 别名]
# 或者: from umake.ui.UI import return_main_screen [as 别名]
def _check_gpg_signature(self, gnupgdir, asc_content, sig):
"""check gpg signature (temporary stock in dir)"""
gpg = gnupg.GPG(gnupghome=gnupgdir)
imported_keys = gpg.import_keys(asc_content)
if imported_keys.count == 0:
logger.error("Keys not valid")
UI.return_main_screen(status_code=1)
verify = gpg.verify(sig)
if verify is False:
logger.error("Signature not valid")
UI.return_main_screen(status_code=1)
示例14: post_install
# 需要导入模块: from umake.ui import UI [as 别名]
# 或者: from umake.ui.UI import return_main_screen [as 别名]
def post_install(self):
"""Create the Unity 3D launcher and setuid chrome sandbox"""
with futures.ProcessPoolExecutor(max_workers=1) as executor:
# chrome sandbox requires this: https//code.google.com/p/chromium/wiki/LinuxSUIDSandbox
f = executor.submit(_chrome_sandbox_setuid, os.path.join(self.install_path, "Editor", "chrome-sandbox"))
if not f.result():
UI.return_main_screen(exit_status=1)
create_launcher(self.desktop_filename, get_application_desktop_file(name=_("Unity3D Editor"),
icon_path=os.path.join(self.install_path, "unity-editor-icon.png"),
exec=os.path.join(self.install_path, "Editor", "Unity"),
comment=self.description,
categories="Development;IDE;"))
示例15: decompress_and_install
# 需要导入模块: from umake.ui import UI [as 别名]
# 或者: from umake.ui.UI import return_main_screen [as 别名]
def decompress_and_install(self, fd):
UI.display(DisplayMessage("Installing {}".format(self.name)))
shutil.copyfile(fd.name, self.install_path + '/drjava.jar')
self.post_install()
# Mark as installation done in configuration
self.mark_in_config()
UI.delayed_display(DisplayMessage("Installation done"))
UI.return_main_screen()