本文整理汇总了Python中platformio.pkgmanager.PackageManager类的典型用法代码示例。如果您正苦于以下问题:Python PackageManager类的具体用法?Python PackageManager怎么用?Python PackageManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PackageManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: install
def install(self, with_packages=None, without_packages=None,
skip_default_packages=False):
with_packages = set(
self.pkg_aliases_to_names(with_packages or []))
without_packages = set(
self.pkg_aliases_to_names(without_packages or []))
upkgs = with_packages | without_packages
ppkgs = set(self.get_packages().keys())
if not upkgs.issubset(ppkgs):
raise exception.UnknownPackage(", ".join(upkgs - ppkgs))
requirements = []
for name, opts in self.get_packages().items():
if name in without_packages:
continue
elif (name in with_packages or (not skip_default_packages and
opts.get("default"))):
requirements.append(name)
pm = PackageManager()
for name in requirements:
pm.install(name)
# register installed platform
data = get_state_item("installed_platforms", [])
if self.get_type() not in data:
data.append(self.get_type())
set_state_item("installed_platforms", data)
return len(requirements)
示例2: uninstall
def uninstall(self):
platform = self.get_type()
installed_platforms = PlatformFactory.get_platforms(
installed=True).keys()
if platform not in installed_platforms:
raise exception.PlatformNotInstalledYet(platform)
deppkgs = set()
for item in installed_platforms:
if item == platform:
continue
p = PlatformFactory.newPlatform(item)
deppkgs = deppkgs.union(set(p.get_packages().keys()))
pm = PackageManager()
for name in self.get_packages().keys():
if not pm.is_installed(name) or name in deppkgs:
continue
pm.uninstall(name)
# unregister installed platform
installed_platforms.remove(platform)
set_state_item("installed_platforms", installed_platforms)
return True
示例3: platforms_show
def platforms_show(ctx, platform):
installed_platforms = PlatformFactory.get_platforms(
installed=True).keys()
if platform not in installed_platforms:
if (not app.get_setting("enable_prompts") or
click.confirm("The platform '%s' has not been installed yet. "
"Would you like to install it now?" % platform)):
ctx.invoke(platforms_install, platforms=[platform])
else:
raise PlatformNotInstalledYet(platform)
p = PlatformFactory.newPlatform(platform)
click.echo("{name:<20} - {description} [ {url} ]".format(
name=click.style(p.get_type(), fg="cyan"),
description=p.get_description(), url=p.get_vendor_url()))
installed_packages = PackageManager.get_installed()
for name in p.get_installed_packages():
data = installed_packages[name]
pkgalias = p.get_pkg_alias(name)
click.echo("----------")
click.echo("Package: %s" % click.style(name, fg="yellow"))
if pkgalias:
click.echo("Alias: %s" % pkgalias)
click.echo("Version: %d" % int(data['version']))
click.echo("Installed: %s" % datetime.fromtimestamp(
data['time']).strftime("%Y-%m-%d %H:%M:%S"))
示例4: cli
def cli():
for platform in PackageManager.get_installed().keys():
echo("\nPlatform %s" % style(platform, fg="cyan"))
echo("--------")
p = PlatformFactory().newPlatform(platform)
p.update()
示例5: cli
def cli():
for name, pkgs in PackageManager.get_installed().items():
echo("{name:<20} with packages: {pkgs}".format(
name=style(name, fg="cyan"),
pkgs=", ".join(pkgs.keys())
))
示例6: run
def run(self, variables, targets, verbose):
assert isinstance(variables, dict)
assert isinstance(targets, list)
self.configure_default_packages(variables, targets)
self._install_default_packages()
self._verbose_level = int(verbose)
if "clean" in targets:
targets.remove("clean")
targets.append("-c")
if "build_script" not in variables:
variables['build_script'] = self.get_build_script()
if not isfile(variables['build_script']):
raise exception.BuildScriptNotFound(variables['build_script'])
# append aliases of the installed packages
installed_packages = PackageManager.get_installed()
for name, options in self.get_packages().items():
if "alias" not in options or name not in installed_packages:
continue
variables['piopackage_%s' % options['alias']] = name
self._found_error = False
result = self._run_scons(variables, targets)
assert "returncode" in result
# if self._found_error:
# result['returncode'] = 1
if self._last_echo_line == ".":
click.echo("")
return result
示例7: run
def run(self, variables, targets, verbose):
assert isinstance(variables, list)
assert isinstance(targets, list)
self._verbose_level = int(verbose)
installed_platforms = PlatformFactory.get_platforms(
installed=True).keys()
installed_packages = PackageManager.get_installed()
if self.get_type() not in installed_platforms:
raise exception.PlatformNotInstalledYet(self.get_type())
if "clean" in targets:
targets.remove("clean")
targets.append("-c")
if not any([v.startswith("BUILD_SCRIPT=") for v in variables]):
variables.append("BUILD_SCRIPT=%s" % self.get_build_script())
for v in variables:
if not v.startswith("BUILD_SCRIPT="):
continue
_, path = v.split("=", 2)
if not isfile(path):
raise exception.BuildScriptNotFound(path)
# append aliases of the installed packages
for name, options in self.get_packages().items():
if "alias" not in options or name not in installed_packages:
continue
variables.append(
"PIOPACKAGE_%s=%s" % (options['alias'].upper(), name))
self._found_error = False
try:
# test that SCons is installed correctly
assert util.test_scons()
result = util.exec_command(
[
"scons",
"-Q",
"-f", join(util.get_source_dir(), "builder", "main.py")
] + variables + targets,
stdout=util.AsyncPipe(self.on_run_out),
stderr=util.AsyncPipe(self.on_run_err)
)
except (OSError, AssertionError):
raise exception.SConsNotInstalledError()
assert "returncode" in result
# if self._found_error:
# result['returncode'] = 1
if self._last_echo_line == ".":
click.echo("")
return result
示例8: cli
def cli(platforms):
for platform in platforms:
if platform not in PackageManager.get_installed():
raise PlatformNotInstalledYet(platform)
p = PlatformFactory().newPlatform(platform)
if p.uninstall():
secho("The platform '%s' has been successfully "
"uninstalled!" % platform, fg="green")
示例9: uninstall
def uninstall(self):
platform = self.get_name()
pm = PackageManager(platform)
for package, data in pm.get_installed(platform).items():
pm.uninstall(package, data['path'])
pm.unregister_platform(platform)
rmtree(pm.get_platform_dir())
return True
示例10: install
def install(self, with_packages, without_packages, skip_default_packages):
with_packages = set(self.pkg_aliases_to_names(with_packages))
without_packages = set(self.pkg_aliases_to_names(without_packages))
upkgs = with_packages | without_packages
ppkgs = set(self.PACKAGES.keys())
if not upkgs.issubset(ppkgs):
raise UnknownPackage(", ".join(upkgs - ppkgs))
requirements = []
for name, opts in self.PACKAGES.items():
if name in without_packages:
continue
elif (name in with_packages or (not skip_default_packages and
opts['default'])):
requirements.append((name, opts['path']))
pm = PackageManager(self.get_name())
for (package, path) in requirements:
pm.install(package, path)
return len(requirements)
示例11: run
def run(self, variables, targets, verbose):
assert isinstance(variables, list)
assert isinstance(targets, list)
envoptions = {}
for v in variables:
_name, _value = v.split("=", 1)
envoptions[_name.lower()] = _value
self.configure_default_packages(envoptions, targets)
self._install_default_packages()
self._verbose_level = int(verbose)
if "clean" in targets:
targets.remove("clean")
targets.append("-c")
if "build_script" not in envoptions:
variables.append("BUILD_SCRIPT=%s" % self.get_build_script())
for v in variables:
if not v.startswith("BUILD_SCRIPT="):
continue
_, path = v.split("=", 1)
if not isfile(path):
raise exception.BuildScriptNotFound(path)
# append aliases of the installed packages
installed_packages = PackageManager.get_installed()
for name, options in self.get_packages().items():
if "alias" not in options or name not in installed_packages:
continue
variables.append(
"PIOPACKAGE_%s=%s" % (options['alias'].upper(), name))
self._found_error = False
result = self._run_scons(variables, targets)
assert "returncode" in result
# if self._found_error:
# result['returncode'] = 1
if self._last_echo_line == ".":
click.echo("")
return result
示例12: run
def run(self, variables, targets, verbose):
assert isinstance(variables, list)
assert isinstance(targets, list)
envoptions = {}
for v in variables:
_name, _value = v.split("=", 1)
envoptions[_name.lower()] = _value
self.configure_default_packages(envoptions, targets)
self._install_default_packages()
self._verbose_level = int(verbose)
if "clean" in targets:
targets.remove("clean")
targets.append("-c")
if "build_script" not in envoptions:
variables.append("BUILD_SCRIPT=%s" % self.get_build_script())
for v in variables:
if not v.startswith("BUILD_SCRIPT="):
continue
_, path = v.split("=", 1)
if not isfile(path):
raise exception.BuildScriptNotFound(path)
# append aliases of the installed packages
installed_packages = PackageManager.get_installed()
for name, options in self.get_packages().items():
if "alias" not in options or name not in installed_packages:
continue
variables.append(
"PIOPACKAGE_%s=%s" % (options['alias'].upper(), name))
self._found_error = False
try:
# test that SCons is installed correctly
assert util.test_scons()
result = util.exec_command(
[
"scons",
"-Q",
"-j %d" % self.get_job_nums(),
"--warn=no-no-parallel-support",
"-f", join(util.get_source_dir(), "builder", "main.py")
] + variables + targets,
stdout=util.AsyncPipe(self.on_run_out),
stderr=util.AsyncPipe(self.on_run_err)
)
except (OSError, AssertionError):
raise exception.SConsNotInstalledError()
assert "returncode" in result
# if self._found_error:
# result['returncode'] = 1
if self._last_echo_line == ".":
click.echo("")
return result
示例13: is_outdated
def is_outdated(self):
pm = PackageManager()
obsolated = pm.get_outdated()
return not set(self.get_packages().keys()).isdisjoint(set(obsolated))
示例14: update
def update(self):
pm = PackageManager()
for name in self.get_installed_packages():
pm.update(name)
示例15: update
def update(self):
platform = self.get_name()
pm = PackageManager(platform)
for package in pm.get_installed(platform).keys():
pm.update(package)