Conky script

Archival storage to keep things organized and uncluttered. Can't find what you need? Search for old topics here.

Moderators: Tech Team, Global Moderators

Forum rules
Please read the Community Guidelines before posting.

Conky script

Postby dijxtra on Wed Nov 18, 2009 12:45 pm

Hi there,

I don't know how many Conky users play CC, but I guess sharing my script with the world won't hurt anybody. So, here it is.

Python script that does the heavy lifting:
Code: Select all
## check-conquerclub.py -- A command line util to check for ready Conquer Club games by Nikola Skoric
## Based on check-gmail.py by Baishampayan Ghose

# ======================================================================
# Copyright (C) 2006 Baishampayan Ghose <b.ghose@ubuntu.com>
# Modified 2009 Nikola Skoric <nskoric@gmail.com>
# Time-stamp: Wed Nov 18 18:12:26 CET 2009
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
# ======================================================================

import sys
import urllib             # For BasicHTTPAuthentication
import feedparser         # For parsing the feed
import re

uname = sys.argv[1]

_URL = "http://www.conquerclub.com/rss.php?username=" + uname

def auth():
    '''The method to do HTTPBasicAuthentication'''
    opener = urllib.FancyURLopener()
    f = opener.open(_URL)
    feed = f.read()
    return feed


def readfeed(feed):
   '''Parse the Atom feed and print a summary'''
   atom = feedparser.parse(feed)
        p = re.compile('Game (\d+) Round (\d+) - (\w+) \((\d{2}hrs \d{2}min) \d{2}sec remaining\)')
        times = []
        for entry in atom.entries:
            #print entry.title
            m = p.match(entry.title)
            if m:
                if m.group(3) == 'READY':
                    times.append(m.group(4))
        if len(times) > 0:
            times.sort()
            p = re.compile('(\d{2})hrs (\d{2})min')
            m = p.match(times[0])
            time = m.group(1) + ":" + m.group(2)
            if len(times) > 1:
                print "%s games ready." % len(times)
            else:
                print "One game ready."
            print "(%s remaining)." % time
        else:
            print "No games ready."


if __name__ == "__main__":
    f = auth()  # Do auth and then get the feed
    readfeed(f) # Let the feed be chewed by feedparser

This python script can be used as shell script like this:
$ python /path/to/script/check-conquerclub.py username
or it can be used in .conkyrc.

This is a line from my .conkyrc:
Code: Select all
${color slate grey}CC: ${color }${execpi 300 python ~/bin/check-conquerclub.py dijxtra}


If you use Conky but are not familiar with such concepts like "shell script" or "writing .conkyrc", here is what you have to do to make this work:
0. I assume you have working conky (for that, you obviously need GNU/Linux system)
1. install python if you don't have it (it's on every sane GNU/Linux system by default)
2. install python-feedparser library if you don't have it (on Ubuntu you do it by typing "sudo apt-get install python-feedparser" in the shell or by using synaptic)
3. copy/paste the python code into file check-conquerclub.py
4. put check-conquerclub.py file somewhere (I propose $HOME/bin)
5. put the sample .conkyrc code I provided at the end of your .conkyrc
6. edit the line to fit your needs:
6.1. instead of "~/bin/check-conquerclub.py" put path to your check-conquerclub.py file
6.2. instead of "dijxtra" put your username
6.3. change "CC: " to "ConquerClub: " or "Risk: " or whatever you see fit
6.4. change the color property to your liking

And that's about it.

If you have questions or need help, just post in this thread and send me a PM reminding me to check this thread out since I won't be checking this thread regularly since I doubt there will be much (if any) replies :-)

Regards,
dijxtra aka Nikola Škorić
Sergeant 1st Class dijxtra
 
Posts: 111
Joined: Sun May 20, 2007 9:26 am
Location: Croatia
Medals: 27
Standard Achievement (2) Doubles Achievement (1) Triples Achievement (1) Quadruples Achievement (1) Terminator Achievement (1)
Freestyle Achievement (1) Fog of War Achievement (2) Teammate Achievement (1) Random Map Achievement (1) Cross-Map Achievement (1)
Clan Achievement (13) Tournament Contribution (1) General Contribution (1)

Re: Conky script

Postby Dako on Thu Nov 19, 2009 6:08 am

I will try it later when I get back home. Don't have conky but will install it and test how it goes.

Thank you!

PS - yay, one more fellow unix user here!
Image
User avatar
Brigadier Dako
 
Posts: 3950
Joined: Sun Aug 26, 2007 9:07 am
Location: St. Petersburg, Russia
Medals: 117
Standard Achievement (3) Doubles Achievement (3) Triples Achievement (3) Quadruples Achievement (3) Terminator Achievement (2)
Assassin Achievement (1) Manual Troops Achievement (2) Freestyle Achievement (2) Polymorphic Achievement (1) Nuclear Spoils Achievement (2)
Fog of War Achievement (3) Trench Warfare Achievement (1) Speed Achievement (1) Teammate Achievement (2) Random Map Achievement (2)
Cross-Map Achievement (3) Battle Royale Achievement (1) Ratings Achievement (3) Tournament Achievement (14) General Achievement (24)
Clan Achievement (21) General Contribution (20)

Re: Conky script

Postby Calidrmr on Tue Aug 16, 2011 2:02 pm

moved to Archives by Calidrmr 8/16/11
reason: abandoned
no shadow topic left in place
Image
<Juan_Bottom>You're like the Barry Bonds of drinking. You don't need the practice you just do it because you like it.
User avatar
Sergeant 1st Class Calidrmr
 
Posts: 640
Joined: Wed Sep 12, 2007 5:00 pm
Location: the corner bar...
Medals: 61
Standard Achievement (2) Doubles Achievement (3) Triples Achievement (3) Quadruples Achievement (3) Terminator Achievement (1)
Assassin Achievement (1) Manual Troops Achievement (1) Freestyle Achievement (1) Nuclear Spoils Achievement (1) Fog of War Achievement (3)
Speed Achievement (1) Teammate Achievement (2) Random Map Achievement (1) Cross-Map Achievement (3) Ratings Achievement (3)
Tournament Achievement (1) General Achievement (10) Clan Achievement (5) Training Achievement (1) General Contribution (15)


Return to Tool Archives

Who is online

Users browsing this forum: No registered users

Login