fixed version detector to work with new github tar/zipballs
authorForrest Voight <forrest@forre.st>
Fri, 7 Dec 2012 07:48:30 +0000 (02:48 -0500)
committerForrest Voight <forrest@forre.st>
Fri, 7 Dec 2012 07:48:30 +0000 (02:48 -0500)
p2pool/__init__.py

index e8d488f..7459fa4 100644 (file)
@@ -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'),)