Changeset 638be5f


Ignore:
Timestamp:
Mar 13, 2017, 9:20:38 PM (2 years ago)
Author:
Martin Hermant <martin.hermant@gmail.com>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, sampler
Children:
20a33fb
Parents:
d24b5c7
Message:

Version.py :

  • clean comments
  • use try catch instead of which
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Version.py

    rd24b5c7 r638be5f  
    11
    22import os
     3
     4
    35for l in open('VERSION').readlines(): exec (l.strip())
    46
    5 # def get_git_revision_hash( short=True):
    6 #     import os
    7 #     def which(program):
    8 #         def is_exe(fpath):
    9 #             return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
    10 
    11 #         fpath, fname = os.path.split(program)
    12 #         if fpath:
    13 #             if is_exe(program):
    14 #                 return program
    15 #         else:
    16 #             for path in os.environ["PATH"].split(os.pathsep):
    17 #                 path = path.strip('"')
    18 #                 exe_file = os.path.join(path, program)
    19 #                 if is_exe(exe_file):
    20 #                     return exe_file
    21 #         return None
    22 
    23 #     if not which('git') :
    24 #         # print('no git found on this system : can\'t get sha')
    25 #         return ""
    26 #     if not os.path.isdir('.git'):
    27 #         # print('Version : not in git repository : can\'t get sha')
    28 #         return ""
    29 
    30 #     import subprocess
    31 #     aubio_dir = os.path.abspath(os.curdir)
    32 #     if not os.path.exists(aubio_dir):
    33 #         raise SystemError("git / root folder not found")
    34 #     gitcmd = ['git','-C',aubio_dir ,'rev-parse']
    35 #     if short:
    36 #       gitcmd.append('--short')
    37 #     gitcmd.append('HEAD')
    38 #     outCmd = subprocess.check_output(gitcmd).strip().decode('utf8')
    39 #     return outCmd
    407
    418
     
    8552    spl = verstr.split('~')
    8653    if len(spl)==2:
    87         verstr = spl[0] + '+a1.'+spl[1]
     54        verstr = spl[0] + '+a0.'+spl[1]
    8855
    8956    # TODO: add rc, .dev, and .post suffixes, add numbering
     
    9360
    9461def get_git_revision_hash( short=True):
    95     def which(program):
    96    
    97         def is_exe(fpath):
    98             return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
    9962
    100         fpath, fname = os.path.split(program)
    101         if fpath:
    102             if is_exe(program):
    103                 return program
    104         else:
    105             for path in os.environ["PATH"].split(os.pathsep):
    106                 path = path.strip('"')
    107                 exe_file = os.path.join(path, program)
    108                 if is_exe(exe_file):
    109                     return exe_file
    110 
    111         return None
    112 
    113     if not which('git') :
    114         # print('no git found on this system : can\'t get sha')
    115         return ""
    11663    if not os.path.isdir('.git'):
    11764        # print('Version : not in git repository : can\'t get sha')
    118         return ""
     65        return None
    11966
    12067    import subprocess
     
    12673      gitcmd.append('--short')
    12774    gitcmd.append('HEAD')
    128     outCmd = subprocess.check_output(gitcmd).strip().decode('utf8')
     75    try:
     76      outCmd = subprocess.check_output(gitcmd).strip().decode('utf8')
     77    except Exception as e:
     78      print ('git command error :%s'%e)
     79      return None
    12980    return outCmd
    13081
Note: See TracChangeset for help on using the changeset viewer.