From: Forrest Voight Date: Fri, 7 Dec 2012 07:48:30 +0000 (-0500) Subject: fixed version detector to work with new github tar/zipballs X-Git-Tag: 10.0~24 X-Git-Url: https://git.novaco.in/?p=p2pool.git;a=commitdiff_plain;h=f2bfc05171afdf4c3df548d15da76ee7e0df87f6 fixed version detector to work with new github tar/zipballs --- diff --git a/p2pool/__init__.py b/p2pool/__init__.py index e8d488f..7459fa4 100644 --- a/p2pool/__init__.py +++ b/p2pool/__init__.py @@ -1,4 +1,5 @@ import os +import re import sys import traceback import subprocess @@ -21,6 +22,7 @@ def _get_version(): return check_output(['git.cmd', 'describe', '--always', '--dirty'], cwd=os.path.dirname(os.path.abspath(sys.argv[0]))).strip() except: pass + root_dir = os.path.abspath(os.path.dirname(sys.argv[0])) git_dir = os.path.join(root_dir, '.git') if os.path.exists(git_dir): @@ -31,11 +33,13 @@ def _get_version(): return open(os.path.join(git_dir, *path)).read().strip()[:7] else: return head[:7] + dir_name = os.path.split(root_dir)[1] - chars = '0123456789abcdef' - if len(dir_name) >= 7 and (len(dir_name) == 7 or dir_name[-8] not in chars) and all(c in chars for c in dir_name[-7:]): - return dir_name[-7:] - return 'unknown' + match = re.match('p2pool-([.0-9]+)', dir_name) + if match: + return match.groups()[0] + + return 'unknown %s' % (dir_name.encode('hex'),) except Exception, e: traceback.print_exc() return 'unknown %s' % (str(e).encode('hex'),)