From b3f0b6175ad62499d72443d139aa75b82d5e16e7 Mon Sep 17 00:00:00 2001 From: tianyu Date: Fri, 28 Aug 2015 10:05:31 +0800 Subject: [PATCH] Update cm.py --- net/cm/cm.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/net/cm/cm.py b/net/cm/cm.py index dc2ae77..98cac0b 100644 --- a/net/cm/cm.py +++ b/net/cm/cm.py @@ -86,14 +86,14 @@ while True: parent = link.parent if isinstance(parent, Tag): sha1 = parent.find('small', class_='md5') - sha1 = sha1.text.splitlines()[1].strip().replace('sha1: ', '') + sha1 = sha1.text.replace('\n', '').strip().replace('sha1: ', '') cmFile.sha1 = sha1 s = json.JSONDecoder().decode(cmFile.json()) if s in cmFiles: print("downloaded, skip") else: - while int(check_output('ps -ef | grep /root/bypy/bypy.py |grep -v grep |wc -l', shell=True)) > 5: + while int(check_output('ps -ef | grep /root/bypy/bypy.py |grep -v grep |wc -l', shell=True)) >= 3: print("wait other jobs done...") time.sleep(3) @@ -116,7 +116,7 @@ while True: call("mkdir -p {}{}".format(download_dir, device), shell=True) - call("wget --progress=dot:binary \"{}\" -O \"{}\" -o \"{}.wget.log\"". + call("wget --limit-rate=3000k --progress=dot:binary \"{}\" -O \"{}\" -o \"{}.wget.log\"". format(cmFile.url, out_file, out_file), shell=True) if sha1_file(out_file) == cmFile.sha1: @@ -131,6 +131,7 @@ while True: Popen("./cm.sh {}{} {}.sha1 {}".format(download_dir, device, filename, device), shell=True) Popen("./cm.sh {}{} {}.wget.log {}".format(download_dir, device, filename, device), shell=True) else: + print("sha1 not match, continue") continue cmFiles_dict["count"] = count @@ -141,3 +142,4 @@ while True: time.sleep(60) print("job finished, restart now") +