fix file lookup location and other issues

This commit is contained in:
André Apitzsch 2017-07-20 00:43:06 +02:00
parent 3ba58716d0
commit 624bee755c
14 changed files with 27 additions and 94 deletions

1
.gitignore vendored
View File

@ -8,7 +8,6 @@ syntax: glob
*.pyo
*~
autom4te.cache
data/defs.py
data/org.gajim.Gajim.appdata.xml
data/org.gajim.Gajim.desktop
libtool

View File

@ -1,9 +0,0 @@
# this file is automatically generate by configure
# do not edit it!
docdir = "@DOCDIR@"
basedir = "@PKGDATADIR@"
version = "@VERSION@"
localedir = "@LOCALEDIR@"

View File

@ -0,0 +1 @@
__version__ = "0.16.11"

View File

@ -33,10 +33,11 @@
import re
from gajim.common import defs
from gi.repository import GLib
from enum import IntEnum, unique
import gajim
@unique
class Option(IntEnum):
TYPE = 0
@ -188,7 +189,7 @@ class Config:
'send_on_ctrl_enter': [opt_bool, False, _('Send message on Ctrl+Enter and with Enter make new line (Mirabilis ICQ Client default behaviour).')],
'last_roster_visible': [opt_bool, True],
'key_up_lines': [opt_int, 25, _('How many lines to store for Ctrl+KeyUP.')],
'version': [ opt_str, defs.version ], # which version created the config
'version': [ opt_str, gajim.__version__ ], # which version created the config
'search_engine': [opt_str, 'https://www.google.com/search?&q=%s&sourceid=gajim'],
'dictionary_url': [opt_str, 'WIKTIONARY', _("Either custom url with %%s in it where %%s is the word/phrase or 'WIKTIONARY' which means use wiktionary.")],
'always_english_wikipedia': [opt_bool, False],

View File

@ -25,7 +25,6 @@
import os
import sys
import tempfile
from gajim.common import defs
from enum import Enum, unique
@unique
@ -102,8 +101,7 @@ class ConfigPaths:
basedir = pkg_resources.resource_filename("gajim", ".")
self.add('DATA', None, os.path.join(basedir, 'data'))
self.add('GUI', None, os.path.join(basedir, 'data', 'gui'))
basedir = os.environ.get('GAJIM_BASEDIR', defs.basedir)
self.add('ICONS', None, os.path.join(basedir, 'icons'))
self.add('ICONS', None, os.path.join(basedir, 'data', 'icons'))
self.add('HOME', None, os.path.expanduser('~'))
self.add('PLUGINS_BASE', None, os.path.join(basedir, 'plugins'))

View File

@ -1,44 +0,0 @@
# -*- coding:utf-8 -*-
## src/common/defs.py
##
## Copyright (C) 2006 Nikos Kouremenos <kourem AT gmail.com>
## Copyright (C) 2006-2014 Yann Leboulanger <asterix AT lagaule.org>
## Copyright (C) 2006-2008 Jean-Marie Traissard <jim AT lapin.org>
## Copyright (C) 2007 Brendan Taylor <whateley AT gmail.com>
## Tomasz Melcer <liori AT exroot.org>
## Copyright (C) 2008 Jonathan Schleifer <js-gajim AT webkeks.org>
##
## This file is part of Gajim.
##
## Gajim 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; version 3 only.
##
## Gajim 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 Gajim. If not, see <http://www.gnu.org/licenses/>.
##
import subprocess
import sys
import os.path
docdir = '../'
basedir = './'
localedir = '../po'
version = '0.16.11'
try:
node = subprocess.Popen('git rev-parse --short=12 HEAD', shell=True,
stdout=subprocess.PIPE).communicate()[0]
if node:
version += '-' + node.decode('utf-8').strip()
except Exception:
pass
for base in ('.', 'common'):
sys.path.append(os.path.join(base, '.libs'))

View File

@ -24,7 +24,6 @@
import locale
import gettext
import os
from gajim.common import defs
import unicodedata
# May be changed after GTK is imported
@ -47,7 +46,6 @@ def paragraph_direction_mark(text):
return '\u200E'
APP = 'gajim'
DIR = defs.localedir
# set '' so each part of the locale that should be modified is set
# according to the environment variables
@ -64,7 +62,8 @@ if os.name == 'nt':
if lang:
os.environ['LANG'] = lang
gettext.install(APP, DIR)
#gettext.install(APP, defs.localedir)
gettext.install(APP)
if gettext._translations:
_translation = list(gettext._translations.values())[0]
else:

View File

@ -43,7 +43,6 @@ from gajim import vcard
from gajim import conversation_textview
from gajim import dataforms_widget
from gajim.common import defs
from random import randrange
from gajim.common import pep
from gajim.common import ged

View File

@ -252,8 +252,8 @@ class GajimApplication(Gtk.Application):
if options.contains('config-path'):
self.config_path = options.lookup_value('config-path').get_string()
if options.contains('version'):
from gajim.common.defs import version
print(version)
from gajim import __version__
print(__version__)
return 0
if options.contains('quiet'):
logging_helpers.set_quiet()

View File

@ -119,9 +119,8 @@ def get_image_button(icon_name, tooltip, toggle=False):
button.set_tooltip_text(_(tooltip))
return button
GUI_DIR = os.path.join(app.DATA_DIR, 'gui')
def get_gtk_builder(file_name, widget=None):
file_path = os.path.join(GUI_DIR, file_name)
file_path = os.path.join(configpaths.get('GUI'), file_name)
builder = Gtk.Builder()
builder.set_translation_domain(i18n.APP)
if widget:

View File

@ -27,8 +27,6 @@ if sys.platform != 'win32':
if os.geteuid() == 0:
sys.exit("You must not launch gajim as root, it is insecure.")
sys.path.append("@PY_SITEDIR@")
import gajim.gajim as g
g.GajimApplication().run(sys.argv)

View File

@ -27,8 +27,6 @@ if sys.platform != 'win32':
if os.geteuid() == 0:
sys.exit("You must not launch gajim as root, it is insecure.")
sys.path.append("@PY_SITEDIR@")
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

View File

@ -26,8 +26,6 @@ import sys
if os.geteuid() == 0:
sys.exit("You must not launch gajim as root, it is insecure.")
sys.path.append("@PY_SITEDIR@")
import gajim.gajim_remote as g
g.GajimRemote()

View File

@ -9,17 +9,15 @@ if sys.version_info[0] < 3:
import codecs
from setuptools import setup, find_packages
# from distutils.core import setup
from setuptools.command.build_py import build_py as _build
from distutils import log
from distutils.command.build import build as _build
#from distutils.command.install import install as _install
#from setuptools.command.build_py import build_py as _build # build_dir is unknown
from distutils.util import convert_path, newer
import gajim
pos = [x for x in os.listdir('po') if x[-3:] == ".po"]
ALL_LINGUAS = sorted([os.path.split(x)[-1][:-3] for x in pos])
cwd = os.path.dirname(os.path.realpath(__file__))
def build_trans(build_cmd):
'''
@ -28,10 +26,7 @@ def build_trans(build_cmd):
data_files = build_cmd.distribution.data_files
for lang in ALL_LINGUAS:
po_file = os.path.join('po', lang + '.po')
mo_file = os.path.join(build_cmd.build_base, 'mo', lang, 'LC_MESSAGES',
'gajim.mo')
mo_file_unix = (build_cmd.build_base + '/mo/' + lang +
'/LC_MESSAGES/gajim.mo')
mo_file = os.path.join(cwd, 'mo', lang, 'LC_MESSAGES', 'gajim.mo')
mo_dir = os.path.dirname(mo_file)
if not (os.path.isdir(mo_dir) or os.path.islink(mo_dir)):
os.makedirs(mo_dir)
@ -49,16 +44,16 @@ def build_trans(build_cmd):
#linux specific piece:
target = 'share/locale/' + lang + '/LC_MESSAGES'
data_files.append((target, [mo_file_unix]))
data_files.append((target, [mo_file]))
def build_man(build_cmd):
'''
Compresses Gajim manual files
Compress Gajim manual files
'''
data_files = build_cmd.distribution.data_files
for man in ['gajim.1', 'gajim-history-manager.1', 'gajim-remote.1']:
filename = os.path.join('data', man)
newdir = os.path.join(build_cmd.build_base, 'man')
newdir = os.path.join(cwd, 'man')
if not (os.path.isdir(newdir) or os.path.islink(newdir)):
os.makedirs(newdir)
@ -77,7 +72,7 @@ def build_man(build_cmd):
f_out.writelines(f_in)
log.info('Compiling %s >> %s', filename, man_file_gz)
src = build_cmd.build_base + '/man' + '/' + man + '.gz'
src = cwd + '/man' + '/' + man + '.gz'
target = 'share/man/man1'
data_files.append((target, [src]))
@ -86,7 +81,7 @@ def build_intl(build_cmd):
Merge translation files into desktop and mime files
'''
data_files = build_cmd.distribution.data_files
base = build_cmd.build_base
base = cwd
merge_files = (('data/org.gajim.Gajim.desktop', 'share/applications', '-d'),
('data/gajim-remote.desktop', 'share/applications', '-d'),
@ -149,7 +144,7 @@ def merge(in_file, out_file, option, po_dir='po', cache=True):
class build(_build):
def run(self):
build_trans(self)
if not sys.platform == 'win32':
if sys.platform != 'win32':
build_man(self)
build_intl(self)
_build.run(self)
@ -178,18 +173,14 @@ data_files_app_icon = [
data_files = data_files_app_icon
setup(
name = "gajim",
description = 'TODO',
version=gajim.__version__,
url = 'https://gajim.org',
cmdclass = {
'build': build, # if setuptools use "'build_py': build"
'build_py': build,
},
# TODO fix tests
# TODO configure_file defs.py.in
# TODO #install plugins
scripts = [
'scripts/gajim',
'scripts/gajim-history-manager',
@ -197,4 +188,9 @@ setup(
packages = find_packages(),
package_data = {'gajim': package_data},
data_files = data_files,
install_requires=[
'dbus-python',
'nbxmpp',
'pyOpenSSL'
],
)