Example #1
0
        def on_response(dialog, response_id):
            if response_id == gtk.RESPONSE_OK:
                if self.config["tray_password"] == sha_hash(entered_pass.get_text()).hexdigest():
                    self.window.present()

            tray_lock.destroy()
            is_showing_dlg[0] = False
Example #2
0
        def on_response(dialog, response_id):
            if response_id == gtk.RESPONSE_OK:
                if self.config["tray_password"] == sha_hash(entered_pass.get_text()).hexdigest():
                    self.window.present()

            tray_lock.destroy()
            is_showing_dlg[0] = False
Example #3
0
 def create(fname, lname, username, password, dob, email, location, bio):
     s = sha_hash()
     unhashed = username+password
     unhashed = bytes(unhashed, encoding='utf8')
     s.update(unhashed)
     password = s.hexdigest()
     joindate = dbtime.make_time_str()
     return User(None, fname, lname, username, password, dob, email, joindate, location, bio, admin_level)
Example #4
0
 def update_password(self, password):
     s = sha_hash()
     unhashed = self.username + password
     unhashed = bytes(unhashed, encoding="utf8")
     s.update(unhashed)
     password = s.hexdigest()
     cur = conn.cursor()
     cur.execute("UPDATE users SET password = ? WHERE id = ?", (password, self.id))
Example #5
0
 def __create_localclient_account(self):
     """
     Returns the string.
     """
     # We create a 'localclient' account with a random password
     try:
         from hashlib import sha1 as sha_hash
     except ImportError:
         from sha import new as sha_hash
     return "localclient:" + sha_hash(str(random.random())).hexdigest() + ":" + str(AUTH_LEVEL_ADMIN) + "\n"
Example #6
0
 def __create_localclient_account(self):
     """
     Returns the string.
     """
     # We create a 'localclient' account with a random password
     try:
         from hashlib import sha1 as sha_hash
     except ImportError:
         from sha import new as sha_hash
     return "localclient:" + sha_hash(str(
         random.random())).hexdigest() + ":" + str(AUTH_LEVEL_ADMIN) + "\n"
Example #7
0
 def login(cls, username, password):
     cur = conn.cursor()
     s = sha_hash()
     unhashed = username+password
     unhashed = bytes(unhashed, encoding='utf8')
     s.update(unhashed)
     password = s.hexdigest()
     cur.execute("SELECT * FROM users WHERE password = ? AND username = ?",(password,username))
     user = cur.fetchone()
     if user == None:
         return None
     else:
         return User.find('username',username)[0]
Example #8
0
def create_localclient_account(append=False):
    import configmanager, random

    auth_file = configmanager.get_config_dir("auth")
    if not os.path.exists(auth_file):
        create_auth_file()

    try:
        from hashlib import sha1 as sha_hash
    except ImportError:
        from sha import new as sha_hash
    fd = open(auth_file, "a" if append else "w")
    fd.write(":".join(["localclient", sha_hash(str(random.random())).hexdigest(), str(AUTH_LEVEL_ADMIN)]) + "\n")
    fd.flush()
    os.fsync(fd.fileno())
    fd.close()
Example #9
0
def create_localclient_account(append=False):
    import configmanager, random
    auth_file = configmanager.get_config_dir("auth")
    if not os.path.exists(auth_file):
        create_auth_file()

    try:
        from hashlib import sha1 as sha_hash
    except ImportError:
        from sha import new as sha_hash
    fd = open(auth_file, "a" if append else "w")
    fd.write(":".join([
        "localclient",
        sha_hash(str(random.random())).hexdigest(),
        str(AUTH_LEVEL_ADMIN)
    ]) + '\n')
    fd.flush()
    os.fsync(fd.fileno())
    fd.close()
Example #10
0
    def set_config(self, hide=False):
        """
        Sets all altered config values in the core.

        :param hide: bool, if True, will not re-show the dialog and will hide it instead
        """
        try:
            from hashlib import sha1 as sha_hash
        except ImportError:
            from sha import new as sha_hash

        # Get the values from the dialog
        new_core_config = {}
        new_gtkui_config = {}

        ## Downloads tab ##
        new_gtkui_config["interactive_add"] = \
            self.glade.get_object("chk_show_dialog").get_active()
        new_gtkui_config["focus_add_dialog"] = \
            self.glade.get_object("chk_focus_dialog").get_active()
        new_core_config["copy_torrent_file"] = \
            self.glade.get_object("chk_copy_torrent_file").get_active()
        new_core_config["del_copy_torrent_file"] = \
            self.glade.get_object("chk_del_copy_torrent_file").get_active()
        new_core_config["move_completed"] = \
            self.glade.get_object("chk_move_completed").get_active()
        if client.is_localhost():
            new_core_config["download_location"] = \
                self.glade.get_object("download_path_button").get_filename()
            new_core_config["move_completed_path"] = \
                self.glade.get_object("move_completed_path_button").get_filename()
            new_core_config["torrentfiles_location"] = \
                self.glade.get_object("torrent_files_button").get_filename()
        else:
            new_core_config["download_location"] = \
                self.glade.get_object("entry_download_path").get_text()
            new_core_config["move_completed_path"] = \
                self.glade.get_object("entry_move_completed_path").get_text()
            new_core_config["torrentfiles_location"] = \
                self.glade.get_object("entry_torrents_path").get_text()

        new_core_config["autoadd_enable"] = \
            self.glade.get_object("chk_autoadd").get_active()
        if client.is_localhost():
            new_core_config["autoadd_location"] = \
                self.glade.get_object("folder_autoadd").get_filename()
        else:
            new_core_config["autoadd_location"] = \
                self.glade.get_object("entry_autoadd").get_text()

        new_core_config["compact_allocation"] = \
            self.glade.get_object("radio_compact_allocation").get_active()
        new_core_config["prioritize_first_last_pieces"] = \
            self.glade.get_object(
                "chk_prioritize_first_last_pieces").get_active()
        new_core_config["add_paused"] = \
            self.glade.get_object("chk_add_paused").get_active()

        ## Network tab ##
        listen_ports = (
            self.glade.get_object("spin_port_min").get_value_as_int(),
            self.glade.get_object("spin_port_max").get_value_as_int())
        new_core_config["listen_ports"] = listen_ports
        new_core_config["random_port"] = \
            self.glade.get_object("chk_random_port").get_active()
        outgoing_ports = (
            self.glade.get_object("spin_outgoing_port_min").get_value_as_int(),
            self.glade.get_object("spin_outgoing_port_max").get_value_as_int())
        new_core_config["outgoing_ports"] = outgoing_ports
        new_core_config["random_outgoing_ports"] = \
            self.glade.get_object("chk_random_outgoing_ports").get_active()
        incoming_address = self.glade.get_object(
            "entry_interface").get_text().strip()
        if deluge.common.is_ip(incoming_address) or not incoming_address:
            new_core_config["listen_interface"] = incoming_address
        new_core_config["peer_tos"] = self.glade.get_object(
            "entry_peer_tos").get_text()
        new_core_config["dht"] = self.glade.get_object("chk_dht").get_active()
        new_core_config["upnp"] = self.glade.get_object(
            "chk_upnp").get_active()
        new_core_config["natpmp"] = \
            self.glade.get_object("chk_natpmp").get_active()
        new_core_config["utpex"] = \
            self.glade.get_object("chk_utpex").get_active()
        new_core_config["lsd"] = \
            self.glade.get_object("chk_lsd").get_active()
        new_core_config["enc_in_policy"] = \
            self.glade.get_object("combo_encin").get_active()
        new_core_config["enc_out_policy"] = \
            self.glade.get_object("combo_encout").get_active()
        new_core_config["enc_level"] = \
            self.glade.get_object("combo_enclevel").get_active()
        new_core_config["enc_prefer_rc4"] = \
            self.glade.get_object("chk_pref_rc4").get_active()

        ## Bandwidth tab ##
        new_core_config["max_connections_global"] = \
            self.glade.get_object(
                "spin_max_connections_global").get_value_as_int()
        new_core_config["max_download_speed"] = \
            self.glade.get_object("spin_max_download").get_value()
        new_core_config["max_upload_speed"] = \
            self.glade.get_object("spin_max_upload").get_value()
        new_core_config["max_upload_slots_global"] = \
            self.glade.get_object(
                "spin_max_upload_slots_global").get_value_as_int()
        new_core_config["max_half_open_connections"] = \
            self.glade.get_object("spin_max_half_open_connections").get_value_as_int()
        new_core_config["max_connections_per_second"] = \
            self.glade.get_object(
                "spin_max_connections_per_second").get_value_as_int()
        new_core_config["max_connections_per_torrent"] = \
            self.glade.get_object(
                "spin_max_connections_per_torrent").get_value_as_int()
        new_core_config["max_upload_slots_per_torrent"] = \
            self.glade.get_object(
                "spin_max_upload_slots_per_torrent").get_value_as_int()
        new_core_config["max_upload_speed_per_torrent"] = \
            self.glade.get_object(
                "spin_max_upload_per_torrent").get_value()
        new_core_config["max_download_speed_per_torrent"] = \
            self.glade.get_object(
                "spin_max_download_per_torrent").get_value()
        new_core_config["ignore_limits_on_local_network"] = \
            self.glade.get_object("chk_ignore_limits_on_local_network").get_active()
        new_core_config["rate_limit_ip_overhead"] = \
            self.glade.get_object("chk_rate_limit_ip_overhead").get_active()

        ## Interface tab ##
        new_gtkui_config["enable_system_tray"] = \
            self.glade.get_object("chk_use_tray").get_active()
        new_gtkui_config["close_to_tray"] = \
            self.glade.get_object("chk_min_on_close").get_active()
        new_gtkui_config["start_in_tray"] = \
            self.glade.get_object("chk_start_in_tray").get_active()
        new_gtkui_config["enable_appindicator"] = \
            self.glade.get_object("chk_enable_appindicator").get_active()
        new_gtkui_config["lock_tray"] = \
            self.glade.get_object("chk_lock_tray").get_active()
        passhex = sha_hash(\
            self.glade.get_object("txt_tray_password").get_text()).hexdigest()
        if passhex != "c07eb5a8c0dc7bb81c217b67f11c3b7a5e95ffd7":
            new_gtkui_config["tray_password"] = passhex
        new_gtkui_config["classic_mode"] = \
            self.glade.get_object("chk_classic_mode").get_active()
        new_gtkui_config["show_rate_in_title"] = \
            self.glade.get_object("chk_show_rate_in_title").get_active()
        new_gtkui_config["focus_main_window_on_add"] = \
            self.glade.get_object("chk_focus_main_window_on_add").get_active()

        ## Other tab ##
        new_gtkui_config["show_new_releases"] = \
            self.glade.get_object("chk_show_new_releases").get_active()
        new_core_config["send_info"] = \
            self.glade.get_object("chk_send_info").get_active()
        new_core_config["geoip_db_location"] = \
            self.glade.get_object("entry_geoip").get_text()

        ## Daemon tab ##
        new_core_config["daemon_port"] = \
            self.glade.get_object("spin_daemon_port").get_value_as_int()
        new_core_config["allow_remote"] = \
            self.glade.get_object("chk_allow_remote_connections").get_active()
        new_core_config["new_release_check"] = \
            self.glade.get_object("chk_new_releases").get_active()

        ## Proxy tab ##
        new_core_config["proxies"] = {}
        for t in ("peer", "web_seed", "tracker", "dht"):
            new_core_config["proxies"][t] = {}
            new_core_config["proxies"][t]["type"] = \
                self.glade.get_object("combo_proxy_type_%s" % t).get_active()
            new_core_config["proxies"][t]["port"] = \
                self.glade.get_object("spin_proxy_port_%s" % t).get_value_as_int()
            new_core_config["proxies"][t]["username"] = \
                self.glade.get_object("txt_proxy_username_%s" % t).get_text()
            new_core_config["proxies"][t]["password"] = \
                self.glade.get_object("txt_proxy_password_%s" % t).get_text()
            new_core_config["proxies"][t]["hostname"] = \
                self.glade.get_object("txt_proxy_server_%s" % t).get_text()

        ## Queue tab ##
        new_core_config["queue_new_to_top"] = \
            self.glade.get_object("chk_queue_new_top").get_active()
        new_core_config["max_active_seeding"] = \
            self.glade.get_object("spin_seeding").get_value_as_int()
        new_core_config["max_active_downloading"] = \
            self.glade.get_object("spin_downloading").get_value_as_int()
        new_core_config["max_active_limit"] = \
            self.glade.get_object("spin_active").get_value_as_int()
        new_core_config["dont_count_slow_torrents"] = \
            self.glade.get_object("chk_dont_count_slow_torrents").get_active()
        new_core_config["stop_seed_at_ratio"] = \
            self.glade.get_object("chk_seed_ratio").get_active()
        new_core_config["remove_seed_at_ratio"] = \
            self.glade.get_object("chk_remove_ratio").get_active()
        new_core_config["stop_seed_ratio"] = \
            self.glade.get_object("spin_share_ratio").get_value()
        new_core_config["share_ratio_limit"] = \
            self.glade.get_object("spin_share_ratio_limit").get_value()
        new_core_config["seed_time_ratio_limit"] = \
            self.glade.get_object("spin_seed_time_ratio_limit").get_value()
        new_core_config["seed_time_limit"] = \
            self.glade.get_object("spin_seed_time_limit").get_value()

        ## Cache tab ##
        new_core_config["cache_size"] = \
            self.glade.get_object("spin_cache_size").get_value_as_int()
        new_core_config["cache_expiry"] = \
            self.glade.get_object("spin_cache_expiry").get_value_as_int()

        # Run plugin hook to apply preferences
        component.get("PluginManager").run_on_apply_prefs()

        # GtkUI
        for key in new_gtkui_config.keys():
            # The values do not match so this needs to be updated
            if self.gtkui_config[key] != new_gtkui_config[key]:
                self.gtkui_config[key] = new_gtkui_config[key]

        # Core
        if client.connected():
            # Only do this if we're connected to a daemon
            config_to_set = {}
            for key in new_core_config.keys():
                # The values do not match so this needs to be updated
                try:
                    if self.core_config[key] != new_core_config[key]:
                        config_to_set[key] = new_core_config[key]
                except KeyError:
                    config_to_set[key] = new_core_config[key]

            if config_to_set:
                # Set each changed config value in the core
                client.core.set_config(config_to_set)
                client.force_call(True)
                # Update the configuration
                self.core_config.update(config_to_set)

        if hide:
            self.hide()
        else:
            # Re-show the dialog to make sure everything has been updated
            self.show()

        if client.is_classicmode() != new_gtkui_config["classic_mode"]:
            dialog = Gtk.MessageDialog(
                flags=Gtk.DialogFlags.MODAL
                | Gtk.DialogFlags.DESTROY_WITH_PARENT,
                type=Gtk.MessageType.QUESTION,
                buttons=Gtk.ButtonsType.YES_NO,
                message_format=
                _("You must restart the deluge UI to change classic mode. Quit now?"
                  ))
            result = dialog.run()
            if result == Gtk.ResponseType.YES:
                shutdown_daemon = (not client.is_classicmode()
                                   and client.connected()
                                   and client.is_localhost())
                component.get("MainWindow").quit(shutdown=shutdown_daemon)
            dialog.destroy()
