From: Flavio Calva Date: Wed, 18 May 2022 18:58:04 +0000 (+0100) Subject: fixed version X-Git-Url: http://git.ya2.it/?p=pmachines.git;a=commitdiff_plain;h=dd32d640a4ac923b2ae399cc161f8bf8ae9a915c fixed version --- diff --git a/game/app.py b/game/app.py index 88c9216..057a680 100755 --- a/game/app.py +++ b/game/app.py @@ -198,12 +198,14 @@ class PmachinesApp: if res: res = LVector2i(*[int(_res) for _res in res.split('x')]) else: - d_i = base.pipe.get_display_information() - def _res(idx): - return d_i.get_display_mode_width(idx), \ - d_i.get_display_mode_height(idx) - resolutions = [ - _res(idx) for idx in range(d_i.get_total_display_modes())] + resolutions = [] + if not self.version: + d_i = base.pipe.get_display_information() + def _res(idx): + return d_i.get_display_mode_width(idx), \ + d_i.get_display_mode_height(idx) + resolutions = [ + _res(idx) for idx in range(d_i.get_total_display_modes())] res = sorted(resolutions)[-1] fullscreen = self._options['settings']['fullscreen'] props = WindowProperties() diff --git a/lib/build/build.py b/lib/build/build.py index d424c79..9fdd8cb 100644 --- a/lib/build/build.py +++ b/lib/build/build.py @@ -2,6 +2,7 @@ from os import walk, chdir, getcwd from os.path import join, getsize, exists, dirname, getmtime, sep from subprocess import Popen, PIPE, run +from logging import debug from time import strftime from pathlib import Path from hashlib import md5 @@ -21,8 +22,10 @@ def exec_cmd(cmd): def _branch(): '''Returns the current branch.''' git_branch = exec_cmd('git symbolic-ref HEAD').split('/')[-1].strip() + print('git_branch result: %s' % git_branch) branches = ['master', 'rc', 'stable'] if git_branch in branches: + print('git_branch: %s' % git_branch) return git_branch root = str(Path(dirname(dirname(__file__))).parent) + '/' if 'itch' in __file__.split(sep): @@ -31,14 +34,39 @@ def _branch(): root = '/app/bin/' for branch in branches: try: + print('try: %s' % root + 'assets/bld_version.txt') with open(root + 'assets/bld_version.txt') as fver: ver = fver.read() - if branch in ver: + print('ver: %s' % ver) + #if branch in ver: + b2c = {'master': 'a', 'rc': 'r', 'stable': '.'} + if ver[1] == b2c[branch]: return branch except FileNotFoundError: print('file not found: %s' % root + 'assets/bld_version.txt') +def _commit(): + '''Returns the current branch.''' + git_commit = exec_cmd('git rev-parse HEAD')[:7] + print('git_commit result: %s' % git_commit) + if not git_commit.startswith("Can't r"): + return git_commit + root = str(Path(dirname(dirname(__file__))).parent) + '/' + if 'itch' in __file__.split(sep): + root = str(Path(dirname(__file__))) + '/' + if __file__ == '/app/bin/pmachines': # flatpak + root = '/app/bin/' + try: + print('try: %s' % root + 'assets/bld_version.txt') + with open(root + 'assets/bld_version.txt') as fver: + ver = fver.read() + print('ver: %s' % ver) + return ver.split('-')[1] + except FileNotFoundError: + print('file not found: %s' % root + 'assets/bld_version.txt') + + def _version(): '''Computes the version of the current build.''' day = strftime('%y%m%d') @@ -53,13 +81,13 @@ def _version(): _ver = fver.read().strip() ret_ver = _ver or ('0.' + day) else: - try: - pref = {'master': 'a', 'rc': 'rc', '': 'runtime'}[_branch()] - except KeyError: - pref = 'notfound' + #try: we want an error! + pref = {'master': 'a', 'rc': 'rc', '': 'runtime'}[_branch()] + #except KeyError: + # pref = 'notfound' ret_ver = '0%s%s' % (pref, day) pref = ret_ver - bld_ver = pref + '-' + exec_cmd('git rev-parse HEAD')[:7] + bld_ver = pref + '-' + _commit() try: with open(root + 'assets/bld_version.txt', 'w') as fver: fver.write(bld_ver) diff --git a/lib/engine/log.py b/lib/engine/log.py index ac4920e..13f104c 100755 --- a/lib/engine/log.py +++ b/lib/engine/log.py @@ -61,38 +61,51 @@ class LogMgrBase(Colleague): # headless log manager is_appimage = par_path.startswith('/tmp/.mount_Pmachi') return is_appimage and par_path.endswith('/usr/bin') + # @property + # def curr_path(self): + # # this is different from the music's one since it does not work + # # with the version in windows + # if sys.platform == 'darwin': + # return dirname(__file__) + '/../Resources/' + # # return dirname(__file__) + # par_path = str(Path(__file__).parent.absolute()) + # if self.is_appimage: + # return str(Path(par_path).absolute()) + # is_snap = par_path.startswith('/snap/') + # is_snap = is_snap and par_path.endswith('/x1') + # if is_snap: + # return str(Path(par_path).absolute()) + # #return getcwd() + # #curr_path = dirname(__file__) + # curr_path = str(Path(__file__).parent.parent.parent.absolute()) + # info('current path: %s' % curr_path) + # return curr_path + @property def curr_path(self): - # this is different from the music's one since it does not work - # with the version in windows - if sys.platform == 'darwin': - return dirname(__file__) + '/../Resources/' - # return dirname(__file__) - par_path = str(Path(__file__).parent.absolute()) + if system() == 'Windows': + return '' + if exists('main.py'): + return '' + else: + par_path = str(Path(__file__).parent.absolute()) if self.is_appimage: - return str(Path(par_path).absolute()) - is_snap = par_path.startswith('/snap/') - is_snap = is_snap and par_path.endswith('/x1') - if is_snap: - return str(Path(par_path).absolute()) - #return getcwd() - #curr_path = dirname(__file__) - curr_path = str(Path(__file__).parent.parent.parent.absolute()) - info('current path: %s' % curr_path) - return curr_path + par_path = str(Path(par_path).absolute()) + par_path += '/' + return par_path @property def build_version(self): appimg_mnt = glob('/tmp/.mount_Pmachi*') if appimg_mnt: #with open(appimg_mnt[0] + '/usr/bin/appimage_version.txt') as fver: - with open(self.curr_path + '/assets/bld_version.txt') as fver: + with open(self.curr_path + 'assets/bld_version.txt') as fver: return fver.read().strip() try: - with open(self.curr_path + '/assets/bld_version.txt') as fver: + with open(self.curr_path + 'assets/bld_version.txt') as fver: return fver.read().strip() except FileNotFoundError: - info('not found ' + self.curr_path + '/assets/bld_version.txt') + info('not found ' + self.curr_path + 'assets/bld_version.txt') return 'notfound' def log_cfg(self):