← Back to team overview

cairo-dock-team team mailing list archive

[Merge] lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Moon into lp:cairo-dock-plug-ins-extras

 

Eduardo Mucelli Rezende Oliveira has proposed merging lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Moon into lp:cairo-dock-plug-ins-extras.

Requested reviews:
  Cairo-Dock Team (cairo-dock-team)

For more details, see:
https://code.launchpad.net/~eduardo-mucelli/cairo-dock-plug-ins-extras/Moon/+merge/60734

This applet displays the moon phases as its own icon, and some informations about the current moon.
-- 
https://code.launchpad.net/~eduardo-mucelli/cairo-dock-plug-ins-extras/Moon/+merge/60734
Your team Cairo-Dock Team is requested to review the proposed merge of lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Moon into lp:cairo-dock-plug-ins-extras.
=== added directory 'Moon'
=== added file 'Moon/ChangeLog'
--- Moon/ChangeLog	1970-01-01 00:00:00 +0000
+++ Moon/ChangeLog	2011-05-12 07:36:37 +0000
@@ -0,0 +1,1 @@
+0.0.1: (May/12/2011): Moon applet was created with the possibility to show the moon phases as its own icon, and to show some informations. The service used in this applet was created by Brian Casey -- http://www.briancasey.org/artifacts/astro/moon.cgi

=== added file 'Moon/Moon'
--- Moon/Moon	1970-01-01 00:00:00 +0000
+++ Moon/Moon	2011-05-12 07:36:37 +0000
@@ -0,0 +1,104 @@
+#!/usr/bin/python
+
+# This is a part of the external Moon applet for Cairo-Dock
+#
+# Author: Eduardo Mucelli Rezende Oliveira
+# E-mail: edumucelli@xxxxxxxxx or eduardom@xxxxxxxxxxx
+#
+# This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#    GNU General Public License for more details.
+
+# This applet displays the moon phases as its own icon, 
+# and some informations about the current moon
+
+import urllib, urllib2, datetime, os, re
+from sgmllib import SGMLParser
+from urllib import FancyURLopener
+
+from util import log
+from CDApplet import CDApplet
+
+from MoonCalendarParser import MoonCalendarParser
+
+class AgentOpener(FancyURLopener):
+    """Masked user-agent otherwise the access would be forbidden"""
+    version = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11'
+
+class Interface:
+
+    def __init__(self, year, month, day):
+        self.year, self.month, self.day = year, month, day
+        self.information = ""
+        self.moon_image = ""
+
+    def fetch(self):
+        parser = MoonCalendarParser()
+        opener = AgentOpener()                                                      # opens the web connection with masked user-agent
+        params = urllib.urlencode({'year': self.year, 'month': self.month, 'day': self.day})
+
+        try:
+            page = urllib2.urlopen(parser.url, params)                              # get the HTML
+        except IOError:
+            log ("Problem to open %s" % (parser.url))
+        else:
+            parser.parse(page.read())                                               # feed the parser to get the specific content: translated text
+            page.close()                                                            # lets close the page connection
+            self.information = parser.information
+            self.moon_image = parser.moon_image
+        return self.moon_image, self.information
+
+# TODO: Use this struct to build the week structure in order to
+# maintain the information about the moon for the next seven days
+#class Data:
+#    def __init__(self, **kwds):
+#        self.__dict__.update(kwds)
+
+class Applet(CDApplet):
+
+    def inform_start_of_waiting_process(self):
+        self.icon.SetQuickInfo("...")
+
+    def inform_end_of_waiting_process(self):
+        self.icon.SetQuickInfo("")
+
+    def get_moon_from_web(self):
+        self.inform_start_of_waiting_process()
+
+        interface = Interface(self.year, self.month, self.day)
+        image, information = interface.fetch()
+        self.information = re.sub("\s+\n\s+" , " \n", information)                                 # " ".join(information.split())
+        # os.popen("wget -N -q http://www.briancasey.org/artifacts/astro/image/%s -O %s" % (image, os.path.abspath("./data/%s" % (image))))
+        self.icon.SetIcon(os.path.abspath("./data/%s" % image))
+
+        self.inform_end_of_waiting_process()
+
+    def __init__(self):
+
+        self.year, self.month, self.day = datetime.date.today().timetuple()[:3]
+        self.information = ""
+        self.moon_image = ""
+        self.week = []
+        self.dialog_active_time = 30                                                    # time in seconds that the dialog window will be active
+
+        CDApplet.__init__(self)                                                         # call high-level init
+
+    # Inherited methods from CDApplet
+    def begin(self):
+        self.get_moon_from_web()
+
+    def reload(self):
+        self.get_moon_from_web()                                                        # refresh the moon informations
+
+    # Callbacks
+    def on_click(self, key):
+        self.icon.PopupDialog({'message':self.information, 'time-length':self.dialog_active_time},{})
+
+if __name__ == '__main__':
+	Applet().run()

