Esempio n. 1
0
def refresh_langlist(lang_widget, host, port):
    liststore = lang_widget.get_model()
    liststore.clear()
    try:
        lang_list = rpc.db_exec(host, port, 'list_lang')
    except socket.error:
        return []
    index = -1
    i = 0
    lang = locale.getdefaultlocale()[0]
    for key, val in lang_list:
        liststore.insert(i, (val, key))
        if key == lang:
            index = i
        if key == 'en_US' and index < 0:
            index = i
        i += 1
    lang_widget.set_active(index)
    return lang_list
Esempio n. 2
0
def refresh_langlist(lang_widget, host, port):
    liststore = lang_widget.get_model()
    liststore.clear()
    try:
        lang_list = rpc.db_exec(host, port, 'list_lang')
    except socket.error:
        return []
    from tryton.gui.main import Main
    Main.get_main().refresh_ssl()
    index = -1
    i = 0
    lang = locale.getdefaultlocale()[0]
    for key, val in lang_list:
        liststore.insert(i, (val, key))
        if key == lang:
            index = i
        if key == 'en_US' and index < 0:
            index = i
        i += 1
    lang_widget.set_active(index)
    return lang_list
Esempio n. 3
0
    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
Esempio n. 4
0
    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:
            res = self.dialog.run()
            dbname = self.entry_dbname.get_text()
            url = self.entry_server_connection.get_text()
            url_m = re.match('^([\w.\-]+):(\d{1,5})', \
                url or '')
            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 (not dbname) \
                    or (not re.match('^[a-zA-Z0-9_]+$', dbname)):
                    common.warning(_('The database name is restricted to ' \
                        'alpha-nummerical characters and "_" (underscore). ' \
                        'Avoid all accents, space ' \
                        'and any other special characters.'),
                        _('Wrong characters in database name!'))
                    continue
                elif 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
                elif not admin_passwd.get_text():
                    common.warning(_("Admin password and confirmation are " \
                        "required to create a new database."), \
                        _('Missing admin password!'))
                    continue
                elif url_m.group(1) \
                        and int(url_m.group(2)) \
                        and dbname \
                        and langreal \
                        and passwd \
                        and admin_passwd.get_text():
                    try:
                        exist = rpc.db_exec(url_m.group(1),
                                int(url_m.group(2)), '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
                        host = url_m.group(1)
                        port = url_m.group(2)
                        try:
                            rpcprogress = common.RPCProgress('db_exec',
                                    (host, int(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()
                            from tryton.gui.main import Main
                            Main.get_main().refresh_ssl()
                            break
                        from tryton.gui.main import Main
                        Main.get_main().refresh_ssl()
                        parent.present()
                        self.dialog.destroy()
                        if self.sig_login:
                            CONFIG['login.server'] = host
                            CONFIG['login.port'] = port
                            CONFIG['login.db'] = dbname
                            CONFIG['login.login'] = '******'
                            self.sig_login()
                        break
Esempio n. 6
0
    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()
            url = self.entry_server_connection.get_text()
            url_m = re.match('^([\w.\-]+):(\d{1,5})', url or '')
            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 (not dbname or not re.match('^[a-zA-Z0-9_]+$', dbname)):
                    common.warning(
                        _('The database name is restricted to '
                          'alpha-nummerical characters '
                          'and "_" (underscore). '
                          'Avoid all accents, space '
                          'and any other special characters.'),
                        _('Wrong characters in database name!'))
                    continue
                elif 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
                elif not admin_passwd.get_text():
                    common.warning(
                        _("Admin password and confirmation are "
                          "required to create a new database."),
                        _('Missing admin password!'))
                    continue
                elif url_m.group(1) \
                        and int(url_m.group(2)) \
                        and dbname \
                        and langreal \
                        and passwd \
                        and admin_passwd.get_text():
                    try:
                        exist = rpc.db_exec(url_m.group(1),
                                            int(url_m.group(2)), '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
                        host = url_m.group(1)
                        port = url_m.group(2)
                        self.dialog.props.sensitive = False
                        try:
                            rpcprogress = common.RPCProgress(
                                'db_exec',
                                (host, int(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'] = port
                            CONFIG['login.db'] = dbname
                            CONFIG['login.login'] = '******'
                            self.sig_login()
                        break