1 3
import os
2 3
import subprocess
3

4 3
import mopidy
5

6

7 3
def get_version():
8 3
    try:
9 3
        return get_git_version()
10 0
    except OSError:
11 0
        return mopidy.__version__
12

13

14 3
def get_git_version():
15 3
    project_dir = os.path.abspath(
16
        os.path.join(os.path.dirname(mopidy.__file__), "..")
17
    )
18 3
    process = subprocess.Popen(
19
        ["git", "describe"],
20
        stdout=subprocess.PIPE,
21
        stderr=subprocess.PIPE,
22
        cwd=project_dir,
23
    )
24 3
    if process.wait() != 0:
25 0
        raise OSError('Execution of "git describe" failed')
26 3
    version = process.stdout.read().strip().decode()
27 3
    if version.startswith("v"):
28 3
        version = version[1:]
29 3
    return version

Read our documentation on viewing source code .

Loading