/usr/bin/pytr is in pytrainer 1.11.0-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | #!/usr/bin/python
# -*- coding: iso-8859-1 -*-
#Copyright (C) Fiz Vazquez vud1@sindominio.net
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import sys
import os
import glob
import commands
import platform
def _max(one, two):
'''Function to determine the max of two versions of format /xx/xxx/????-1.2.3 '''
if one is None:
return two
elif two is None:
return one
try:
one_v = os.path.basename(one).split('-')[1]
two_v = os.path.basename(two).split('-')[1]
except IndexError:
#Got format that doesnt fit what we expect
#Do simple comparison
if os.path.basename(one) > os.path.basename(two):
return one
else:
return two
one_v_nos = one_v.split('.')
two_v_nos = two_v.split('.')
for index, no in enumerate(one_v_nos):
if index >= len(two_v_nos):
return one
elif no > two_v_nos[index]:
return one
elif no < two_v_nos[index]:
return two
else:
pass
if len(one_v_nos) >= len(two_v_nos):
return one
return two
bin_path = os.path.realpath(os.path.dirname(__file__)) # directory that the pytrainer script executes from e.g. /usr/bin or /usr/local/bin
base_path = os.path.dirname(bin_path)
#Get the version of the running python interpreter
ver = platform.python_version_tuple()
if (os.path.exists(base_path + "/INSTALL")
and os.path.exists(base_path + "/setup.py")
and os.path.exists(base_path + "/pytrainer/main.py")
and os.path.exists(base_path + "/locale")):
print("running pytrainer from source path")
data_path = base_path + "/"
site_path = base_path
gettext_path = base_path + "/locale"
else:
print("running pytrainer from egg installation")
parts = os.path.split(base_path)
if parts[1] == 'EGG-INFO':
base_path = parts[0]
data_path = base_path + "/share/pytrainer/"
site_path = "%s/lib/python%s.%s/site-packages" % (base_path, ver[0], ver[1])
gettext_path = base_path + "/share/locale"
print "data_path: " + data_path
print "gettext_path: " + gettext_path
print "site_path: " + site_path
#ensure pytrainer directory is included in import path
sys.path.insert(0, site_path)
def main():
import pytrainer.lib.localization
pytrainer.lib.localization.initialize_gettext(gettext_path)
from pytrainer.main import pyTrainer
pytrainer = pyTrainer(None, data_path)
if __name__ == "__main__":
main()
|