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

Subscribers

People subscribed via source and target branches