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__)
- 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):
if not platform.startswith('win'):
from os import ttyname # here because it doesn't work on windows
import sys
- with open(ttyname(0), 'w') as fout:
- sys.stdout = fout
- print('version: ' + self.build_version) # self.eng.logic.version)
+ try:
+ with open(ttyname(0), 'w') as fout:
+ sys.stdout = fout
+ print('version: ' + self.build_version) # self.eng.logic.version)
+ except OSError: # it doesn't work with crontab
+ print('version: ' + self.build_version)
messages = ['version: ' + self.build_version] # self.eng.logic.version]
messages += ['argv[0]: %s' % argv[0]]
messages += ['getcwd: %s' % getcwd()]