Example #11
0
    def set_config(self, hide=False):
        """
        Sets all altered config values in the core.

        :param hide: bool, if True, will not re-show the dialog and will hide it instead
        """
        try:
            from hashlib import sha1 as sha_hash
        except ImportError:
            from sha import new as sha_hash

        # Get the values from the dialog
        new_core_config = {}
        new_gtkui_config = {}

        ## Downloads tab ##
        new_gtkui_config["interactive_add"] = self.glade.get_widget("chk_show_dialog").get_active()
        new_gtkui_config["focus_add_dialog"] = self.glade.get_widget("chk_focus_dialog").get_active()
        new_core_config["copy_torrent_file"] = self.glade.get_widget("chk_copy_torrent_file").get_active()
        new_core_config["del_copy_torrent_file"] = self.glade.get_widget("chk_del_copy_torrent_file").get_active()
        new_core_config["move_completed"] = self.glade.get_widget("chk_move_completed").get_active()
        if client.is_localhost():
            new_core_config["download_location"] = self.glade.get_widget("download_path_button").get_filename()
            new_core_config["move_completed_path"] = self.glade.get_widget("move_completed_path_button").get_filename()
            new_core_config["torrentfiles_location"] = self.glade.get_widget("torrent_files_button").get_filename()
        else:
            new_core_config["download_location"] = self.glade.get_widget("entry_download_path").get_text()
            new_core_config["move_completed_path"] = self.glade.get_widget("entry_move_completed_path").get_text()
            new_core_config["torrentfiles_location"] = self.glade.get_widget("entry_torrents_path").get_text()

        new_core_config["autoadd_enable"] = self.glade.get_widget("chk_autoadd").get_active()
        if client.is_localhost():
            new_core_config["autoadd_location"] = self.glade.get_widget("folder_autoadd").get_filename()
        else:
            new_core_config["autoadd_location"] = self.glade.get_widget("entry_autoadd").get_text()

        new_core_config["compact_allocation"] = self.glade.get_widget("radio_compact_allocation").get_active()
        new_core_config["prioritize_first_last_pieces"] = self.glade.get_widget(
            "chk_prioritize_first_last_pieces"
        ).get_active()
        new_core_config["add_paused"] = self.glade.get_widget("chk_add_paused").get_active()

        ## Network tab ##
        listen_ports = (
            self.glade.get_widget("spin_port_min").get_value_as_int(),
            self.glade.get_widget("spin_port_max").get_value_as_int(),
        )
        new_core_config["listen_ports"] = listen_ports
        new_core_config["random_port"] = self.glade.get_widget("chk_random_port").get_active()
        outgoing_ports = (
            self.glade.get_widget("spin_outgoing_port_min").get_value_as_int(),
            self.glade.get_widget("spin_outgoing_port_max").get_value_as_int(),
        )
        new_core_config["outgoing_ports"] = outgoing_ports
        new_core_config["random_outgoing_ports"] = self.glade.get_widget("chk_random_outgoing_ports").get_active()
        new_core_config["listen_interface"] = self.glade.get_widget("entry_interface").get_text()
        new_core_config["peer_tos"] = self.glade.get_widget("entry_peer_tos").get_text()
        new_core_config["dht"] = self.glade.get_widget("chk_dht").get_active()
        new_core_config["upnp"] = self.glade.get_widget("chk_upnp").get_active()
        new_core_config["natpmp"] = self.glade.get_widget("chk_natpmp").get_active()
        new_core_config["utpex"] = self.glade.get_widget("chk_utpex").get_active()
        new_core_config["lsd"] = self.glade.get_widget("chk_lsd").get_active()
        new_core_config["enc_in_policy"] = self.glade.get_widget("combo_encin").get_active()
        new_core_config["enc_out_policy"] = self.glade.get_widget("combo_encout").get_active()
        new_core_config["enc_level"] = self.glade.get_widget("combo_enclevel").get_active()
        new_core_config["enc_prefer_rc4"] = self.glade.get_widget("chk_pref_rc4").get_active()

        ## Bandwidth tab ##
        new_core_config["max_connections_global"] = self.glade.get_widget(
            "spin_max_connections_global"
        ).get_value_as_int()
        new_core_config["max_download_speed"] = self.glade.get_widget("spin_max_download").get_value()
        new_core_config["max_upload_speed"] = self.glade.get_widget("spin_max_upload").get_value()
        new_core_config["max_upload_slots_global"] = self.glade.get_widget(
            "spin_max_upload_slots_global"
        ).get_value_as_int()
        new_core_config["max_half_open_connections"] = self.glade.get_widget(
            "spin_max_half_open_connections"
        ).get_value_as_int()
        new_core_config["max_connections_per_second"] = self.glade.get_widget(
            "spin_max_connections_per_second"
        ).get_value_as_int()
        new_core_config["max_connections_per_torrent"] = self.glade.get_widget(
            "spin_max_connections_per_torrent"
        ).get_value_as_int()
        new_core_config["max_upload_slots_per_torrent"] = self.glade.get_widget(
            "spin_max_upload_slots_per_torrent"
        ).get_value_as_int()
        new_core_config["max_upload_speed_per_torrent"] = self.glade.get_widget(
            "spin_max_upload_per_torrent"
        ).get_value()
        new_core_config["max_download_speed_per_torrent"] = self.glade.get_widget(
            "spin_max_download_per_torrent"
        ).get_value()
        new_core_config["ignore_limits_on_local_network"] = self.glade.get_widget(
            "chk_ignore_limits_on_local_network"
        ).get_active()
        new_core_config["rate_limit_ip_overhead"] = self.glade.get_widget("chk_rate_limit_ip_overhead").get_active()

        ## Interface tab ##
        new_gtkui_config["enable_system_tray"] = self.glade.get_widget("chk_use_tray").get_active()
        new_gtkui_config["close_to_tray"] = self.glade.get_widget("chk_min_on_close").get_active()
        new_gtkui_config["start_in_tray"] = self.glade.get_widget("chk_start_in_tray").get_active()
        new_gtkui_config["enable_appindicator"] = self.glade.get_widget("chk_enable_appindicator").get_active()
        new_gtkui_config["lock_tray"] = self.glade.get_widget("chk_lock_tray").get_active()
        passhex = sha_hash(self.glade.get_widget("txt_tray_password").get_text()).hexdigest()
        if passhex != "c07eb5a8c0dc7bb81c217b67f11c3b7a5e95ffd7":
            new_gtkui_config["tray_password"] = passhex
        new_gtkui_config["classic_mode"] = self.glade.get_widget("chk_classic_mode").get_active()
        new_gtkui_config["show_rate_in_title"] = self.glade.get_widget("chk_show_rate_in_title").get_active()

        ## Other tab ##
        new_gtkui_config["show_new_releases"] = self.glade.get_widget("chk_show_new_releases").get_active()
        new_core_config["send_info"] = self.glade.get_widget("chk_send_info").get_active()
        new_core_config["geoip_db_location"] = self.glade.get_widget("entry_geoip").get_text()

        ## Daemon tab ##
        new_core_config["daemon_port"] = self.glade.get_widget("spin_daemon_port").get_value_as_int()
        new_core_config["allow_remote"] = self.glade.get_widget("chk_allow_remote_connections").get_active()
        new_core_config["new_release_check"] = self.glade.get_widget("chk_new_releases").get_active()

        ## Proxy tab ##
        new_core_config["proxies"] = {}
        for t in ("peer", "web_seed", "tracker", "dht"):
            new_core_config["proxies"][t] = {}
            new_core_config["proxies"][t]["type"] = self.glade.get_widget("combo_proxy_type_%s" % t).get_active()
            new_core_config["proxies"][t]["port"] = self.glade.get_widget("spin_proxy_port_%s" % t).get_value_as_int()
            new_core_config["proxies"][t]["username"] = self.glade.get_widget("txt_proxy_username_%s" % t).get_text()
            new_core_config["proxies"][t]["password"] = self.glade.get_widget("txt_proxy_password_%s" % t).get_text()
            new_core_config["proxies"][t]["hostname"] = self.glade.get_widget("txt_proxy_server_%s" % t).get_text()

        ## Queue tab ##
        new_core_config["queue_new_to_top"] = self.glade.get_widget("chk_queue_new_top").get_active()
        new_core_config["max_active_seeding"] = self.glade.get_widget("spin_seeding").get_value_as_int()
        new_core_config["max_active_downloading"] = self.glade.get_widget("spin_downloading").get_value_as_int()
        new_core_config["max_active_limit"] = self.glade.get_widget("spin_active").get_value_as_int()
        new_core_config["dont_count_slow_torrents"] = self.glade.get_widget("chk_dont_count_slow_torrents").get_active()
        new_core_config["stop_seed_at_ratio"] = self.glade.get_widget("chk_seed_ratio").get_active()
        new_core_config["remove_seed_at_ratio"] = self.glade.get_widget("chk_remove_ratio").get_active()
        new_core_config["stop_seed_ratio"] = self.glade.get_widget("spin_share_ratio").get_value()
        new_core_config["share_ratio_limit"] = self.glade.get_widget("spin_share_ratio_limit").get_value()
        new_core_config["seed_time_ratio_limit"] = self.glade.get_widget("spin_seed_time_ratio_limit").get_value()
        new_core_config["seed_time_limit"] = self.glade.get_widget("spin_seed_time_limit").get_value()

        ## Cache tab ##
        new_core_config["cache_size"] = self.glade.get_widget("spin_cache_size").get_value_as_int()
        new_core_config["cache_expiry"] = self.glade.get_widget("spin_cache_expiry").get_value_as_int()

        # Run plugin hook to apply preferences
        component.get("PluginManager").run_on_apply_prefs()

        # GtkUI
        for key in new_gtkui_config.keys():
            # The values do not match so this needs to be updated
            if self.gtkui_config[key] != new_gtkui_config[key]:
                self.gtkui_config[key] = new_gtkui_config[key]

        # Core
        if client.connected():
            # Only do this if we're connected to a daemon
            config_to_set = {}
            for key in new_core_config.keys():
                # The values do not match so this needs to be updated
                try:
                    if self.core_config[key] != new_core_config[key]:
                        config_to_set[key] = new_core_config[key]
                except KeyError:
                    config_to_set[key] = new_core_config[key]

            if config_to_set:
                # Set each changed config value in the core
                client.core.set_config(config_to_set)
                client.force_call(True)
                # Update the configuration
                self.core_config.update(config_to_set)

        if hide:
            self.hide()
        else:
            # Re-show the dialog to make sure everything has been updated
            self.show()
Example #12
0
 def _hash(self, username, password):
     return sha_hash(bytes(username + password, encoding='utf8')).hexdigest()