/usr/share/pyshared/tryton/client.py is in tryton-client 2.2.1-1.
This file is owned by root:root, with mode 0o644.
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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | #This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
"""
%prog [options]
"""
import os
import sys
import pygtk
pygtk.require('2.0')
import gtk
import gobject
gobject.threads_init()
import logging
from urlparse import urlparse
import threading
from tryton import version
from tryton import config
import tryton.common as common
from tryton.config import CONFIG, CURRENT_DIR, PREFIX, PIXMAPS_DIR, \
TRYTON_ICON, get_config_dir
from tryton import translate
from tryton import gui
from tryton.ipc import Client as IPCClient
import traceback
import time
import signal
if not hasattr(gtk.gdk, 'lock'):
class _Lock(object):
__enter__ = gtk.gdk.threads_enter
def __exit__(*ignored):
gtk.gdk.threads_leave()
gtk.gdk.lock = _Lock()
if sys.platform == 'win32':
class Dialog(gtk.Dialog):
def run(self):
with gtk.gdk.lock:
return super(Dialog, self).run()
gtk.Dialog = Dialog
class TrytonClient(object):
"Tryton client"
def __init__(self):
CONFIG.parse()
if CONFIG.arguments:
url, = CONFIG.arguments
urlp = urlparse(url)
if urlp.scheme == 'tryton':
urlp = urlparse('http' + url[6:])
hostname, port = (urlp.netloc.split(':', 1)
+ [CONFIG.defaults['login.port']])[:2]
database, _ = (urlp.path[1:].split('/', 1) + [None])[:2]
if IPCClient(hostname, port, database).write(url):
sys.exit(0)
CONFIG['login.server'] = hostname
CONFIG['login.port'] = port
CONFIG['login.db'] = database
CONFIG['login.expanded'] = True
logging.basicConfig()
translate.set_language_direction(CONFIG['client.language_direction'])
translate.setlang(CONFIG['client.lang'])
loglevel = {
'DEBUG': logging.DEBUG,
'INFO': logging.INFO,
'WARNING': logging.WARNING,
'ERROR': logging.ERROR,
'CRITICAL': logging.CRITICAL,
}
for logger in CONFIG['logging.logger'].split(','):
if logger:
log = logging.getLogger(logger)
log.setLevel(loglevel[CONFIG['logging.level'].upper()])
if CONFIG['logging.default']:
logging.getLogger().setLevel(
loglevel[CONFIG['logging.default'].upper()])
self.quit_client = (threading.Event()
if sys.platform == 'win32' else None)
common.ICONFACTORY.load_client_icons()
def quit_mainloop(self):
if sys.platform == 'win32':
self.quit_client.set()
else:
if gtk.main_level() > 0:
gtk.main_quit()
def run(self):
main = gui.Main(self)
signal.signal(signal.SIGINT, lambda signum, frame: main.sig_quit())
signal.signal(signal.SIGTERM, lambda signum, frame: main.sig_quit())
if hasattr(signal, 'SIGQUIT'):
signal.signal(signal.SIGQUIT, lambda signum, frame: main.sig_quit())
def excepthook(exctyp, exception, tb):
import common
import traceback
tb = '\n'.join(traceback.format_tb(tb))
common.process_exception(exception, tb=tb)
sys.excepthook = excepthook
if CONFIG['tip.autostart']:
main.sig_tips()
main.sig_login()
#XXX psyco breaks report printing
#try:
# import psyco
# psyco.full()
#except ImportError:
# pass
if sys.platform == 'win32':
# http://faq.pygtk.org/index.py?req=show&file=faq21.003.htp
def sleeper():
time.sleep(.001)
return 1
gobject.timeout_add(400, sleeper)
try:
if sys.platform == 'win32':
while not self.quit_client.isSet():
with gtk.gdk.lock:
running = gtk.main_iteration(True)
else:
gtk.main()
except KeyboardInterrupt:
CONFIG.save()
if hasattr(gtk, 'accel_map_save'):
gtk.accel_map_save(os.path.join(get_config_dir(), 'accel.map'))
if __name__ == "__main__":
CLIENT = TrytonClient()
CLIENT.run()
|