refactor "--version" to use "pathlib" instead of "os"

This commit is contained in:
Joe Schr 2023-01-12 19:27:41 +01:00
parent 08748dd021
commit 1cf69f139c

View File

@ -2,10 +2,10 @@
__version__ = '2023.1.dev'
if 'dev' in __version__:
from pathlib import Path
try:
import os
import subprocess
freqtrade_basedir = os.path.dirname(os.path.abspath(__file__))
freqtrade_basedir = Path(__file__).parent
__version__ = __version__ + '-' + subprocess.check_output(
['git', 'log', '--format="%h"', '-n 1'],
@ -15,7 +15,6 @@ if 'dev' in __version__:
# git not available, ignore
try:
# Try Fallback to freqtrade_commit file (created by CI while building docker image)
from pathlib import Path
versionfile = Path('./freqtrade_commit')
if versionfile.is_file():
__version__ = f"docker-{__version__}-{versionfile.read_text()[:8]}"