Main index > About new desklets > Internode ISP usage meter

By cs-cam (Desklet Author), on Wed Apr 6 07:44:54 2005: Internode ISP usage meter.

Hey all,

My first attempt at a desklet and my first attempt at python so this is probably a little rough. Just a usage meter for my ISP (http://internode.on.net), may not be of much use to other people but it was a good experiment and I'm planning on writing something for modubar so it'll draw an extra icon which is the internode logo with the percentage used written over it or maybe displayed on mouse over. Just thought I'd share and ask if anybody knows where I could host a tarball as I don't have any web space to put it at the moment.

Ta :)

By ZeroDivide (Desklet Author), on Wed Apr 6 15:51:38 2005.

hello cs-cam,

Check this site out for hosting your tarball http://www.myfilebin.com/index.php
It gives you 20MB of space with a limit of 2MB per file.

ZeroDivide

By cs-cam (Desklet Author), on Wed Apr 6 18:39:14 2005.

Thanks for the link. Here it is

http://www.myfilebin.com/userfiles/cam/internode-0.0.1.tar.gz

Since I'm new at python I didn't use any python commands to fetch the data from the net, just read the output of a wget so if anyone has any suggestions or links where I can look to see how it's done properly that'd be great :)

By syfou (Core Developer & Desklet Author), on Wed Apr 6 18:57:17 2005.

Hi,

What you are looking for is probably urllib2, as it supports authentification and http over TLS.

A few other tips... This code:

Code:


used = float(outtext.split()[0])
total = float(outtext.split()[1])


could be expressed as:

Code:


used, total = [float(num) for num in outtext.split()]


And in fact, since you did let Python garbage collect the pipe anyway, you coud just have done:

Code:


used, total = [float(num) for num in os.popen('{%s;} 2>&1 ' % cmd, 'r').read() ]



You should also use some exception handling to avoid crahes when the information cannot be retrieved, just displaying some "Data not available" message then...

By cs-cam (Desklet Author), on Wed Apr 6 23:10:25 2005.

Thanks for the tips, as I sid, first go at Python but I'll get there :) I'll rewrite it and see how it goes then, just gotta find some free time :roll:

By cs-cam (Desklet Author), on Mon Apr 11 02:11:31 2005, last edited on Mon Apr 11 02:17:03 2005.

http://www.myfilebin.com/userfiles/cam/internode-0.0.2.tar.gz

Hows that look? Once I get the okay from you guys that it's not that bad I'm gonna submit it to the ISP since they maintain a page with similar tools.

Well I just did an experiment with the phony login detals and it bugs out. Get python errors in the console and the desklet fails to start, what did I mess up? Going from my best guess, if the code inside the try: block failed to execute then wouldn't it execute the except: code? Or do I need to try and catch a more generic exception?

By syfou (Core Developer & Desklet Author), on Mon Apr 11 02:14:01 2005.

I have to leave town in a few hours for a day... I will look at it right when I am back.

By cs-cam (Desklet Author), on Mon Apr 11 02:19:08 2005.

Thanks, no rush it's taken me almost a week to make those few changes you told me above. I don't have as much free time as I'd like to have either :)

By syfou (Core Developer & Desklet Author), on Wed Apr 13 17:32:44 2005.

Hi cs-cam,
I just read 0.0.2 iteration. Here are some remarks:

Nothing else to say, really...If you feel this can be useful to others, feel free to submit it for official inclusion... But it's up to you to decide. :-)


adesklets is proud to be hosted on:

SourceForge.net Logo

Back to adesklets.sf.net.