Skip to content

Commit 232c771

Browse files
Grahame Bowlandgraydon
authored andcommitted
python scripts run with Python 2.4 (for RHEL5)
1 parent a7a1523 commit 232c771

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/etc/get-snapshot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
import os, tarfile, hashlib, re, shutil, sys
3+
import os, tarfile, re, shutil, sys
44
from snapshot import *
55

66
def unpack_snapshot(triple, dl_path):

src/etc/snapshot.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import re, os, sys, glob, hashlib, tarfile, shutil, subprocess, tempfile
1+
import re, os, sys, glob, tarfile, shutil, subprocess, tempfile
2+
3+
try:
4+
import hashlib
5+
sha_func = hashlib.sha1
6+
except ImportError:
7+
import sha
8+
sha_func = sha.new
29

310
def scrub(b):
411
if sys.version_info >= (3,) and type(b) == bytes:
@@ -119,9 +126,8 @@ def local_rev_committer_date():
119126
def get_url_to_file(u,f):
120127
# no security issue, just to stop partial download leaving a stale file
121128
tmpf = f + '.tmp'
122-
try:
123-
subprocess.check_call(["curl", "-o", tmpf, u])
124-
except subprocess.CalledProcessError:
129+
returncode = subprocess.call(["curl", "-o", tmpf, u])
130+
if returncode != 0:
125131
os.unlink(tmpf)
126132
raise
127133
os.rename(tmpf, f)
@@ -133,7 +139,7 @@ def snap_filename_hash_part(snap):
133139
return match.group(1)
134140

135141
def hash_file(x):
136-
h = hashlib.sha1()
142+
h = sha_func()
137143
h.update(open(x, "rb").read())
138144
return scrub(h.hexdigest())
139145

0 commit comments

Comments
 (0)