diff options
author | Martin Robinson <mrobinson@igalia.com> | 2023-05-20 18:22:07 +0200 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2023-05-20 18:23:46 +0200 |
commit | 3875debfbfd5b335285a70780aa1aa3a775bb02a (patch) | |
tree | 1ace5e07a4a7e13744b92a061f07aa445fd2f477 /python | |
parent | 4998c65c423f995149f4b314d8ff68024c24cc72 (diff) | |
download | servo-3875debfbfd5b335285a70780aa1aa3a775bb02a.tar.gz servo-3875debfbfd5b335285a70780aa1aa3a775bb02a.zip |
Remove some unused python code
This change removes:
- The custom `--dry-run` support for `cargo-update`. The real cargo
command now has `--dry-run` support and this code was broken for
Python 3.
- The Python 2 version of TemporaryDirectory. This is no longer needed
as we require Python 3.
Diffstat (limited to 'python')
-rw-r--r-- | python/servo/devenv_commands.py | 65 | ||||
-rw-r--r-- | python/servo/package_commands.py | 20 |
2 files changed, 9 insertions, 76 deletions
diff --git a/python/servo/devenv_commands.py b/python/servo/devenv_commands.py index 7d3481d1c19..4385fbb8794 100644 --- a/python/servo/devenv_commands.py +++ b/python/servo/devenv_commands.py @@ -10,7 +10,6 @@ from __future__ import print_function, unicode_literals from os import path, listdir, getcwd -import json import signal import subprocess import sys @@ -96,67 +95,19 @@ class MachCommands(CommandBase): if not params: params = [] - if dry_run: - import toml - import httplib - import colorama - - cargo_file = open(path.join(self.context.topdir, "Cargo.lock")) - content = toml.load(cargo_file) - - packages = {} - outdated_packages = 0 - conn = httplib.HTTPSConnection("crates.io") - for package in content.get("package", []): - if "replace" in package: - continue - source = package.get("source", "") - if source == r"registry+https://github.com/rust-lang/crates.io-index": - version = package["version"] - name = package["name"] - if not packages.get(name, "") or packages[name] > version: - packages[name] = package["version"] - conn.request('GET', '/api/v1/crates/{}/versions'.format(package["name"])) - r = conn.getresponse() - json_content = json.load(r) - for v in json_content.get("versions"): - if not v.get("yanked"): - max_version = v.get("num") - break - - if version != max_version: - outdated_packages += 1 - version_major, version_minor = (version.split("."))[:2] - max_major, max_minor = (max_version.split("."))[:2] - - if version_major == max_major and version_minor == max_minor and "alpha" not in version: - msg = "minor update" - msg_color = "\033[93m" - else: - msg = "update, which may contain breaking changes" - msg_color = "\033[91m" - - colorama.init() - print("{}Outdated package `{}`, available {}\033[0m".format(msg_color, name, msg), - "\n\tCurrent version: {}".format(version), - "\n\t Latest version: {}".format(max_version)) - conn.close() - - print("\nFound {} outdated packages from crates.io".format(outdated_packages)) - elif package: - params += ["-p", package] - elif all_packages: - params = [] - else: + if not package and not all_packages: print("Please choose package to update with the --package (-p) ") print("flag or update all packages with --all-packages (-a) flag") sys.exit(1) - if params or all_packages: - self.ensure_bootstrapped() + if package: + params += ["-p", package] + if dry_run: + params.append("--dry-run") - with cd(self.context.topdir): - self.call_rustup_run(["cargo", "update"] + params, env=self.build_env()) + self.ensure_bootstrapped() + with cd(self.context.topdir): + self.call_rustup_run(["cargo", "update"] + params, env=self.build_env()) @Command('rustc', description='Run the Rust compiler', diff --git a/python/servo/package_commands.py b/python/servo/package_commands.py index 1f4e87f9830..1488eadbd3e 100644 --- a/python/servo/package_commands.py +++ b/python/servo/package_commands.py @@ -82,24 +82,6 @@ PACKAGES = { } -TemporaryDirectory = None -if sys.version_info >= (3, 2): - TemporaryDirectory = tempfile.TemporaryDirectory -else: - import contextlib - - # Not quite as robust as tempfile.TemporaryDirectory, - # but good enough for most purposes - @contextlib.contextmanager - def TemporaryDirectory(**kwargs): - dir_name = tempfile.mkdtemp(**kwargs) - try: - yield dir_name - except Exception as e: - shutil.rmtree(dir_name) - raise e - - def listfiles(directory): return [f for f in os.listdir(directory) if path.isfile(path.join(directory, f))] @@ -683,7 +665,7 @@ class PackageCommands(CommandBase): brew_version = timestamp.strftime('%Y.%m.%d') - with TemporaryDirectory(prefix='homebrew-servo') as tmp_dir: + with tempfile.TemporaryDirectory(prefix='homebrew-servo') as tmp_dir: def call_git(cmd, **kwargs): subprocess.check_call( ['git', '-C', tmp_dir] + cmd, |