diff options
| author | bors <bors@rust-lang.org> | 2016-05-31 21:37:42 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-05-31 21:37:42 -0700 |
| commit | 433d70cda2e6d61d5bbb20423f0937a643cf34b4 (patch) | |
| tree | a9d80726d917b5d33bc37453ccd1278a0fb0d201 /src | |
| parent | ad5fbaf57c1f763935175cd217fedfc551d91aac (diff) | |
| parent | a422b7e4ed8bc8a05777eced718156f47eaa861b (diff) | |
| download | rust-433d70cda2e6d61d5bbb20423f0937a643cf34b4.tar.gz rust-433d70cda2e6d61d5bbb20423f0937a643cf34b4.zip | |
Auto merge of #33141 - tshepang:python-love, r=brson
some Python nits and fixes
Diffstat (limited to 'src')
| -rw-r--r-- | src/bootstrap/bootstrap.py | 22 | ||||
| -rw-r--r-- | src/etc/get-stage0.py | 12 |
2 files changed, 15 insertions, 19 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 0ab5253ee72..d69d4b96249 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -108,14 +108,15 @@ def run(args, verbose=False): def stage0_data(rust_root): nightlies = os.path.join(rust_root, "src/stage0.txt") + data = {} with open(nightlies, 'r') as nightlies: - data = {} - for line in nightlies.read().split("\n"): + for line in nightlies: + line = line.rstrip() # Strip newline character, '\n' if line.startswith("#") or line == '': continue a, b = line.split(": ", 1) data[a] = b - return data + return data class RustBuild: def download_stage0(self): @@ -246,7 +247,7 @@ class RustBuild: env) def run(self, args, env): - proc = subprocess.Popen(args, env = env) + proc = subprocess.Popen(args, env=env) ret = proc.wait() if ret != 0: sys.exit(ret) @@ -261,20 +262,19 @@ class RustBuild: try: ostype = subprocess.check_output(['uname', '-s']).strip() cputype = subprocess.check_output(['uname', '-m']).strip() - except FileNotFoundError: + except subprocess.CalledProcessError: if sys.platform == 'win32': return 'x86_64-pc-windows-msvc' - else: - err = "uname not found" - if self.verbose: - raise Exception(err) - sys.exit(err) + err = "uname not found" + if self.verbose: + raise Exception(err) + sys.exit(err) # Darwin's `uname -s` lies and always returns i386. We have to use # sysctl instead. if ostype == 'Darwin' and cputype == 'i686': sysctl = subprocess.check_output(['sysctl', 'hw.optional.x86_64']) - if sysctl.contains(': 1'): + if ': 1' in sysctl: cputype = 'x86_64' # The goal here is to come up with the same triple as LLVM would, diff --git a/src/etc/get-stage0.py b/src/etc/get-stage0.py index 22ec624e4f5..28e3363189a 100644 --- a/src/etc/get-stage0.py +++ b/src/etc/get-stage0.py @@ -11,18 +11,15 @@ # except according to those terms. import os -import shutil import sys -import tarfile path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../bootstrap")) sys.path.append(path) import bootstrap -def main(argv): +def main(triple): src_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")) - triple = argv[1] data = bootstrap.stage0_data(src_root) channel, date = data['rustc'].split('-', 1) @@ -31,9 +28,8 @@ def main(argv): if not os.path.exists(dl_dir): os.makedirs(dl_dir) - filename_base = 'rustc-' + channel + '-' + triple - filename = filename_base + '.tar.gz' - url = 'https://static.rust-lang.org/dist/' + date + '/' + filename + filename = 'rustc-{}-{}.tar.gz'.format(channel, triple) + url = 'https://static.rust-lang.org/dist/{}/{}'.format(date, filename) dst = dl_dir + '/' + filename if os.path.exists(dst): os.unlink(dst) @@ -49,4 +45,4 @@ def main(argv): bootstrap.unpack(dst, stage0_dst, match='rustc', verbose=True) if __name__ == '__main__': - main(sys.argv) + main(sys.argv[1]) |
