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()
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
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):
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')
_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)
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):