Skip to content

Commit

Permalink
python scripts run with Python 2.4 (for RHEL5)
Browse files Browse the repository at this point in the history
  • Loading branch information
Grahame Bowland authored and graydon committed Mar 28, 2012
1 parent a7a1523 commit 232c771
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/etc/get-snapshot.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python

import os, tarfile, hashlib, re, shutil, sys
import os, tarfile, re, shutil, sys
from snapshot import *

def unpack_snapshot(triple, dl_path):
Expand Down
16 changes: 11 additions & 5 deletions src/etc/snapshot.py
@@ -1,4 +1,11 @@
import re, os, sys, glob, hashlib, tarfile, shutil, subprocess, tempfile
import re, os, sys, glob, tarfile, shutil, subprocess, tempfile

try:
import hashlib
sha_func = hashlib.sha1
except ImportError:
import sha
sha_func = sha.new

def scrub(b):
if sys.version_info >= (3,) and type(b) == bytes:
Expand Down Expand Up @@ -119,9 +126,8 @@ def local_rev_committer_date():
def get_url_to_file(u,f):
# no security issue, just to stop partial download leaving a stale file
tmpf = f + '.tmp'
try:
subprocess.check_call(["curl", "-o", tmpf, u])
except subprocess.CalledProcessError:
returncode = subprocess.call(["curl", "-o", tmpf, u])
if returncode != 0:
os.unlink(tmpf)
raise
os.rename(tmpf, f)
Expand All @@ -133,7 +139,7 @@ def snap_filename_hash_part(snap):
return match.group(1)

def hash_file(x):
h = hashlib.sha1()
h = sha_func()
h.update(open(x, "rb").read())
return scrub(h.hexdigest())

Expand Down

0 comments on commit 232c771

Please sign in to comment.