Note that there are some explanatory texts on larger screens.

plurals
  1. POPython IRC bot system uptime
    primarykey
    data
    text
    <p>I'm trying to show system uptime in my irc bot. The script I'm using is:</p> <pre><code> #linux import os, sys from datetime import timedelta from util import hook import subprocess import datetime @hook.command def uptime_linux(inp,say=None): with open('/proc/uptime', 'r') as f: uptime_seconds = float(f.readline().split()[0]) uptime_string = str(timedelta(seconds = uptime_seconds)) say(uptime_string) # windows def uptime(): """Returns a datetime.timedelta instance representing the uptime in a Windows 2000/NT/XP machine""" if not sys.platform.startswith('win'): raise RuntimeError, "This function is to be used in windows only" cmd = "net statistics server" p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE) (child_stdin, child_stdout) = (p.stdin, p.stdout) lines = child_stdout.readlines() child_stdin.close() child_stdout.close() lines = [line.strip() for line in lines if line.strip()] date, time, ampm = lines[1].split()[2:5] #print date, time, ampm m, d, y = [int(v) for v in date.split('/')] H, M = [int(v) for v in time.split(':')] if ampm.lower() == 'pm': H += 12 now = datetime.datetime.now() then = datetime.datetime(y, m, d, H, M) diff = now - then return diff @hook.command def uptime_win(inp,say=None): if __name__ == '__main__': say(uptime()) </code></pre> <p>It doesn't give me an error, but it doesn't show. I've looked at the code, I don't see why I'm not able to see it.Maybe it might something small but I don't see it :D. I have the needed modules included, and it still doesn't work :'(. Also I'd want to ask if any of you have easier method to get uptime for windows (I have for linux already).Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload