Exemple #1
0
def write_scripts(network, network_type, script_info):
    """ Writes script info to disk and loads it into the daemon. """
    if network_type == "wired":
        con = ConfigManager(wired_conf)
        con.set(network, "beforescript", script_info["pre_entry"])
        con.set(network, "afterscript", script_info["post_entry"])
        con.set(network, "predisconnectscript", script_info["pre_disconnect_entry"])
        con.set(network, "postdisconnectscript", script_info["post_disconnect_entry"])
        con.write(open(wired_conf, "w"))
        wired.ReloadConfig()
        wired.ReadWiredNetworkProfile(network)
        wired.SaveWiredNetworkProfile(network)
    else:
        bssid = wireless.GetWirelessProperty(int(network), "bssid")
        con = ConfigManager(wireless_conf)
        con.set(bssid, "beforescript", script_info["pre_entry"])
        con.set(bssid, "afterscript", script_info["post_entry"])
        con.set(bssid, "predisconnectscript", script_info["pre_disconnect_entry"])
        con.set(bssid, "postdisconnectscript", script_info["post_disconnect_entry"])
        con.write(open(wireless_conf, "w"))
        wireless.ReloadConfig()
        wireless.ReadWirelessNetworkProfile(int(network))
        wireless.SaveWirelessNetworkProfile(int(network))
def write_scripts(network, network_type, script_info):
    """ Writes script info to disk and loads it into the daemon. """
    if network_type == "wired":
        con = ConfigManager(wired_conf)
        con.set(network, "beforescript", script_info["pre_entry"])
        con.set(network, "afterscript", script_info["post_entry"])
        con.set(network, "predisconnectscript",
                script_info["pre_disconnect_entry"])
        con.set(network, "postdisconnectscript",
                script_info["post_disconnect_entry"])
        con.write()
        wired.ReloadConfig()
        wired.ReadWiredNetworkProfile(network)
        wired.SaveWiredNetworkProfile(network)
    else:
        bssid = wireless.GetWirelessProperty(int(network), "bssid")
        con = ConfigManager(wireless_conf)
        con.set(bssid, "beforescript", script_info["pre_entry"])
        con.set(bssid, "afterscript", script_info["post_entry"])
        con.set(bssid, "predisconnectscript",
                script_info["pre_disconnect_entry"])
        con.set(bssid, "postdisconnectscript",
                script_info["post_disconnect_entry"])
        con.write()
        wireless.ReloadConfig()
        wireless.ReadWirelessNetworkProfile(int(network))
        wireless.SaveWirelessNetworkProfile(int(network))
Exemple #3
0
def get_script_info(network, network_type):
    """ Read script info from disk and load it into the configuration dialog """
    info = {}
    if network_type == "wired":
        con = ConfigManager(wired_conf)
        if con.has_section(network):
            info["pre_entry"] = con.get(network, "beforescript", None)
            info["post_entry"] = con.get(network, "afterscript", None)
            info["pre_disconnect_entry"] = con.get(network, "predisconnectscript", None)
            info["post_disconnect_entry"] = con.get(network, "postdisconnectscript", None)
    else:
        bssid = wireless.GetWirelessProperty(int(network), "bssid")
        con = ConfigManager(wireless_conf)
        if con.has_section(bssid):
            info["pre_entry"] = con.get(bssid, "beforescript", None)
            info["post_entry"] = con.get(bssid, "afterscript", None)
            info["pre_disconnect_entry"] = con.get(bssid, "predisconnectscript", None)
            info["post_disconnect_entry"] = con.get(bssid, "postdisconnectscript", None)
    return info
def get_script_info(network, network_type):
    """ Read script info from disk and load it into the configuration dialog """
    info = {}
    if network_type == "wired":
        con = ConfigManager(wired_conf)
        if con.has_section(network):
            info["pre_entry"] = con.get(network, "beforescript", None)
            info["post_entry"] = con.get(network, "afterscript", None)
            info["pre_disconnect_entry"] = con.get(network,
                                                   "predisconnectscript", None)
            info["post_disconnect_entry"] = con.get(network,
                                                    "postdisconnectscript",
                                                    None)
    else:
        bssid = wireless.GetWirelessProperty(int(network), "bssid")
        con = ConfigManager(wireless_conf)
        if con.has_section(bssid):
            info["pre_entry"] = con.get(bssid, "beforescript", None)
            info["post_entry"] = con.get(bssid, "afterscript", None)
            info["pre_disconnect_entry"] = con.get(bssid,
                                                   "predisconnectscript", None)
            info["post_disconnect_entry"] = con.get(bssid,
                                                    "postdisconnectscript",
                                                    None)
    return info