Пример #1
0
def amule_cb(word, word_eol, userdata):
    """Read aMule's onlinesig file and shows up/down speeds and total
    downloaded in the active channel.
    Arguments:
    word     -- array of strings sent by HexChat/X-Chat to every hook (ignored)
    word_eol -- array of strings sent by HexChat/X-Chat to every hook (ignored)
    userdata -- optional variable that can be sent to a hook (ignored)
    """
    if path.exists(_AMULESIG):
        lines = open(_AMULESIG, "r").readlines()
        if lines[0] == "0":
            helper.gprint("aMule isn't connected")
        else:
            down_speed = (lines[6])[0:-1]
            up_speed = (lines[7])[0:-1]
            total_down = helper.units(int(lines[11]), 1024)
            version = lines[13][0:-1]
            xchat.command("".join(["say ( aMule ", version, " )",
                                   " Download: ", down_speed, "KB/s -",
                                   " Upload: ", up_speed, "KB/s -"
                                   " Downloaded: ", total_down]))
    else:
        helper.gprint([_AMULESIG, " file does not exist, check whether you",
                       " have 'Online signature' enabled in your aMule",
                       " settings"])
    return xchat.EAT_ALL
Пример #2
0
def transmission_cb(word, word_eol, userdata):
    """Reads transmission's stats file and show total Upload and Download in
    the active channel
    Arguments:
    word     -- array of strings sent by HexChat/X-Chat to every hook (ignored)
    word_eol -- array of strings sent by HexChat/X-Chat to every hook (ignored)
    userdata -- optional variable that can be sent to a hook (ignored)
    """
    if path.exists(_TRANSMISSIONSTATS):
        lines = open(_TRANSMISSIONSTATS, "r").readlines()
        downloaded = helper.units(int(lines[1].split(":")[1][1:-3]), 1024)
        uploaded = helper.units(int(lines[5].split(":")[1][1:-1]), 1024)
        xchat.command("".join(["say ( Transmission ) Downloaded: ", downloaded,
                               " - Uploaded: ", uploaded]))
    else:
        helper.gprint("".join(["There is no stats file. Please, check your",
                               " Transmission setting"]))
    return xchat.EAT_ALL
Пример #3
0
def network_cb(word, word_eol, userdata):
    """Shows network information on the active channel.
    Arguments:
    word     -- array of strings sent by HexChat/X-Chat to every hook (ignored)
    word_eol -- array of strings sent by HexChat/X-Chat to every hook (ignored)
    userdata -- optional variable that can be sent to a hook (ignored)
    """
    # Find all devices and show a line for each one
    net = re.compile('eth|ath|wlan|ra([0-9]):')
    hostname = platform.node()
    for line in file("/proc/net/dev"):
        if net.search(line):
            device = line.split(":")[0].split()[-1]
            parts = line[:-1].split(":")[1].split()
            received = helper.units(int(parts[0]), 1024)
            sent = helper.units(int(parts[8]), 1024)
            command = "".join(["say [ Network ] Device: ", device,
                               "  - Hostname: ", hostname, "  - Received: ",
                               received, "  - Sent: ", sent])
            xchat.command(command)
    return xchat.EAT_ALL