def clear_profile_combo(self, *args): netloc = self.entry_host.get_text() host = common.get_hostname(netloc) port = common.get_port(netloc) database = self.entry_database.get_text().strip() login = self.entry_login.get_text() for idx, profile_info in enumerate(self.profile_store): if not profile_info[1]: continue profile = profile_info[0] try: profile_host = self.profiles.get(profile, 'host') profile_db = self.profiles.get(profile, 'database') profile_login = self.profiles.get(profile, 'username') except configparser.NoOptionError: continue if (host == common.get_hostname(profile_host) and port == common.get_port(profile_host) and database == profile_db and (not login or login == profile_login)): break else: idx = -1 self.combo_profile.set_active(idx) return False
def login(parameters): from tryton import common global CONNECTION, _USER, _USERNAME, _HOST, _PORT, _DATABASE global _VIEW_CACHE, _TOOLBAR_CACHE, _KEYWORD_CACHE global _CLIENT_DATE host = CONFIG['login.host'] hostname = common.get_hostname(host) port = common.get_port(host) database = CONFIG['login.db'] username = CONFIG['login.login'] language = CONFIG['client.lang'] date = CONFIG['login.date'] connection = ServerProxy(hostname, port, database) logging.getLogger(__name__).info('common.db.login(%s, %s, %s)' % (username, 'x' * 10, language)) result = connection.common.db.login(username, parameters, language) logging.getLogger(__name__).debug(repr(result)) _USER = result[0] session = ':'.join(map(str, [username] + result)) if CONNECTION is not None: CONNECTION.close() CONNECTION = ServerPool(hostname, port, database, session=session) _HOST = host _PORT = port _DATABASE = database _USERNAME = '' _CLIENT_DATE = date _VIEW_CACHE = {} _TOOLBAR_CACHE = {} _KEYWORD_CACHE = {} bus.listen(CONNECTION)
def login(parameters): from tryton import common global CONNECTION, _USER global _CLIENT_DATE host = CONFIG['login.host'] hostname = common.get_hostname(host) port = common.get_port(host) database = CONFIG['login.db'] username = CONFIG['login.login'] language = CONFIG['client.lang'] date = CONFIG['login.date'] connection = ServerProxy(hostname, port, database) logging.getLogger(__name__).info('common.db.login(%s, %s, %s)' % (username, 'x' * 10, language)) result = connection.common.db.login(username, parameters, language) logging.getLogger(__name__).debug(repr(result)) _USER = result[0] session = ':'.join(map(str, [username] + result)) if CONNECTION is not None: CONNECTION.close() CONNECTION = ServerPool(hostname, port, database, session=session, cache=not CONFIG['dev']) _CLIENT_DATE = date bus.listen(CONNECTION)
def main(): CSS = b""" .readonly entry { background-color: @insensitive_bg_color; } .required entry { border-color: darker(@unfocused_borders); } .invalid entry, entry.invalid { border-color: @error_color; } """ screen = Gdk.Screen.get_default() style_context = Gtk.StyleContext() provider = Gtk.CssProvider() provider.load_from_data(CSS) style_context.add_provider_for_screen( screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) theme_path = os.path.join(get_config_dir(), 'theme.css') if os.path.exists(theme_path): provider = Gtk.CssProvider() provider.load_from_path(theme_path) style_context.add_provider_for_screen(screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_USER) def excepthook(type_, value, traceback_): common.error(str(value), ''.join(traceback.format_tb(traceback_))) sys.excepthook = excepthook CONFIG.parse() if CONFIG.arguments: url = CONFIG.arguments[0] urlp = urlparse(url) if urlp.scheme == 'tryton': urlp = urlparse('http' + url[6:]) database, _ = (urlp.path[1:].split('/', 1) + [None])[:2] CONFIG['login.host'] = urlp.netloc CONFIG['login.db'] = database CONFIG['login.expanded'] = True else: CONFIG.arguments = [] translate.set_language_direction(CONFIG['client.language_direction']) translate.setlang(CONFIG['client.lang']) common.ICONFACTORY.load_client_icons() if CONFIG.arguments or DBLogin().run(): server = '%(hostname)s:%(port)s/%(database)s' % { 'hostname': common.get_hostname(CONFIG['login.host']), 'port': common.get_port(CONFIG['login.host']), 'database': CONFIG['login.db'], } server = hashlib.md5(server.encode('utf-8')).hexdigest() application_id = 'org.tryton._' + server app = gui.Main(application_id=application_id, flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE) app.run([sys.argv[0]] + CONFIG.arguments)
def clear_profile_combo(self, entry, event): netloc = self.entry_host.get_text() host = common.get_hostname(netloc) port = common.get_port(netloc) database = self.entry_database.get_text().strip() for idx, profile_info in enumerate(self.profile_store): if not profile_info[1]: continue profile = profile_info[0] profile_host = self.profiles.get(profile, 'host') profile_db = self.profiles.get(profile, 'database') if (host == common.get_hostname(profile_host) and port == common.get_port(profile_host) and database == profile_db): break else: idx = -1 self.combo_profile.set_active(idx) return False
def db_create(self, button): if not self.current_profile['name']: return netloc = self.host_entry.get_text() host = common.get_hostname(netloc) port = common.get_port(netloc) dia = DBCreate(host, port) dbname = dia.run() self.db_cache = None self.username_entry.set_text('admin') self.display_dbwidget(None, None, dbname)
def get_url(self): path = [CONFIG['login.db'], 'data', self.model] protocol = 'https' if CONNECTION.ssl else 'http' host = common.get_hostname(CONFIG['login.host']) port = common.get_port(CONFIG['login.host']) if protocol == 'https' and port == 445: netloc = host elif protocol == 'http' and port == 80: netloc = host else: netloc = '%s:%s' % (host, port) query_string = [] if self.selected_records.get_active(): domain = [r.id for r in self.screen.selected_records] else: domain = self.screen.search_domain( self.screen.screen_container.get_text()) if not self.ignore_search_limit.get_active(): query_string.append(('s', str(self.screen.limit))) query_string.append( ('p', str(self.screen.offset // self.screen.limit))) if self.screen.order: for expr in self.screen.order: query_string.append(('o', ','.join(filter(None, expr)))) query_string.insert( 0, ('d', json.dumps(domain, cls=JSONEncoder, separators=(',', ':')))) if self.screen.local_context: query_string.append(('c', json.dumps(self.screen.local_context, cls=JSONEncoder, separators=(',', ':')))) iter_ = self.model2.get_iter_first() while iter_: query_string.append(('f', self.model2.get_value(iter_, 1))) iter_ = self.model2.iter_next(iter_) encoding = self.csv_enc.get_active_text() if encoding: query_string.append(('enc', encoding)) query_string.append(('dl', self.get_delimiter())) query_string.append(('qc', self.get_quotechar())) if not self.add_field_names.get_active(): query_string.append(('h', '0')) if self.csv_locale.get_active(): query_string.append(('loc', '1')) query_string = urllib.parse.urlencode(query_string) return urllib.parse.urlunparse( (protocol, netloc, '/'.join(path), '', query_string, ''))
def display_dbwidget(self, entry, event, dbname=None): netloc = self.host_entry.get_text() host = common.get_hostname(netloc) if not host: return port = common.get_port(netloc) if (host, port, self.current_profile['name']) == self.db_cache: return if self.updating_db: return if dbname is None: dbname = self.current_database dbprogress = common.DBProgress(host, port) self.hide_database_info() self.add_button.set_sensitive(False) self.remove_button.set_sensitive(False) self.ok_button.set_sensitive(False) self.cell.set_property('editable', False) self.host_entry.set_sensitive(False) self.updating_db = True def callback(dbs): self.updating_db = False self.db_cache = (host, port, self.current_profile['name']) if dbs is None or dbs == -1: if dbs is None: label = _(u'Could not connect to the server') else: label = _(u'Incompatible version of the server') self.database_label.set_label('<b>%s</b>' % label) self.database_label.show() elif dbs == 0: self.database_button.show() elif dbs == -2: self.database_entry.show() else: self.database_entry.set_text(dbname if dbname else '') self.database_combo.show() self.add_button.set_sensitive(True) self.remove_button.set_sensitive(True) self.ok_button.set_sensitive(True) self.cell.set_property('editable', True) self.host_entry.set_sensitive(True) dbprogress.update(self.database_combo, self.database_progressbar, callback, dbname)
def display_dbwidget(self, entry, event): netloc = self.host_entry.get_text() host = common.get_hostname(netloc) if not host: return port = common.get_port(netloc) if (host, port, self.current_profile['name']) == self.db_cache: return if self.updating_db: return self.hide_database_info() self.add_button.set_sensitive(False) self.remove_button.set_sensitive(False) self.ok_button.set_sensitive(False) self.cell.set_property('editable', False) self.host_entry.set_sensitive(False) self.updating_db = True self.refresh_databases(host, port)
def __init__(self): CONFIG.parse() if CONFIG.arguments: url, = CONFIG.arguments urlp = urlparse(url) if urlp.scheme == 'tryton': urlp = urlparse('http' + url[6:]) hostname = common.get_hostname(urlp.netloc) port = common.get_port(urlp.netloc) database, _ = (urlp.path[1:].split('/', 1) + [None])[:2] if IPCClient(hostname, port, database).write(url): sys.exit(0) CONFIG['login.host'] = urlp.netloc CONFIG['login.db'] = database CONFIG['login.expanded'] = True translate.set_language_direction(CONFIG['client.language_direction']) translate.setlang(CONFIG['client.lang']) self.quit_client = (threading.Event() if sys.platform == 'win32' else None) common.ICONFACTORY.load_client_icons()
def run(self): parent = common.get_toplevel_window() self.dialog.set_default_response(gtk.RESPONSE_OK) self.dialog.set_transient_for(parent) self.dialog.show_all() pass_widget = self.entry_serverpasswd change_button = self.button_server_change admin_passwd = self.entry_adminpasswd admin_passwd2 = self.entry_adminpasswd2 change_button.connect_after('clicked', self.server_change) if self.host and self.port: url = '%s:%d' % (self.host, self.port) else: url = '' self.entry_server_connection.set_text(url) liststore = gtk.ListStore(str, str) self.combo_language.set_model(liststore) try: common.refresh_langlist(self.combo_language, self.host, self.port) except TrytonServerError: self.button_create.set_sensitive(False) while True: self.dialog.props.sensitive = True res = self.dialog.run() dbname = self.entry_dbname.get_text() netloc = self.entry_server_connection.get_text() host = common.get_hostname(netloc) port = common.get_port(netloc) langidx = self.combo_language.get_active_iter() langreal = langidx \ and self.combo_language.get_model().get_value(langidx, 1) passwd = pass_widget.get_text() if res == gtk.RESPONSE_OK: if admin_passwd.get_text() != admin_passwd2.get_text(): common.warning( _("The new admin password " "doesn't match the confirmation field.\n"), _("Passwords doesn't match!")) continue try: exist = rpc.db_exec(host, port, 'db_exist', dbname) except TrytonServerError, exception: common.process_exception(exception) continue if exist: common.warning(_("A database with the same name " "already exists.\n" "Try another database name."), _("This database name already exist!")) self.entry_dbname.set_text("") self.entry_dbname.grab_focus() continue else: # Everything runs fine, break the block here self.dialog.props.sensitive = False try: rpcprogress = common.RPCProgress('db_exec', (host, port, 'create', dbname, passwd, langreal, admin_passwd.get_text())) rpcprogress.run(False) except TrytonServerError, exception: if str(exception.faultCode) == "AccessDenied": common.warning(_("Sorry, wrong password for " "the Tryton server. " "Please try again."), _("Access denied!")) self.entry_serverpasswd.set_text("") self.entry_serverpasswd.grab_focus() continue else: # Unclassified error common.warning(_("Can't create the " "database, caused by an unknown reason.\n" "If there is a database created, it could " "be broken. Maybe drop this database! " "Please check the error message for " "possible informations.\n" "Error message:\n") + str(exception.faultCode), _("Error creating database!")) parent.present() self.dialog.destroy() rpc.logout() break parent.present() self.dialog.destroy() if self.sig_login: CONFIG['login.server'] = host CONFIG['login.port'] = str(port) CONFIG['login.db'] = dbname CONFIG['login.login'] = '******' self.sig_login() break
def run(self): parent = common.get_toplevel_window() self.dialog.set_default_response(gtk.RESPONSE_OK) self.dialog.set_transient_for(parent) self.dialog.show_all() pass_widget = self.entry_serverpasswd change_button = self.button_server_change admin_passwd = self.entry_adminpasswd admin_passwd2 = self.entry_adminpasswd2 change_button.connect_after('clicked', self.server_change) if self.host and self.port: url = '%s:%d' % (self.host, self.port) else: url = '' self.entry_server_connection.set_text(url) liststore = gtk.ListStore(str, str) self.combo_language.set_model(liststore) try: common.refresh_langlist(self.combo_language, self.host, self.port) except TrytonServerError: self.button_create.set_sensitive(False) while True: self.dialog.props.sensitive = True res = self.dialog.run() dbname = self.entry_dbname.get_text() netloc = self.entry_server_connection.get_text() host = common.get_hostname(netloc) port = common.get_port(netloc) langidx = self.combo_language.get_active_iter() langreal = langidx \ and self.combo_language.get_model().get_value(langidx, 1) passwd = pass_widget.get_text() if res == gtk.RESPONSE_OK: if admin_passwd.get_text() != admin_passwd2.get_text(): common.warning( _("The new admin password " "doesn't match the confirmation field.\n"), _("Passwords doesn't match!")) continue try: exist = rpc.db_exec(host, port, 'db_exist', dbname) except TrytonServerError, exception: common.process_exception(exception) continue if exist: common.warning( _("A database with the same name " "already exists.\n" "Try another database name."), _("This database name already exist!")) self.entry_dbname.set_text("") self.entry_dbname.grab_focus() continue else: # Everything runs fine, break the block here self.dialog.props.sensitive = False try: rpcprogress = common.RPCProgress( 'db_exec', (host, port, 'create', dbname, passwd, langreal, admin_passwd.get_text())) rpcprogress.run(False) except TrytonServerError, exception: if str(exception.faultCode) == "AccessDenied": common.warning( _("Sorry, wrong password for " "the Tryton server. " "Please try again."), _("Access denied!")) self.entry_serverpasswd.set_text("") self.entry_serverpasswd.grab_focus() continue else: # Unclassified error common.warning( _("Can't create the " "database, caused by an unknown reason.\n" "If there is a database created, it could " "be broken. Maybe drop this database! " "Please check the error message for " "possible informations.\n" "Error message:\n") + str(exception.faultCode), _("Error creating database!")) parent.present() self.dialog.destroy() rpc.logout() break parent.present() self.dialog.destroy() if self.sig_login: CONFIG['login.server'] = host CONFIG['login.port'] = str(port) CONFIG['login.db'] = dbname CONFIG['login.login'] = '******' self.sig_login() break
def run(self): profile_name = CONFIG['login.profile'] can_use_profile = self.profiles.has_section(profile_name) if can_use_profile: for (configname, sectionname) in (('login.server', 'host'), ('login.port', 'port'), ('login.db', 'database')): if (self.profiles.get(profile_name, sectionname) != CONFIG[configname]): can_use_profile = False break if can_use_profile: for idx, row in enumerate(self.profile_store): if row[0] == profile_name: self.combo_profile.set_active(idx) break else: self.combo_profile.set_active(-1) if ':' in CONFIG['login.server']: host = '[%s]' % CONFIG['login.server'] else: host = CONFIG['login.server'] self.entry_host.set_text('%s:%s' % (host, CONFIG['login.port'])) db = CONFIG['login.db'] if CONFIG['login.db'] else '' self.entry_database.set_text(db) self.entry_login.set_text(CONFIG['login.login']) self.dialog.show_all() self.entry_login.grab_focus() # Reshow dialog for gtk-quarks self.dialog.reshow_with_initial_size() self.expander.set_expanded(CONFIG['login.expanded']) # The previous action did not called expand_hostspec self.expand_hostspec(self.expander) response, result = None, ('', '', '', '') while not all(result): response = self.dialog.run() if response != gtk.RESPONSE_OK: break active_profile = self.combo_profile.get_active() if active_profile != -1: profile = self.profile_store[active_profile][0] CONFIG['login.profile'] = profile netloc = self.entry_host.get_text() host = common.get_hostname(netloc) port = common.get_port(netloc) try: test = DBListEditor.test_server_version(host, port) if not test: if test is False: common.warning('', _(u'Incompatible version of the server')) else: common.warning('', _(u'Could not connect to the server')) continue except Exception, exception: common.process_exception(exception) continue database = self.entry_database.get_text() login = self.entry_login.get_text() CONFIG['login.server'] = host CONFIG['login.port'] = port CONFIG['login.db'] = database CONFIG['login.expanded'] = self.expander.props.expanded CONFIG['login.login'] = login result = ( host, port, database, self.entry_login.get_text())
def run(self): profile_name = CONFIG['login.profile'] can_use_profile = self.profiles.has_section(profile_name) if can_use_profile: for (configname, sectionname) in [ ('login.host', 'host'), ('login.db', 'database'), ]: if (self.profiles.get(profile_name, sectionname) != CONFIG[configname]): can_use_profile = False break if can_use_profile: for idx, row in enumerate(self.profile_store): if row[0] == profile_name: self.combo_profile.set_active(idx) break else: self.combo_profile.set_active(-1) host = CONFIG['login.host'] if CONFIG['login.host'] else '' self.entry_host.set_text(host) db = CONFIG['login.db'] if CONFIG['login.db'] else '' self.entry_database.set_text(db) self.entry_login.set_text(CONFIG['login.login']) self.clear_profile_combo() self.dialog.show_all() self.entry_login.grab_focus() # Reshow dialog for gtk-quarks self.dialog.reshow_with_initial_size() self.expander.set_expanded(CONFIG['login.expanded']) # The previous action did not called expand_hostspec self.expand_hostspec(self.expander) response, result = None, ('', '', '', '') while not all(result): response = self.dialog.run() if response != gtk.RESPONSE_OK: break self.clear_profile_combo() active_profile = self.combo_profile.get_active() if active_profile != -1: profile = self.profile_store[active_profile][0] else: profile = '' host = self.entry_host.get_text() hostname = common.get_hostname(host) port = common.get_port(host) test = DBListEditor.test_server_version(hostname, port) if not test: if test is False: common.warning('', _(u'Incompatible version of the server')) else: common.warning('', _(u'Could not connect to the server')) continue database = self.entry_database.get_text() login = self.entry_login.get_text() CONFIG['login.profile'] = profile CONFIG['login.host'] = host CONFIG['login.db'] = database CONFIG['login.expanded'] = self.expander.props.expanded CONFIG['login.login'] = login result = ( hostname, port, database, self.entry_login.get_text()) if CONFIG['login.date']: date = self.entry_date.props.value else: date = None self.parent.present() self.dialog.destroy() if response != gtk.RESPONSE_OK: rpc.logout() raise TrytonError('QueryCanceled') return result + (date,)
def run(self): profile_name = CONFIG['login.profile'] can_use_profile = self.profiles.has_section(profile_name) if can_use_profile: for (configname, option) in [ ('login.host', 'host'), ('login.db', 'database'), ]: try: value = self.profiles.get(profile_name, option) except configparser.NoOptionError: value = None if value != CONFIG[configname]: can_use_profile = False break if can_use_profile: for idx, row in enumerate(self.profile_store): if row[0] == profile_name: self.combo_profile.set_active(idx) break else: self.combo_profile.set_active(-1) host = CONFIG['login.host'] if CONFIG['login.host'] else '' self.entry_host.set_text(host) db = CONFIG['login.db'] if CONFIG['login.db'] else '' self.entry_database.set_text(db) self.entry_login.set_text(CONFIG['login.login']) self.clear_profile_combo() self.dialog.show_all() self.entry_login.grab_focus() self.expander.set_expanded(CONFIG['login.expanded']) # The previous action did not called expand_hostspec self.expand_hostspec(self.expander) response, result = None, ('', '', '', '') while not all(result): response = self.dialog.run() if response != Gtk.ResponseType.OK: break self.clear_profile_combo() active_profile = self.combo_profile.get_active() if active_profile != -1: profile = self.profile_store[active_profile][0] else: profile = '' host = self.entry_host.get_text() hostname = common.get_hostname(host) port = common.get_port(host) test = DBListEditor.test_server_version(hostname, port) if not test: if test is False: common.warning('', _('Incompatible version of the server'), parent=self.dialog) else: common.warning('', _('Could not connect to the server'), parent=self.dialog) continue database = self.entry_database.get_text() login = self.entry_login.get_text() CONFIG['login.profile'] = profile CONFIG['login.host'] = host CONFIG['login.db'] = database CONFIG['login.expanded'] = self.expander.props.expanded CONFIG['login.login'] = login result = (hostname, port, database, self.entry_login.get_text()) if CONFIG['login.date']: CONFIG['login.date'] = self.entry_date.props.value self.dialog.destroy() self._window.destroy() return response == Gtk.ResponseType.OK
def run(self): profile_name = CONFIG['login.profile'] can_use_profile = self.profiles.has_section(profile_name) if can_use_profile: for (configname, sectionname) in (('login.server', 'host'), ('login.port', 'port'), ('login.db', 'database')): if (self.profiles.get(profile_name, sectionname) != CONFIG[configname]): can_use_profile = False break if can_use_profile: for idx, row in enumerate(self.profile_store): if row[0] == profile_name: self.combo_profile.set_active(idx) break else: self.combo_profile.set_active(-1) if ':' in CONFIG['login.server']: host = '[%s]' % CONFIG['login.server'] else: host = CONFIG['login.server'] self.entry_host.set_text('%s:%s' % (host, CONFIG['login.port'])) db = CONFIG['login.db'] if CONFIG['login.db'] else '' self.entry_database.set_text(db) self.entry_login.set_text(CONFIG['login.login']) self.dialog.show_all() if not self.entry_login.get_text(): self.entry_login.grab_focus() else: self.entry_password.grab_focus() # Reshow dialog for gtk-quarks self.dialog.reshow_with_initial_size() self.expander.set_expanded(CONFIG['login.expanded']) # The previous action did not called expand_hostspec self.expand_hostspec(self.expander) res, result = None, ('', '', '', '', '', '') while not all(result): res = self.dialog.run() if res != gtk.RESPONSE_OK: break active_profile = self.combo_profile.get_active() if active_profile != -1: profile = self.profile_store[active_profile][0] CONFIG['login.profile'] = profile netloc = self.entry_host.get_text() host = common.get_hostname(netloc) port = common.get_port(netloc) try: if not common.test_server_version(host, port): common.warning('', _(u'Incompatible version of the server')) continue except Exception, exception: common.process_exception(exception) continue database = self.entry_database.get_text() login = self.entry_login.get_text() CONFIG['login.server'] = host CONFIG['login.port'] = port CONFIG['login.db'] = database CONFIG['login.expanded'] = self.expander.props.expanded CONFIG['login.login'] = login result = (self.entry_login.get_text(), self.entry_password.get_text(), host, port, database)
def main(): CSS = b""" .readonly entry, .readonly text { background-color: @insensitive_bg_color; } .required entry, .required text { border-color: darker(@unfocused_borders); } .invalid entry, entry.invalid, .invalid text, text.invalid { border-color: @error_color; } label.required { font-weight: bold; } label.editable { font-style: italic; } .window-title, .wizard-title { background-color: white; font-size: large; font-weight: bold; } .window-title .status { font-size: medium; font-weight: normal; } """ screen = Gdk.Screen.get_default() style_context = Gtk.StyleContext() provider = Gtk.CssProvider() # the line below injects CSS with higher priority than the custom theme # -> it overrides Coog theme behavior # provider.load_from_data(CSS) style_context.add_provider_for_screen(screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_USER) theme_path = os.path.join(get_config_dir(), 'theme.css') if os.path.exists(theme_path): provider = Gtk.CssProvider() provider.load_from_path(theme_path) style_context.add_provider_for_screen(screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_USER) def excepthook(type_, value, traceback_): common.error(value, ''.join(traceback.format_tb(traceback_))) sys.excepthook = excepthook CONFIG.parse() if CONFIG.arguments: url = CONFIG.arguments[0] urlp = urlparse(url) if urlp.scheme == 'tryton': urlp = urlparse('http' + url[6:]) database, _ = (urlp.path[1:].split('/', 1) + [None])[:2] CONFIG['login.host'] = urlp.netloc CONFIG['login.db'] = database CONFIG['login.expanded'] = True else: CONFIG.arguments = [] translate.set_language_direction(CONFIG['client.language_direction']) translate.setlang(CONFIG['client.lang']) if CONFIG.arguments or DBLogin().run(): server = '%(hostname)s:%(port)s/%(database)s' % { 'hostname': common.get_hostname(CONFIG['login.host']), 'port': common.get_port(CONFIG['login.host']), 'database': CONFIG['login.db'], } server = hashlib.md5(server.encode('utf-8')).hexdigest() application_id = 'org.tryton._' + server app = gui.Main(application_id=application_id, flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE) app.run([sys.argv[0]] + CONFIG.arguments)