Merge lp:~mcielen/gwibber/cwibber_0.1 into lp:~segphault/gwibber/service-split

Proposed by Martijn Cielen
Status: Needs review
Proposed branch: lp:~mcielen/gwibber/cwibber_0.1
Merge into: lp:~segphault/gwibber/service-split
Diff against target: None lines
To merge this branch: bzr merge lp:~mcielen/gwibber/cwibber_0.1
Reviewer Review Type Date Requested Status
Ken VanDine (community) Disapprove
Review via email: mp+10583@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Martijn Cielen (mcielen) wrote :

added cwibber, a cli interface to gwibber, to use with eg conky

Revision history for this message
Ken VanDine (ken-vandine) wrote :

Sorry this took so long to get reviewed, the client has been re-written.

Thanks for your submission.

review: Disapprove

Unmerged revisions

375. By root <root@tijnEEE>

cwibber is a cli script to get microblogging feeds.
Useful in combination with eg conky.
Uses the Gwibber 2.0 daemon.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'bin/cwibber'
2--- bin/cwibber 1970-01-01 00:00:00 +0000
3+++ bin/cwibber 2009-08-23 22:58:39 +0000
4@@ -0,0 +1,89 @@
5+#!/usr/bin/env python
6+
7+"""
8+Cwibber v0.1
9+Blizzkid (Martijn Cielen) - 20090820
10+
11+A python script to get your microblogging feeds in your shell.
12+Currently supports Facebook, Identica and Twitter.
13+Uses the Gwibber 2 Gwibber-daemon and dbus.
14+Thanks to Ryan Paul (Segphault) for the initial code snippet
15+
16+Changelog
17+v0.1: initial release
18+
19+"""
20+
21+import dbus, dbus.glib, re, sys, subprocess
22+
23+"""
24+CONFIGURATION
25+"""
26+
27+# configuration of number of messages you want to see for each service, set to 0 to disable
28+ct_fb = 2 # Facebook
29+ct_tw = 2 # Twitter
30+ct_id = 2 # Identi.ca
31+
32+# set fb_cmt to 0 to disable Facebook comments. Set to 1 to show last 3 comments
33+fb_cmt = 1
34+
35+# set sh_ttl to 0 to disable category headers. Set to 1 to enable
36+sh_ttl = 1
37+
38+"""
39+DO NOT edit below this line
40+"""
41+
42+# define function to remove html tags in Facebook extended text.
43+def remove_html_tags(data):
44+ p = re.compile(r'<.*?>')
45+ return p.sub('', data)
46+
47+"""
48+This should be enabled once gwibber-daemon's refresh interval is specified in gconf
49+
50+
51+# check whether gwibber-daemon is running. If not, start it.
52+output = subprocess.Popen(['ps', '-Af'], stdout=subprocess.PIPE).stdout.read()
53+if not "gwibber" in output:
54+ try:
55+ retcode = subprocess.Popen("./gwibber-daemon", shell=True)
56+ if retcode < 0:
57+ print >>sys.stderr, "Child was terminated by signal", -retcode
58+ else:
59+ print >>sys.stderr, "Child returned", retcode
60+ except OSError, e:
61+ print >>sys.stderr, "Execution failed:", e
62+"""
63+
64+# dbus call - credits to Ryan Paul
65+bus = dbus.SessionBus()
66+obj = bus.get_object("com.Gwibber", "/com/gwibber/Messages")
67+messages = dbus.Interface(obj, "com.Gwibber")
68+
69+# facebook
70+if ct_fb > 0:
71+ if sh_ttl == 1:
72+ print "FACEBOOK"
73+ for message in messages.get_messages(["facebook"],ct_fb)["messages"]:
74+ print "%s: %s %s" % (message["sender"], message["text"], remove_html_tags(message["extended_text"]))
75+ if fb_cmt > 0:
76+ for comment in message["comments"]:
77+ print " %s: %s" % (comment["sender"], comment["text"])
78+ print "\n"
79+
80+# twitter
81+if ct_tw > 0:
82+ if sh_ttl == 1:
83+ print "TWITTER"
84+ for message in messages.get_messages(["twitter"],ct_tw)["messages"]:
85+ print "%s: %s" % (message["sender"], message["text"])
86+ print "\n"
87+
88+# identi.ca
89+if ct_id > 0:
90+ if sh_ttl == 1:
91+ print "IDENTI.CA"
92+ for message in messages.get_messages(["identica"],ct_id)["messages"]:
93+ print "%s: %s" % (message["sender"], message["text"])

Subscribers

People subscribed via source and target branches