=== added file 'Moon/Moon.conf'
--- Moon/Moon.conf	1970-01-01 00:00:00 +0000
+++ Moon/Moon.conf	2011-05-12 07:36:37 +0000
@@ -0,0 +1,99 @@
+#!en;0.0.1
+
+#[gtk-about]
+[Icon]
+#F[Applet]
+frame_maininfo=
+
+#d Name of the dock it belongs to:
+dock name = 
+
+#s Name of the icon as it will appear in its caption in the dock:
+name = Moon
+
+#F[Display]
+frame_display=
+
+#S+ Image's filename :
+#{Let empty to use the default one.}
+icon = 
+
+#j+[0;128] Desired icon size for this applet
+#{Set to 0 to use the default applet size}
+icon size = 0;0
+
+order=
+
+#F[Applet's Handbook]
+frame_hand=
+#A
+handbook=Moon
+
+
+#[gtk-convert]
+[Desklet]
+
+#j+[48;512] Desklet's dimension (width x height) :
+#{Depending on your WindowManager, you can resize it with ALT + middle_click or ALT + left_click for exemple.}
+size = 164;96
+
+#i[-2048;2048] Desklet's position (x ; y) :
+#{Depending on your WindowManager, you can move it with ALT + left_click}
+x position=0
+#i[-2048;2048] ...
+y position=0
+
+#b Is detached from the dock ?
+initially detached=false
+#l[Normal;Keep above;Keep below;On Widget Layer;Reserve space] Accessibility :
+#{for CompizFusion's "widget layer", set behaviour in Compiz to: (class=Cairo-dock & type=utility)}
+accessibility=0
+#b Should be visible on all desktops ?
+sticky=true
+
+#b Lock position ?
+#{If locked, the desklet can't be moved by simply dragging it with the left mouse button. Of course you can still move it with ALT + left_click.}
+locked = false
+
+#I[-180;180] Rotation :
+#{in degrees.}
+rotation = 0
+
+use size=
+
+#F[Decorations;gtk-orientation-portrait]
+frame_deco=
+
+#o+ Choose a decoration theme for this desklet :
+#{Choose the 'personnal' one to define your own decorations below.}
+decorations = default
+
+#v
+sep_deco =
+
+#S+ Background image :
+#{It's an image that will be displayed below the drawings, like a frame for exemple. Let empty to not use any.}
+bg desklet =
+#e+[0;1] Background tansparency :
+bg alpha = 1
+#i+[0;256] Left offset :
+#{in pixels. Use this to adjust the left position of the drawings.}
+left offset = 0
+#i+[0;256] Top offset :
+#{in pixels. Use this to adjust the top position of the drawings.}
+top offset = 0
+#i+[0;256] Right offset :
+#{in pixels. Use this to adjust the right position of the drawings.}
+right offset = 0
+#i+[0;256] Bottom offset :
+#{in pixels. Use this to adjust the bottom position of the drawings.}
+bottom offset = 0
+#S+ Foreground image :
+#{It's an image that will be displayed above the drawings, like a reflect for exemple. Let empty to not use any.}
+fg desklet =
+#e+[0;1] Foreground tansparency :
+fg alpha = 1
+
+
+#[gtk-preferences]
+[Configuration]

=== added file 'Moon/MoonCalendarParser.py'
--- Moon/MoonCalendarParser.py	1970-01-01 00:00:00 +0000
+++ Moon/MoonCalendarParser.py	2011-05-12 07:36:37 +0000
@@ -0,0 +1,38 @@
+# This is a part of the external Moon applet for Cairo-Dock
+#
+# Author: Eduardo Mucelli Rezende Oliveira
+# E-mail: edumucelli@xxxxxxxxx or eduardom@xxxxxxxxxxx
+
+from sgmllib import SGMLParser
+
+class MoonCalendarParser(SGMLParser):
+
+    def reset(self):                              
+        SGMLParser.reset(self)
+        self.url = "http://www.briancasey.org/artifacts/astro/moon.cgi";
+        self.information = ""
+        self.moon_image = ""
+        self.inside_td_element = False                                              # indica se o parser esta dentro de <td></td> tag
+        self.stop_parsing = False                                                   # identifies the end of the useful data
+
+    def start_img(self, attrs):
+        self.moon_image = (dict(attrs)["src"]).split('/')[-1]                       # /image/moon06b.gif => moon06b.gif
+
+    def start_td(self, attrs):
+        for name, value in attrs:
+            if name == "width" and value == "225":                                  # the useful information is all before this td
+                self.stop_parsing = True                                            # i was lucky that there is this google ad td which
+        self.inside_td_element = True                                               # that could be the referential to the end of the parsing
+
+    def end_td(self):
+        self.inside_td_element = False
+
+    def handle_data(self, text):
+        if not self.stop_parsing:
+            if self.inside_td_element:
+                # self.information.append(text)
+                self.information += text
+
+    def parse(self, page):
+        self.feed(page)                                                             # feed the parser with the page's html
+        self.close()

=== added file 'Moon/README'
--- Moon/README	1970-01-01 00:00:00 +0000
+++ Moon/README	2011-05-12 07:36:37 +0000
@@ -0,0 +1,6 @@
+# Contact me
+
+Any doubt, suggestion or anything else, except asking for some money, I would be pleased to received a message from you. :¬)
+
+Author: Eduardo Mucelli Rezende Oliveira
+E-mail: edumucelli@xxxxxxxxx or eduardom@xxxxxxxxxxx

=== added file 'Moon/auto-load.conf'
--- Moon/auto-load.conf	1970-01-01 00:00:00 +0000
+++ Moon/auto-load.conf	2011-05-12 07:36:37 +0000
@@ -0,0 +1,16 @@
+[Register]
+
+# Author of the applet
+author = Eduardo Mucelli Rezende Oliveira
+
+# A short description of the applet and how to use it.
+description = This applet displays the moon phases as its own icon and some informations about the current moon
+
+# Category of the applet : 2 = files, 3 = internet, 4 = Desktop, 5 = accessory, 6 = system, 7 = fun
+category = 5
+
+# 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.
+version = 0.0.1
+
+# Whether the applet can be instanciated several times or not.
+multi-instance = true

=== added directory 'Moon/data'
=== added file 'Moon/data/moon00a.gif'
Binary files Moon/data/moon00a.gif	1970-01-01 00:00:00 +0000 and Moon/data/moon00a.gif	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/data/moon01a.gif'
Binary files Moon/data/moon01a.gif	1970-01-01 00:00:00 +0000 and Moon/data/moon01a.gif	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/data/moon01b.gif'
Binary files Moon/data/moon01b.gif	1970-01-01 00:00:00 +0000 and Moon/data/moon01b.gif	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/data/moon02a.gif'
Binary files Moon/data/moon02a.gif	1970-01-01 00:00:00 +0000 and Moon/data/moon02a.gif	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/data/moon02b.gif'
Binary files Moon/data/moon02b.gif	1970-01-01 00:00:00 +0000 and Moon/data/moon02b.gif	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/data/moon03a.gif'
Binary files Moon/data/moon03a.gif	1970-01-01 00:00:00 +0000 and Moon/data/moon03a.gif	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/data/moon03b.gif'
Binary files Moon/data/moon03b.gif	1970-01-01 00:00:00 +0000 and Moon/data/moon03b.gif	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/data/moon04a.gif'
Binary files Moon/data/moon04a.gif	1970-01-01 00:00:00 +0000 and Moon/data/moon04a.gif	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/data/moon04b.gif'
Binary files Moon/data/moon04b.gif	1970-01-01 00:00:00 +0000 and Moon/data/moon04b.gif	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/data/moon05a.gif'
Binary files Moon/data/moon05a.gif	1970-01-01 00:00:00 +0000 and Moon/data/moon05a.gif	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/data/moon05b.gif'
Binary files Moon/data/moon05b.gif	1970-01-01 00:00:00 +0000 and Moon/data/moon05b.gif	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/data/moon06a.gif'
Binary files Moon/data/moon06a.gif	1970-01-01 00:00:00 +0000 and Moon/data/moon06a.gif	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/data/moon06b.gif'
Binary files Moon/data/moon06b.gif	1970-01-01 00:00:00 +0000 and Moon/data/moon06b.gif	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/data/moon07a.gif'
Binary files Moon/data/moon07a.gif	1970-01-01 00:00:00 +0000 and Moon/data/moon07a.gif	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/data/moon07b.gif'
Binary files Moon/data/moon07b.gif	1970-01-01 00:00:00 +0000 and Moon/data/moon07b.gif	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/data/moon08a.gif'
Binary files Moon/data/moon08a.gif	1970-01-01 00:00:00 +0000 and Moon/data/moon08a.gif	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/data/moon08b.gif'
Binary files Moon/data/moon08b.gif	1970-01-01 00:00:00 +0000 and Moon/data/moon08b.gif	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/data/moon09a.gif'
Binary files Moon/data/moon09a.gif	1970-01-01 00:00:00 +0000 and Moon/data/moon09a.gif	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/data/moon09b.gif'
Binary files Moon/data/moon09b.gif	1970-01-01 00:00:00 +0000 and Moon/data/moon09b.gif	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/data/moon10a.gif'
Binary files Moon/data/moon10a.gif	1970-01-01 00:00:00 +0000 and Moon/data/moon10a.gif	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/data/moon10b.gif'
Binary files Moon/data/moon10b.gif	1970-01-01 00:00:00 +0000 and Moon/data/moon10b.gif	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/icon'
Binary files Moon/icon	1970-01-01 00:00:00 +0000 and Moon/icon	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/preview'
Binary files Moon/preview	1970-01-01 00:00:00 +0000 and Moon/preview	2011-05-12 07:36:37 +0000 differ
=== added file 'Moon/util.py'
--- Moon/util.py	1970-01-01 00:00:00 +0000
+++ Moon/util.py	2011-05-12 07:36:37 +0000
@@ -0,0 +1,9 @@
+#!/usr/bin/python
+
+# This is a part of the external Moon applet for Cairo-Dock
+#
+# Author: Eduardo Mucelli Rezende Oliveira
+# E-mail: edumucelli@xxxxxxxxx or eduardom@xxxxxxxxxxx
+
+def log (string):
+    print "[+] Moon: %s" % string


Follow ups