Skip to content
__init__.py 1.59 KiB
Newer Older
Thibault VINCENT's avatar
Thibault VINCENT committed
# -*- coding: utf-8 -*-
#
#  Cloud-Control Node
#  Copyright (C) 2011 SmartJog [http://www.smartjog.com]
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#  Authors:
#    * 2011-06: Thibault VINCENT <thibault.vincent@smartjog.com>
#
__product__   = 'Cloud-Control Node'
__version__   = '0~dev'
__canonical__ = 'cc-node'
__develmode__ = False
def git_version():
    global __version__
    import os
    import sys
    from subprocess import Popen, PIPE, CalledProcessError
    cwd = os.getcwd()
    try:
        os.chdir(os.path.dirname(sys.argv[0]))
        p = Popen(["git", "log", "--pretty=format:%H" ], stdout=PIPE,
                                                stderr=open("/dev/null", "wb"))
        p.wait()
        if p.returncode == 0:
            githash = p.stdout.readline().strip()
            if len(githash) > 0:
                __version__ += "-git-%s" % githash
    except OSError:
        pass
    finally:
        os.chdir(cwd)
if __version__.find("dev") != -1:
    __develmode__ = True
    git_version()