Merge lp:~jesuisbenjamin/cairo-dock-plug-ins-extras/Facebook into lp:~cairo-dock-team/cairo-dock-plug-ins-extras/third-party

Proposed by benjamin
Status: Merged
Merged at revision: 163
Proposed branch: lp:~jesuisbenjamin/cairo-dock-plug-ins-extras/Facebook
Merge into: lp:~cairo-dock-team/cairo-dock-plug-ins-extras/third-party
Diff against target: 94 lines (+33/-8)
3 files modified
Facebook/Facebook (+31/-6)
Facebook/Facebook.conf (+1/-1)
Facebook/auto-load.conf (+1/-1)
To merge this branch: bzr merge lp:~jesuisbenjamin/cairo-dock-plug-ins-extras/Facebook
Reviewer Review Type Date Requested Status
Matthieu Baerts Approve
Review via email: mp+58882@code.launchpad.net

Description of the change

Added method for handling session without Internet connection (prior version would exit the applet).

To post a comment you must log in.
Revision history for this message
Matthieu Baerts (matttbe) wrote :

Thank you for this new revision!

I've just changed all absolute paths because the dock can use another config directory and your applet can be launched from another folder (don't forget to launch this command to sync your branch with the trunk: bzr pull ;) )

A request: Can you write your emblem.svg file into the "config" directory? The directory where you read the config file (generally it's ~/.config/cairo-dock/current_theme/plug-ins/Facebook but it's better to use the path of the config file (Facebook.conf) which can be found in CDApplet => self.cConfFile = sys.argv[3] => can you use it and remove "/Facebook.conf" from this variable?). Simply because it's possible that you can't modify a file into the directory of the applet, e.g. if your applet is installed in /usr/share/cairo-dock/plug-ins/Dbus/third-party/Facebook.

A detail: Also, is it possible to move the svg code from the 'Facebook' file to another? Because this is only one line with 32545 characters (it's a bit too long ^^)

review: Approve
Revision history for this message
benjamin (jesuisbenjamin) wrote :

Hi Matt,

thanks, i didn't know about the os.abspath() thing.

I can write the emblem with the user configuration file, but i don't understand what you meand with the sefl.cConfFile =sys.arg[3] and removing the /Facebook.conf from the variable. I have not used the file name but referred to it as self.keyfile in the code. (??) Besides i know the usage of sys.arg[3] when arguments are passed in the main function from command line but i don't know in this case what you refer to (i don't know how CD launches the applet exactly).

I can keep the original svg xml in a separate file yes.

Revision history for this message
Matthieu Baerts (matttbe) wrote :

> I can write the emblem with the user configuration file, but i don't understand what you meand with the sefl.cConfFile =sys.arg[3] and removing the /Facebook.conf from the variable.
Yes, sorry for my poor English...
In your "Facebook" file, I can see that the svg file (emblem.svg) can be modified. But this file can be protected, it's possible that you can't erase/modify it (e.g. if your applet is installed in "/usr/share/cairo-dock/plug-ins/Dbus/third-party/Facebook" where you've to be 'root' to write something in this directory).
OTOH there is another directory where you can write a file: the directory where the config file (Facebook.conf) is located. And you can have the complete path of your config file by using this variable: self.cConfFile or this command: sys.argv[3]

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Facebook/Facebook'
2--- Facebook/Facebook 2011-04-22 19:25:38 +0000
3+++ Facebook/Facebook 2011-04-23 22:03:27 +0000
4@@ -329,10 +329,29 @@
5 pass
6 # that's it: now the applet waits for the next update :)
7
8+ def error(self):
9+ #signal the applet is in difficulty by adding a [!] emblem to the icon:
10+ # reset icon:
11+ self.icon.SetIcon("~/.config/cairo-dock/third-party/Facebook/icon")
12+ # put warning svg emblem on icon
13+ self.icon.SetEmblem("~/.config/cairo-dock/third-party/Facebook/warning.svg", CDApplet.UPPER_RIGHT)
14+
15 def read_fb(self):
16+ # reset fblist
17+ print "reading facebook"
18+ fblist = []
19 # this method fetches information from FaceBook with fbcmd
20 # it runs the "fbcmd NOTIFY" command, returns and parses results in a "fblist" list
21- fblist = os.popen("fbcmd NOTIFY").readlines()
22+ result = subprocess.Popen(['fbcmd', 'NOTIFY'], stdout=PIPE).stdout
23+ fblist = result.readlines()
24+ print fblist
25+ # if there is no internet connection, the list will be empty
26+ if fblist != []:
27+ pass
28+ else:
29+ print '...Facebook Applet could not connect to the Internet. Trying later.'
30+ self.error()
31+ return False
32 # then it omits friend request details and feeds the result into a the "self.fb" dictionary
33 for i in fblist:
34 ii = i.split()
35@@ -346,7 +365,8 @@
36 pass
37 # next the method runs "fbcmd NOTICES unread", returns and parse results in self.fb
38 # first fetch the data
39- ls = os.popen('fbcmd NOTICES unread').readlines()
40+ result = subprocess.Popen(['fbcmd', 'NOTICES', 'unread'], stdout=PIPE).stdout
41+ ls = result.readlines()
42 # remove the header if any
43 try:
44 del ls[0]
45@@ -361,7 +381,8 @@
46 self.fb['NOTICES_UNREAD'] = count
47 except:
48 self.fb['NOTICES_UNREAD'] = 0
49-
50+ return True
51+
52 def update(self):
53 # this method updates the information from Facebook
54 # but first it needs to know whether the cairo-dock process still exists
55@@ -372,9 +393,13 @@
56 # since the findcairo() method should have terminated the program
57 # in case cairo-dock does not exist, there is no need to check again
58 # the update method continues asking read_fb() to fetch data from Facebook
59- self.read_fb()
60- # then it checks whether there is any need to alarm the user
61- self.consider()
62+ try_read = self.read_fb()
63+ if try_read == True:
64+ print try_read
65+ # then it checks whether there is any need to alarm the user
66+ self.consider()
67+ else:
68+ pass
69 # returning master=True will tell the repeat method to continue
70 return master
71
72
73=== modified file 'Facebook/Facebook.conf'
74--- Facebook/Facebook.conf 2011-04-22 19:25:38 +0000
75+++ Facebook/Facebook.conf 2011-04-23 22:03:27 +0000
76@@ -1,4 +1,4 @@
77-#!en;1.11.04.22
78+#!en;1.11.04.23
79
80 #[gtk-about]
81 [Icon]
82
83=== modified file 'Facebook/auto-load.conf'
84--- Facebook/auto-load.conf 2011-04-22 19:25:38 +0000
85+++ Facebook/auto-load.conf 2011-04-23 22:03:27 +0000
86@@ -9,7 +9,7 @@
87 category = 3
88
89 # Version of the applet; change it everytime you change something in the config file. Don't forget to update the version both in this file and in the config file.
90-version = 1.11.04.22
91+version = 1.11.04.23
92
93 # Default icon to use if no icon has been defined by the user. If not specified, or if the file is not found, the "icon" file will be used.
94 icon =

Subscribers

People subscribed via source and target branches

to all changes: