Home Forums Wiki Doc Install Extras Screenshots Source Code Projects Blog Users Groups Register
Glx-Dock / Cairo-Dock List of forums Git Version | Version Git Bug applets externes BZR avec Archlinux et dérivés
The latest stable release is the *3.4.0* : How to install it here.
Note: We just switched from BZR to Git on Github! (only to host the code and your future pull requests)
Git Version | Version Git

Subjects Author Language Messages Last message
[Locked] Bug applets externes BZR avec Archlinux et dérivés
Page : 1 2
lylambda Français 33 matttbe [Read]
22 September 2013 à 18:44

lesebas, Wednesday 18 September 2013 à 22:46


Subscription date : 24 November 2008
Messages : 298
Un p'tit UP... je n'ai pas du trop comprendre comment on mettait les "print"!

matttbe, Thursday 19 September 2013 à 20:09


Subscription date : 24 January 2009
Messages : 12573
Il y a bien un print (on voit un "45" dans le debug) mais un 'print' sans rien... ne fait rien

Mais il faut en rajouter beaucoup d'autres
print ("==== GMail: " + str (inspect.getframeinfo(inspect.currentframe())[1]))


Par exemple:
#!/usr/bin/python

# This is a part of the external applets for Cairo-Dock
# Copyright : (C) 2011 by Benjamin
#
# 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 2
# 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.
# http://www.gnu.org/licenses/licenses.html#GPL

from CDApplet import CDApplet_

try:
    
import glib # used for timer
    
import gtk # used for Menu class displaying inbox
    
import libxml2 # used to parse XML content from Gmail inbox
except:
    
from gi.repository import GLib as glib
    from gi
.repository import Gtk as gtk
    from gi
.repository import Gdk as gdk
    from lxml import etree

import base64 
# used to encrypt and decrypt messaging accounts' passwords

try: # used to connect to Gmail
    
import urllib.request as _urllib # python 3
except:
    
import urllib2 as _urllib # python 2
import re # used to read Gmail headers at authentication
import os # used to find paths and to launch 'aplay'
import sys # used to find relative paths
import webbrowser

import SVGmaker 
# home-made module to edit SVG counter emblem

import inspect 

class Menu(gtk.Menu):

    
def __init__(selfinbox):
        
gtk.Menu.__init__(self)

        
# get all mail from inbox
        
for mail in inbox:
            
# check if mail has subject / title
            
if mail['title'] == None or len(mail['title']) == 0:
                
mail['title'] = '<i>(' _('No Subject') + ')</i>'
            
# create markups
            
string '<b>'+mail['author']+':</b>\n'+mail['title']
            
menu_item gtk.ImageMenuItem()
            
# the true label is set after with set_markup()
            
menu_item.set_label('')
            try:
                
menu_item.set_image(gtk.image_new_from_file('./img/menu-gmail.png'))
            
except:
                
menu_item.set_image(gtk.Image.new_from_file('./img/menu-gmail.png'))
            
menu_item.get_children()[0].set_markup(string)
            
menu_item.url mail['link']
            
menu_item.connect('activate'self.open_mailmail)
            
self.append(menu_item)
            
menu_item.show()
            
# add a separator if mail is not last in list
            
if inbox.index(mail) != len(inbox) - 1:
                
sep gtk.SeparatorMenuItem()
                
self.append(sep)
                
sep.show()

        
self.show()

    
def open_mail(selfmenumail=None):

        
""" Opens the mail URL """
        
try:
          
link mail['link']
          
webbrowser.open(link)
        
except webbrowser.Error:
          
os.popen('x-www-browser https://mail.google.com/mail')

class 
Gmail(CDApplet):

    
"""
        Main applet calling other agents to verify messages and sending signal
        to Cairo-Dock's icon.
    """

    
def __init__(self):

        
self.account = {} # accounts to which user subscribed
        
self.config = {} # user configuration
        
self.flag None # used to check current status (especially with dialogues)
        
self.path sys.argv[3][0:-10# relative path to config file's folder
        
self.subpath self.path+'../../../.Gmail_subscription' # file containing Gmail account details
        
self.svgpath self.path+'emblem.svg' # SVG emblem file
        
self.wav os.path.abspath("./snd/pop.wav")
        
self.rep False # used not to run more than one loop
        
CDApplet.__init__(self)

    
def get_config(selfkeyfile):

        
"""
            Gets configuration from configuration file.
        """

        
self.config['notify'] = keyfile.getboolean('Configuration''NOTIFY')
        
self.config['anim'] = keyfile.getboolean('Configuration''ANIM')
        
self.config['how'] = keyfile.get('Configuration''HOW')
        
self.config['dia'] = keyfile.getboolean('Configuration''DIA')
        
self.config['sound'] = keyfile.getboolean('Configuration''SOUND')
        
self.config['update'] = keyfile.getint('Configuration''UPDATE') * 60000
        self
.config['count'] = keyfile.getboolean('Configuration''COUNT')
        
self.config['info'] = keyfile.get('Configuration''INFO')
        
wav keyfile.get('Configuration''WAV')
        
# set default sound
        
if len(wav) > 0:
            
self.wav os.path.abspath(wav)
        
# set default animation
        
if len(self.config['how']) == 0:
            
self.config['how'] = 'default'

        
# in case user switched between emblem/quickinfo while count > 0
        
if self.account.get('count'0) > 0:
            
self.update_display()
        if 
self.flag == 'error':
            
self.error('')

    
def check_subscription(self):

        
"""
            Checks which accounts the user subsribed to, gets usernames and
            passwords as well as how often the account should be checked.
        """

        
# reset flag in case of prior error:
        
self.flag None

        
# open subscription file and read data
        
try:
            
file open(self.subpath'r')
            
sub file.read()
            
file.close()
        
except:
            
message _("Please fill in your Gmail account.")
            
self.error(message)
            return

        
# check if there was any data
        
if len(sub) < 1:
            
message _("Please fill in your Gmail account.")
            
self.error(message)
            return

        
# if so process the data
        
account base64.b64decode(sub.strip('\n').encode('ascii')).decode().split('\n')

        
# check if the data is correct
        
if len(account) != 2:
            
message _("Please fill in your Gmail account.")
            
self.error(message)
            return

        
# then process the data into account
        
self.account = {'username'account[0],
            
'password'account[1],
            
'count'0,
            
'diff'0}
        
        
self.check_mail()
        
self.repeat()

    
def add_subscription(selfrequest=None):

        
"""
            Prompts user to add subscription details.
        """

        
# if requesting new username:
        
if request == 'username':
            
# set dialogue flag to 'username'
            
self.flag 'username'
            
# prompt for username
            
message _("Please, enter your Gmail username:")
            
self.icon.PopupDialog({"message" message"buttons" "gtk-go-forward-ltr;cancel"},
                    {
"widget-type" "text-entry"})
        
# if requesting new password:
        
elif request == 'password':
            
# set dialogue flag to 'password'
            
self.flag 'password'
            
# prompt for password
            
message _("Please, enter your Gmail password:")
            
self.icon.PopupDialog({"message" message"buttons" "ok;cancel"},
                    {
"widget-type" "text-entry""visible" False})
        
# default request is to encrypt username and password
        
else:
            
# open, encode and write to subscription file
            
file open(self.subpath'wb')
            
file.write(base64.b64encode(str(self.account['username']+ \
            
'\n'+self.account['password']).encode('ascii')))
            
file.close()
            
# run subscription check as double check
            
self.check_subscription()
    
    
    
def check_mail_loop(self):
        
self.check_mail()
        return 
True
    
    def new_mail
(self):
        try:
          
link 'https://mail.google.com/mail/#compose'
          
webbrowser.open(link)
        
except webbrowser.Error:
          
os.popen('x-www-browser '+link)
    
    
def check_mail(selfanimate=False):  # animate is False by default, to not stop a demand of attention

        
"""
        Checks for new mail and requests notifications.
        """
        
if animate:
            
self.icon.Animate('busy',100)

        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# fetch inbox content from Gmail
        
data self.request_gmail()
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))

        
# check if there is any content
        
if data == None:
            if 
animate:
                
self.icon.Animate('',0)
            return
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# unpack and store XML
        
xml data.read()

        
# reading inbox
        
self.account['inbox'] = self.get_inbox(xml)

        if 
animate:
            
self.icon.Animate('',0)
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))

        
# check if mail count could be retrieved
        
if self.account['inbox'] == None:
            return 

        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# parse inbox content to find number of new mails
        
count len(self.account['inbox'])

        
# update account information
        
self.account['diff'] = count self.account['count']
        
self.account['count'] = count
        
print ("==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]) + " diff: " str (self.account['diff']))

        
# update display
        
if self.account['diff'] != 0:
            
self.update_display()

        
# send notifications if there is new mail
        
if self.account['count'] > 0:
            
self.send_alert()
        
elif self.config['anim'] == True:  # no unread message, stop the previous animation
            
self.icon.DemandsAttention(False'')

    
def get_inbox(selfxml_data):

        
"""
            Counts the unreade messages from the XML inbox content.
        """

        
inbox = []

        try:
            try:
                
tree libxml2.parseDoc(xml_data)
                
path tree.xpathNewContext()
                
path.xpathRegisterNs('purl''http://purl.org/atom/ns#')
                
entries path.xpathEval('//purl:entry')
                if 
len(entries) > 0:
                    for 
entry in entries:
                        
path.setContextNode(entry)
                        
mail = {}
                        
mail['title'] = path.xpathEval('purl:title')[0].content
                        mail
['summary'] = path.xpathEval('purl:summary')[0].content
                        mail
['link'] = path.xpathEval('purl:link')[0].prop('href')
                        
mail['author'] = path.xpathEval('purl:author/purl:name')[0].content
                        inbox
.append(mail)
            
except:
                
tree etree.fromstring(xml_data)
                
namespaces = {'purl':'http://purl.org/atom/ns#'}
                
entries tree.xpath('purl:entry'namespaces namespaces)
                if 
len(entries) > 0:
                    for 
entry in entries:
                        
mail = {}
                        
mail['title'] = entry.xpath('purl:title'namespaces namespaces)[0].text
                        mail
['summary'] = entry.xpath('purl:summary'namespaces namespaces)[0].text
                        mail
['link'] = entry.xpath('purl:link'namespaces namespaces)[0].get('href')
                        
mail['author'] = entry.xpath('purl:author/purl:name'namespaces namespaces)[0].text
                        inbox
.append(mail)
            return 
inbox
        except
:
            
message _("WARNING: there was an error reading XML content.")
            
self.error(message)
            return 
None

    def request_gmail
(self):

        
"""
            Authenticates and requests inbox content from Gmail.
        """

        
gmailfeed 'https://mail.google.com/mail/feed/atom/'
        
request _urllib.Request(gmailfeed)

        
# connect to Gmail
        
error None
        
try:
            
handle _urllib.urlopen(request)
        
except IOError as err:
            
# here we will need "fail" as we receive a 401 error to get access
            
error err

        
if not hasattr(error'code') or error.code != 401:
            
# we got an error - but not a 401 error
            
message _("WARNING: Gmail applet failed to connect to Gmail atom feed.")
            
self.error(message)
            return 
None

        
# get the www-authenticate line from the headers
        
authline error.headers['www-authenticate']

        
# from this header we extract scheme and realm
        
authobject re.compile(
                                
r'''(?:\s*www-authenticate\s*:)?\s*(\w*)\s+realm=['"]([^'"]+)['"]''',
                                
re.IGNORECASE)
        
matchobject authobject.match(authline)

        
# make sure scheme and realm was found
        
if not matchobject:
            
message _("WARNING: Gmail atom feed is badly formed: ")
            
message authline
            self
.error(m)
            return 
None

        
# check what scheme we have
        
scheme matchobject.group(1)
        if 
scheme.lower() != 'basic':
            
message _("WARNING: Gmail Applet is not equipped for authentication other than BASIC.")
            return 
self.error(message)

        
# authenticate and get inbox content
        
account = ('%s:%s' % (self.account['username'], self.account['password'])).encode('ascii')
        
        
base64string base64.encodestring(account)[:-1].decode()
        
authheader "Basic %s" base64string
        request
.add_header("Authorization"authheader)
        try:
            
handle _urllib.urlopen(request)
        
except IOError as error:
            
# here we shouldn't fail if the username/password is right
            
message _("WARNING: Gmail username or password may be wrong.")
            
self.error(message)
            return 
None

        
return handle

    def update_display
(self):

        
"""
        Updates applet icon either with quickinfo or svg emblem.
        Only if new mail count is superior to 0.
        """
        
print ("==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))

        
# if user does not want any counter on the icon
        
if self.config['count'] == False:
            
# clean up quick-info
            
self.icon.SetQuickInfo('')
            
# clean up icon
            
self.icon.SetIcon(os.path.abspath('./icon'))
            return

        
# otherwise
        
if self.config['info'] == 'quickinfo':
            
# clean up icon
            
print ("==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
            
self.icon.SetIcon(os.path.abspath('./icon'))
            if 
self.account['count'] == 0:
                
# reset quick-info
                
self.icon.SetQuickInfo('')
                print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
            else:
                
self.icon.SetQuickInfo(str(self.account['count']))
                print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))

        else:
            
# reset quick-info (in case displayed before)
            
self.icon.SetQuickInfo('')
            
# check if emblem is necessary
            
if self.account['count'] == 0:
                
# reset icon
                
self.icon.SetIcon(os.path.abspath("./icon"))
            else:
                
# get size out of config
                
size self.config['info'].split()[0]
                
# make icon with external module SVGmaker
                
SVG SVGmaker.add_counter(self.account['count'], size)
                
svg open(self.svgpath'w')
                
svg.write(SVG)
                
svg.close()
                
# set icon with emblem
                
self.icon.SetIcon(self.svgpath)

    
def error(selfmessage):

        
"""
            Warns the user if an error occured.
        """
        
print ("==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# no need to update the icon
        
if self.flag == 'error':
            return

        if 
self.config['info'] != 'quickinfo':
            
# remove previous quickinfo if needed:
            
self.icon.SetQuickInfo('')
            
# get size from config:
            
size self.config['info'].split()[0]
            
# pass size to filename:
            
file './img/gmail-error-'+size+'.svg'
            
# set icon with error emblem
            
self.icon.SetIcon(os.path.abspath(file))

        else:
            
# reset icon in case needed
            
self.icon.SetIcon(os.path.abspath('./icon'))
            
# set quickinfo:
            
self.icon.SetQuickInfo(_('Error!'))
        
# check if any error is already known
        # or if the user is changing subscription details
        
if self.flag != None:
            return
        
# set error flag
        
self.flag 'error'
        
self.account['count'] = -99 # to be sure that the icon will be updated
        # show dialogue
        
self.icon.ShowDialog(message4)

    
def send_alert(self):

        
"""
            Notifies user according to requirements.
        """

        
# check if user wants notifications
        
if self.config['notify'] == False:
            return

        
# check whether conditions are met
        
if self.account['diff'] <= 0:
            return
        
        
# check whether user wants an effect on the icon
        
if self.config['anim'] == True:
            
self.icon.DemandsAttention(Trueself.config['how'])

        
# check whether user wants a dialogue
        
if self.config['dia'] == True:
            
# checking our grammar ;) # we have at least one new email
            
if self.account['count'] > 1:
                
message _("You have %s new emails") % (str(self.account['count']))
            else:
                
message _("You have 1 new email")
            
self.icon.ShowDialog(message3)

        
# check whether user wants a sound
        
if self.config['sound'] == True:
            try:
                
os.popen('aplay ' self.wav)
            
except:
                
# restore default sound file if custom is corrupted
                
self.wav os.path.abspath("./snd/pop.wav")

    
def repeat(self):

        
"""
           Timer for postman to check messages.
           Will continue as long as check_messages returns True
        """
        
if self.rep == True:
            
pass
        
# set flag to tell the loop is running
        
self.rep True
        
# start timer loop
        
glib.timeout_add(self.config['update'], self.check_mail_loop)

    
def begin(self):

        
"""
            First method ran by CairoDock when applet is launched.
        """

        
###self.icon.SetLabel("Gmail")
        # the applet will not enter the loop until a subscription is found
        
self.check_subscription()

    
def on_answer_dialog(selfkeycontent):

        
"""
            Processes dialogue input for username and password.
        """

        
# check user pressed the first button (OK) or Enter
        
if key == or key == CDApplet.DIALOG_KEY_ENTER:
            
# check user entered something
            
if len(content) > 0:
                
# check if requesting username
                
if self.flag == 'username':
                    
# append account with username
                    
self.account['username'] = format(content)
                    
# request password
                    
self.add_subscription('password')
                
# check if requesting password
                
elif self.flag == 'password':
                    
# append account with password
                    
self.account['password'] = format(content)
                    
# finish up registration process
                    
self.add_subscription()
                else:
                    
# should not happen (kept in case another dialogue needs
                    # to be made in future).
                    
pass
            
else:
                
message _("Sorry, there was no input!")
                
self.error(message)

    
def on_build_menu(self):

        
"""
            Appends items to right-click menu.
        """

        
message_add_label _("Add or change subscription")
        
message_add_tooltip _("Use this to add or change your Gmail account details.")
        
message_middle_click _("middle-click")
        
message_check_label _("Check inbox now")
        
message_check_tooltip _("Check Gmail inbox now if you can't wait.")
        
message_new_mail _("Write a mail")
        
self.icon.AddMenuItems([{"widget-type" CDApplet.MENU_ENTRY,
        
"label"message_add_label,
        
"icon" "gtk-add",
        
"menu" CDApplet.MAIN_MENU_ID,
        
"id" 1,
        
"tooltip" message_add_tooltip},
        {
"widget-type" CDApplet.MENU_ENTRY,
        
"label"message_check_label " (" message_middle_click ")",
        
"icon" "gtk-refresh",
        
"menu" CDApplet.MAIN_MENU_ID,
        
"id" 2,
        
"sensitive" : (len(self.account) > 1), # at least 'count' => -99
        
"tooltip" message_check_tooltip},
        {
"widget-type" CDApplet.MENU_ENTRY,
        
"label"message_new_mail,
        
"icon" "gtk-new",
        
"menu" CDApplet.MAIN_MENU_ID,
        
"id" 3}])

    
def on_menu_select(selfiNumEntry):

        
"""
            Launches methods according to menu selection.
        """

        
if iNumEntry == 1:
            
self.add_subscription('username')
        
elif iNumEntry == 2:
            
self.check_mail(True)
        
elif iNumEntry == 3:
            
self.new_mail()

    
def on_click(selfiState):

        
"""
            Launches Gmail in default browser or application.
        """
        
        
if len(self.account) <= 1:  # no account -> start subscription
            
self.add_subscription('username')
        else:
            if 
self.account['count'] < 1:  # no message -> check now
                
self.check_mail(True)
            else:  
# some message(s) -> show the inbox
                
Menu(self.account['inbox'])
                
m.popup(parent_menu_shell=Noneparent_menu_item=Nonefunc=self.get_xydata=(400400),
                        
button=1activate_time=0)

    
def on_middle_click(self):
    
        
"""
            Check for new mails now.
        """
        
        
self.check_mail(True)

    
def get_xy(selfmdata):

        
# fetch icon geometry
        
icondata self.icon.GetAll()
        
iconContainer  icondata['container']
        
iconOrientation icondata['orientation']
        
iconWidth icondata['width']
        
iconHeight icondata['height']
        
iconPosX icondata['x']
        
iconPosY icondata['y']

        
# get menu geometry
        
try:
            
menuWidthmenuHeight m.size_request()
            
screenHeight gtk.gdk.screen_height()
        
except:
            
window m.get_parent_window()
            
menuWidth window.get_width()
            
menuHeight window.get_height()
            
screen gdk.Screen.get_default()
            
screenHeight screen.get_height()

        
# adapt to container and orientation
        
if iconContainer == 1:  # Then it's a desklet, always oriented in a bottom-like way.
            
if iconPosY['y'] < (screenHeight 2):
                
iconOrientation 1
            
else:
                
iconOrientation 0

        
if iconOrientation == 0:
            
# compute position of menu
            
iconPosX - (menuWidth 2)
            
iconPosY - (iconHeight 2) - menuHeight

        
else:
            
iconPosX - (menuWidth 2)
            
iconPosY + (iconHeight 2)

        return (
xyTrue)

if 
__name__ == "__main__":
    
gmail Gmail()
    
gmail.run()


lesebas, Thursday 19 September 2013 à 22:42


Subscription date : 24 November 2008
Messages : 298
Bon j'ai tenté pas d'en mettre un maximum mais moi ça ne me parle pas...

[sebastien@Vulpus cairo-dock-plugins-extras-bzr]$ cairo-dock
warning : (/var/abs/local/yaourtbuild/cairo-dock-bzr/src/cairo-dock-core/src/implementations/cairo-dock-glx.c:_initialize_opengl_backend:179)
couldn't find an appropriate visual, trying to get one without Stencil buffer
(it may cause some little deterioration in the rendering) ...

============================================================================
    Cairo-Dock version : 3.2.99.beta2
    Compiled date : Sep 16 2013 22:58:09
    Built with GTK : 3.8
    Running with OpenGL: 0
============================================================================

sh : ligne 1 : 2111 Processus arrêté ./"Google" 1 "/org/cairodock/CairoDock/Google" "/home/sebastien/.config/cairo-dock/current_theme/plug-ins/Google/Google.conf" "/home/sebastien/.config/cairo-dock" cairo-dock 2104
libreoffice-writer -> pClassAppli->cStartupWMClass: libreoffice-writer
warning : (/var/abs/local/yaourtbuild/cairo-dock-bzr/src/cairo-dock-core/src/gldit/cairo-dock-packages.c:cairo_dock_list_net_packages:640)
couldn't retrieve packages on http://download.tuxfamily.org/glxdock/themes (check that your connection is alive, or retry later)
warning : (/var/abs/local/yaourtbuild/cairo-dock-bzr/src/cairo-dock-core/src/gldit/cairo-dock-packages.c:cairo_dock_list_packages:712)
while listing distant packages in 'http://download.tuxfamily.org/glxdock/themes/third-party/3.3.0' : Couldn't download file 'http://download.tuxfamily.org/glxdock/themes/third-party/3.3.0/list.conf' (Couldn't resolve host name)
shotwell -> pClassAppli->cStartupWMClass: (null)
wine -> pClassAppli->cStartupWMClass: (null)
gimp -> pClassAppli->cStartupWMClass: (null)
xfce4-terminal -> pClassAppli->cStartupWMClass: (null)
chromium -> pClassAppli->cStartupWMClass: (null)
thunderbird -> pClassAppli->cStartupWMClass: (null)
libreoffice-calc -> pClassAppli->cStartupWMClass: libreoffice-calc
cairo_dock_set_image_on_icon (/usr/share/cairo-dock/plug-ins/Dbus/third-party/Google/icon)
GldiShortkey '<Control>F12' failed!
warning : (/var/abs/local/yaourtbuild/cairo-dock-bzr/src/cairo-dock-core/src/gldit/cairo-dock-keybinder.c:init_object:455)
Couldn't bind '<Control>F12' (Se déconnecter: Afficher le menu de déconnexion)
This shortkey is probably already used by another applet or another application
cairo_dock_set_image_on_icon (/usr/share/cairo-dock/plug-ins/Dbus/third-party/Screensaver_inhibitor/icon)
warning : (/var/abs/local/yaourtbuild/cairo-dock-plugins-bzr/src/cairo-dock-plug-ins/weather/src/applet-read-data.c:cd_weather_get_distant_data:308)
while downloading current conditions data:
http://xml.weather.com/weather/local/FRXX6146?cc=*&unit=m -> Couldn't download file 'http://xml.weather.com/weather/local/FRXX6146?cc=*&unit=m' (Couldn't resolve host name)
cairo_dock_set_image_on_icon (/usr/share/cairo-dock/plug-ins/Dbus/third-party/Gmail/icon)
cairo_dock_set_image_on_icon (/home/sebastien/.config/cairo-dock/extras/dustbin/Silver/trashcan_empty.svg)
File "./Gmail", line 395
else:
^
SyntaxError: invalid syntax
cairo_dock_set_image_on_icon (/usr/share/cairo-dock/plug-ins/showDesktop/icon.png)
GldiShortkey '<Control>F4' failed!
warning : (/var/abs/local/yaourtbuild/cairo-dock-bzr/src/cairo-dock-core/src/gldit/cairo-dock-keybinder.c:init_object:455)
Couldn't bind '<Control>F4' (Afficher le Bureau: Exposé de tous les bureaux)
This shortkey is probably already used by another applet or another application
cairo_dock_set_image_on_icon (/usr/share/cairo-dock/plug-ins/Dbus/third-party/Screensaver_inhibitor/icon.svg)
cairo_dock_set_image_on_icon (/home/sebastien/.config/cairo-dock/extras/weather/7degrees/na.png)
cairo_dock_set_image_on_icon (/home/sebastien/.config/cairo-dock/extras/dustbin/Silver/trashcan_full.svg)
pacmanxg -> pClassAppli->cStartupWMClass: (null)
wicd-client ---> (null)
_cd_find_volume_name_from_drive_name: assertion `pDrive != NULL' failed
_cd_find_volume_name_from_drive_name: assertion `pDrive != NULL' failed
[+] Google: Applet started
warning : (/var/abs/local/yaourtbuild/cairo-dock-plugins-bzr/src/cairo-dock-plug-ins/weather/src/applet-read-data.c:cd_weather_get_distant_data:308)
while downloading current conditions data:
http://xml.weather.com/weather/local/FRXX6146?cc=*&unit=m -> Couldn't download file 'http://xml.weather.com/weather/local/FRXX6146?cc=*&unit=m' (Couldn't resolve host name)
warning : (/var/abs/local/yaourtbuild/cairo-dock-plugins-bzr/src/cairo-dock-plug-ins/weather/src/applet-read-data.c:cd_weather_get_distant_data:308)
while downloading current conditions data:
http://xml.weather.com/weather/local/FRXX6146?cc=*&unit=m -> Couldn't download file 'http://xml.weather.com/weather/local/FRXX6146?cc=*&unit=m' (Couldn't resolve host name)
warning : (/var/abs/local/yaourtbuild/cairo-dock-plugins-bzr/src/cairo-dock-plug-ins/weather/src/applet-read-data.c:cd_weather_get_distant_data:308)
while downloading current conditions data:
http://xml.weather.com/weather/local/FRXX6146?cc=*&unit=m -> Couldn't download file 'http://xml.weather.com/weather/local/FRXX6146?cc=*&unit=m' (Couldn't resolve host name)


[Edit]Par contre avec la rev 429 je n'ai plus accès au menu Gmail (vérifier, ajouter un compte)... et ça ne récupère plus mes message même avec le wifi actif...... ha si... c'est ma version modifiée qui ne marche pas :

#!/usr/bin/python

# This is a part of the external applets for Cairo-Dock
# Copyright : (C) 2011 by Benjamin
# E-mail : jesuisbenjamin@gmail.com
#
# 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 2
# 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.
# http://www.gnu.org/licenses/licenses.html#GPL

from CDApplet import CDApplet_

try:
    
import glib # used for timer
    
import gtk # used for Menu class displaying inbox
    
import libxml2 # used to parse XML content from Gmail inbox
except:
    
from gi.repository import GLib as glib
    from gi
.repository import Gtk as gtk
    from gi
.repository import Gdk as gdk
    from lxml import etree

import base64 
# used to encrypt and decrypt messaging accounts' passwords

try: # used to connect to Gmail
    
import urllib.request as _urllib # python 3
except:
    
import urllib2 as _urllib # python 2
import re # used to read Gmail headers at authentication
import os # used to find paths and to launch 'aplay'
import sys # used to find relative paths
import webbrowser

import SVGmaker 
# home-made module to edit SVG counter emblem

import inspect 

print (inspect.getframeinfo(inspect.currentframe())[1])

class 
Menu(gtk.Menu):

    
def __init__(selfinbox):
        
gtk.Menu.__init__(self)

        
# get all mail from inbox
        
for mail in inbox:
            
# check if mail has subject / title
            
if mail['title'] == None or len(mail['title']) == 0:
                
mail['title'] = '<i>(' _('No Subject') + ')</i>'
            
# create markups
            
string '<b>'+mail['author']+':</b>\n'+mail['title']
            
menu_item gtk.ImageMenuItem()
            
# the true label is set after with set_markup()
            
menu_item.set_label('')
            try:
                
menu_item.set_image(gtk.image_new_from_file('./img/menu-gmail.png'))
            
except:
                
menu_item.set_image(gtk.Image.new_from_file('./img/menu-gmail.png'))
            
menu_item.get_children()[0].set_markup(string)
            
menu_item.url mail['link']
            
menu_item.connect('activate'self.open_mailmail)
            
self.append(menu_item)
            
menu_item.show()
            
# add a separator if mail is not last in list
            
if inbox.index(mail) != len(inbox) - 1:
                
sep gtk.SeparatorMenuItem()
                
self.append(sep)
                
sep.show()

        
self.show()

    
def open_mail(selfmenumail=None):

        
""" Opens the mail URL """
        
try:
          
link mail['link']
          
webbrowser.open(link)
        
except webbrowser.Error:
          
os.popen('x-www-browser https://mail.google.com/mail')

class 
Gmail(CDApplet):

    
"""
        Main applet calling other agents to verify messages and sending signal
        to Cairo-Dock's icon.
    """

    
def __init__(self):

        
self.account = {} # accounts to which user subscribed
        
self.config = {} # user configuration
        
self.flag None # used to check current status (especially with dialogues)
        
self.path sys.argv[3][0:-10# relative path to config file's folder
        
self.subpath self.path+'../../../.Gmail_subscription' # file containing Gmail account details
        
self.svgpath self.path+'emblem.svg' # SVG emblem file
        
self.wav os.path.abspath("./snd/pop.wav")
        
self.rep False # used not to run more than one loop
        
CDApplet.__init__(self)

    
def get_config(selfkeyfile):

        
"""
            Gets configuration from configuration file.
        """

        
self.config['notify'] = keyfile.getboolean('Configuration''NOTIFY')
        
self.config['anim'] = keyfile.getboolean('Configuration''ANIM')
        
self.config['how'] = keyfile.get('Configuration''HOW')
        
self.config['dia'] = keyfile.getboolean('Configuration''DIA')
        
self.config['sound'] = keyfile.getboolean('Configuration''SOUND')
        
self.config['update'] = keyfile.getint('Configuration''UPDATE') * 60000
        self
.config['count'] = keyfile.getboolean('Configuration''COUNT')
        
self.config['info'] = keyfile.get('Configuration''INFO')
        
wav keyfile.get('Configuration''WAV')
        
# set default sound
        
if len(wav) > 0:
            
self.wav os.path.abspath(wav)
        
# set default animation
        
if len(self.config['how']) == 0:
            
self.config['how'] = 'default'

        
# in case user switched between emblem/quickinfo while count > 0
        
if self.account.get('count'0) > 0:
            
self.update_display()
        if 
self.flag == 'error':
            
self.error('')
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
    
def check_subscription(self):

        
"""
            Checks which accounts the user subsribed to, gets usernames and
            passwords as well as how often the account should be checked.
        """

        
# reset flag in case of prior error:
        
self.flag None
        
print ("==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# open subscription file and read data
        
try:
            
file open(self.subpath'r')
            
sub file.read()
            
file.close()
        
except:
            
message _("Please fill in your Gmail account.")
            
self.error(message)
            return
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# check if there was any data
        
if len(sub) < 1:
            
message _("Please fill in your Gmail account.")
            
self.error(message)
            return
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# if so process the data
        
account base64.b64decode(sub.strip('\n').encode('ascii')).decode().split('\n')
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# check if the data is correct
        
if len(account) != 2:
            
message _("Please fill in your Gmail account.")
            
self.error(message)
            return
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# then process the data into account
        
self.account = {'username'account[0],
            
'password'account[1],
            
'count'0,
            
'diff'0}
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))        
        
self.check_mail()
        
self.repeat()
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
    
def add_subscription(selfrequest=None):
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
"""
            Prompts user to add subscription details.
        """
        
print ("==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# if requesting new username:
        
if request == 'username':
            
# set dialogue flag to 'username'
            
self.flag 'username'
            
# prompt for username
            
message _("Please, enter your Gmail username:")
            
self.icon.PopupDialog({"message" message"buttons" "gtk-go-forward-ltr;cancel"},
                    {
"widget-type" "text-entry"})
        
# if requesting new password:
        
elif request == 'password':
            
# set dialogue flag to 'password'
            
self.flag 'password'
            
# prompt for password
            
message _("Please, enter your Gmail password:")
            
self.icon.PopupDialog({"message" message"buttons" "ok;cancel"},
                    {
"widget-type" "text-entry""visible" False})
        
# default request is to encrypt username and password
        
else:
            
# open, encode and write to subscription file
            
file open(self.subpath'wb')
            
file.write(base64.b64encode(str(self.account['username']+ \
            
'\n'+self.account['password']).encode('ascii')))
            
file.close()
            
# run subscription check as double check
            
self.check_subscription()
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))   
    
    
def check_mail_loop(self):
        
self.check_mail()
        return 
True
         
print ("==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))   
    
def new_mail(self):
        try:
          
link 'https://mail.google.com/mail/#compose'
          
webbrowser.open(link)
        
except webbrowser.Error:
          
os.popen('x-www-browser '+link)
          print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))  
    
def check_mail(selfanimate=False):  # animate is False by default, to not stop a demand of attention
        
print ("==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
"""
        Checks for new mail and requests notifications.
        """
        
if animate:
            
self.icon.Animate('busy',100)

        
# fetch inbox content from Gmail
        
data self.request_gmail()

        
# check if there is any content
        
if data == None:
            if 
animate:
                
self.icon.Animate('',0)
            return
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# unpack and store XML
        
xml data.read()
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# reading inbox
        
self.account['inbox'] = self.get_inbox(xml)
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        if 
animate:
            
self.icon.Animate('',0)
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# check if mail count could be retrieved
        
if self.account['inbox'] == None:
            return 
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# parse inbox content to find number of new mails
        
count len(self.account['inbox'])
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# update account information
        
self.account['diff'] = count self.account['count']
        
self.account['count'] = count
        
print ("==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# update display
        
if self.account['diff'] != 0:
            
self.update_display()
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# send notifications if there is new mail
        
if self.account['count'] > 0:
            
self.send_alert()
        
elif self.config['anim'] == True:  # no unread message, stop the previous animation
            
self.icon.DemandsAttention(False'')
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
    
def get_inbox(selfxml_data):

        
"""
            Counts the unreade messages from the XML inbox content.
        """

        
inbox = []

        try:
            try:
                
tree libxml2.parseDoc(xml_data)
                
path tree.xpathNewContext()
                
path.xpathRegisterNs('purl''http://purl.org/atom/ns#')
                
entries path.xpathEval('//purl:entry')
                if 
len(entries) > 0:
                    for 
entry in entries:
                        
path.setContextNode(entry)
                        
mail = {}
                        
mail['title'] = path.xpathEval('purl:title')[0].content
                        mail
['summary'] = path.xpathEval('purl:summary')[0].content
                        mail
['link'] = path.xpathEval('purl:link')[0].prop('href')
                        
mail['author'] = path.xpathEval('purl:author/purl:name')[0].content
                        inbox
.append(mail)
            
except:
                
tree etree.fromstring(xml_data)
                
namespaces = {'purl':'http://purl.org/atom/ns#'}
                
entries tree.xpath('purl:entry'namespaces namespaces)
                if 
len(entries) > 0:
                    for 
entry in entries:
                        
mail = {}
                        
mail['title'] = entry.xpath('purl:title'namespaces namespaces)[0].text
                        mail
['summary'] = entry.xpath('purl:summary'namespaces namespaces)[0].text
                        mail
['link'] = entry.xpath('purl:link'namespaces namespaces)[0].get('href')
                        
mail['author'] = entry.xpath('purl:author/purl:name'namespaces namespaces)[0].text
                        inbox
.append(mail)
            return 
inbox
        except
:
            
message _("WARNING: there was an error reading XML content.")
            
self.error(message)
            return 
None
        
print ("==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
    
def request_gmail(self):

        
"""
            Authenticates and requests inbox content from Gmail.
        """

        
gmailfeed 'https://mail.google.com/mail/feed/atom/'
        
request _urllib.Request(gmailfeed)
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# connect to Gmail
        
error None
        
try:
            
handle _urllib.urlopen(request)
        
except IOError as err:
            
# here we will need "fail" as we receive a 401 error to get access
            
error err
        
print ("==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        if 
not hasattr(error'code') or error.code != 401:
            
# we got an error - but not a 401 error
            
message _("WARNING: Gmail applet failed to connect to Gmail atom feed.")
            
self.error(message)
            return 
None
        
print ("==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# get the www-authenticate line from the headers
        
authline error.headers['www-authenticate']
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# from this header we extract scheme and realm
        
authobject re.compile(
                                
r'''(?:\s*www-authenticate\s*:)?\s*(\w*)\s+realm=['"]([^'"]+)['"]''',
                                
re.IGNORECASE)
        
matchobject authobject.match(authline)
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# make sure scheme and realm was found
        
if not matchobject:
            
message _("WARNING: Gmail atom feed is badly formed: ")
            
message authline
            self
.error(m)
            return 
None
        
print ("==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# check what scheme we have
        
scheme matchobject.group(1)
        if 
scheme.lower() != 'basic':
            
message _("WARNING: Gmail Applet is not equipped for authentication other than BASIC.")
            return 
self.error(message)
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# authenticate and get inbox content
        
account = ('%s:%s' % (self.account['username'], self.account['password'])).encode('ascii')
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))        
        
base64string base64.encodestring(account)[:-1].decode()
        
authheader "Basic %s" base64string
        request
.add_header("Authorization"authheader)
        try:
            
handle _urllib.urlopen(request)
        
except IOError as error:
            
# here we shouldn't fail if the username/password is right
            
message _("WARNING: Gmail username or password may be wrong.")
            
self.error(message)
            return 
None

        
return handle
        
print ("==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
    
def update_display(self):
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
"""
        Updates applet icon either with quickinfo or svg emblem.
        Only if new mail count is superior to 0.
        """
        
print
        
# if user does not want any counter on the icon
        
if self.config['count'] == False:
            
# clean up quick-info
            
self.icon.SetQuickInfo('')
            
# clean up icon
            
self.icon.SetIcon(os.path.abspath('./icon'))
            return
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# otherwise
        
if self.config['info'] == 'quickinfo':
            
# clean up icon
            
self.icon.SetIcon(os.path.abspath('./icon'))
            if 
self.account['count'] == 0:
                
# reset quick-info
                
self.icon.SetQuickInfo('')
            else:
                
self.icon.SetQuickInfo(str(self.account['count']))
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        else:
            
# reset quick-info (in case displayed before)
            
self.icon.SetQuickInfo('')
            
# check if emblem is necessary
            
if self.account['count'] == 0:
                
# reset icon
                
self.icon.SetIcon(os.path.abspath("./icon"))
            else:
                
# get size out of config
                
size self.config['info'].split()[0]
                
# make icon with external module SVGmaker
                
SVG SVGmaker.add_counter(self.account['count'], size)
                
svg open(self.svgpath'w')
                
svg.write(SVG)
                
svg.close()
                
# set icon with emblem
                
self.icon.SetIcon(self.svgpath)
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
    
def error(selfmessage):
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
"""
            Warns the user if an error occured.
        """

        
# no need to update the icon
        
if self.flag == 'error':
            return
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        if 
self.config['info'] != 'quickinfo':
            
# remove previous quickinfo if needed:
            
self.icon.SetQuickInfo('')
            
# get size from config:
            
size self.config['info'].split()[0]
            
# pass size to filename:
            
file './img/gmail-error-'+size+'.svg'
            
# set icon with error emblem
            
self.icon.SetIcon(os.path.abspath(file))
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        else:
            
# reset icon in case needed
            
self.icon.SetIcon(os.path.abspath('./icon'))
            
# set quickinfo:
            
self.icon.SetQuickInfo(_('Error!'))
        
# check if any error is already known
        # or if the user is changing subscription details
        
if self.flag != None:
            return
        
# set error flag
        
self.flag 'error'
        
self.account['count'] = -99 # to be sure that the icon will be updated
        # show dialogue
        
self.icon.ShowDialog(message4)
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
    
def send_alert(self):
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
"""
            Notifies user according to requirements.
        """

        
# check if user wants notifications
        
if self.config['notify'] == False:
            return
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# check whether conditions are met
        
if self.account['diff'] <= 0:
            return
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# check whether user wants an effect on the icon
        
if self.config['anim'] == True:
            
self.icon.DemandsAttention(Trueself.config['how'])
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# check whether user wants a dialogue
        
if self.config['dia'] == True:
            
# checking our grammar ;) # we have at least one new email
            
if self.account['count'] > 1:
                
message _("You have %s new emails") % (str(self.account['count']))
            else:
                
message _("You have 1 new email")
            
self.icon.ShowDialog(message3)
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# check whether user wants a sound
        
if self.config['sound'] == True:
            try:
                
os.popen('aplay ' self.wav)
            
except:
                
# restore default sound file if custom is corrupted
                
self.wav os.path.abspath("./snd/pop.wav")
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
    
def repeat(self):
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
"""
           Timer for postman to check messages.
           Will continue as long as check_messages returns True
        """
        
if self.rep == True:
            
pass
        
# set flag to tell the loop is running
        
self.rep True
        
# start timer loop
        
glib.timeout_add(self.config['update'], self.check_mail_loop)
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
    
def begin(self):
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
"""
            First method ran by CairoDock when applet is launched.
        """

        
###self.icon.SetLabel("Gmail")
        # the applet will not enter the loop until a subscription is found
        
self.check_subscription()
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
    
def on_answer_dialog(selfkeycontent):

        
"""
            Processes dialogue input for username and password.
        """
        
print ("==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
# check user pressed the first button (OK) or Enter
        
if key == or key == CDApplet.DIALOG_KEY_ENTER:
            
# check user entered something
            
if len(content) > 0:
                
# check if requesting username
                
if self.flag == 'username':
                    
# append account with username
                    
self.account['username'] = format(content)
                    
# request password
                    
self.add_subscription('password')
                
# check if requesting password
                
elif self.flag == 'password':
                    
# append account with password
                    
self.account['password'] = format(content)
                    
# finish up registration process
                    
self.add_subscription()
                else:
                    
# should not happen (kept in case another dialogue needs
                    # to be made in future).
                    
pass
            
else:
                
message _("Sorry, there was no input!")
                
self.error(message)
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
    
def on_build_menu(self):

        
"""
            Appends items to right-click menu.
        """

        
message_add_label _("Add or change subscription")
        
message_add_tooltip _("Use this to add or change your Gmail account details.")
        
message_middle_click _("middle-click")
        
message_check_label _("Check inbox now")
        
message_check_tooltip _("Check Gmail inbox now if you can't wait.")
        
message_new_mail _("Write a mail")
        
self.icon.AddMenuItems([{"widget-type" CDApplet.MENU_ENTRY,
        
"label"message_add_label,
        
"icon" "gtk-add",
        
"menu" CDApplet.MAIN_MENU_ID,
        
"id" 1,
        
"tooltip" message_add_tooltip},
        {
"widget-type" CDApplet.MENU_ENTRY,
        
"label"message_check_label " (" message_middle_click ")",
        
"icon" "gtk-refresh",
        
"menu" CDApplet.MAIN_MENU_ID,
        
"id" 2,
        
"sensitive" : (len(self.account) > 1), # at least 'count' => -99
        
"tooltip" message_check_tooltip},
        {
"widget-type" CDApplet.MENU_ENTRY,
        
"label"message_new_mail,
        
"icon" "gtk-new",
        
"menu" CDApplet.MAIN_MENU_ID,
        
"id" 3}])
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
    
def on_menu_select(selfiNumEntry):
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
"""
            Launches methods according to menu selection.
        """

        
if iNumEntry == 1:
            
self.add_subscription('username')
        
elif iNumEntry == 2:
            
self.check_mail(True)
        
elif iNumEntry == 3:
            
self.new_mail()

    
def on_click(selfiState):
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
        
"""
            Launches Gmail in default browser or application.
        """
        
        
if len(self.account) <= 1:  # no account -> start subscription
            
self.add_subscription('username')
        else:
            if 
self.account['count'] < 1:  # no message -> check now
                
self.check_mail(True)
            else:  
# some message(s) -> show the inbox
                
Menu(self.account['inbox'])
                
m.popup(parent_menu_shell=Noneparent_menu_item=Nonefunc=self.get_xydata=(400400),
                        
button=1activate_time=0)
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
    
def on_middle_click(self):
    
        
"""
            Check for new mails now.
        """
         
print ("==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))       
        
self.check_mail(True)
        print (
"==== GMail: " str (inspect.getframeinfo(inspect.currentframe())[1]))
    
def get_xy(selfmdata):

        
# fetch icon geometry
        
icondata self.icon.GetAll()
        
iconContainer  icondata['container']
        
iconOrientation icondata['orientation']
        
iconWidth icondata['width']
        
iconHeight icondata['height']
        
iconPosX icondata['x']
        
iconPosY icondata['y']

        
# get menu geometry
        
try:
            
menuWidthmenuHeight m.size_request()
            
screenHeight gtk.gdk.screen_height()
        
except:
            
window m.get_parent_window()
            
menuWidth window.get_width()
            
menuHeight window.get_height()
            
screen gdk.Screen.get_default()
            
screenHeight screen.get_height()

        
# adapt to container and orientation
        
if iconContainer == 1:  # Then it's a desklet, always oriented in a bottom-like way.
            
if iconPosY['y'] < (screenHeight 2):
                
iconOrientation 1
            
else:
                
iconOrientation 0

        
if iconOrientation == 0:
            
# compute position of menu
            
iconPosX - (menuWidth 2)
            
iconPosY - (iconHeight 2) - menuHeight

        
else:
            
iconPosX - (menuWidth 2)
            
iconPosY + (iconHeight 2)

        return (
xyTrue)

if 
__name__ == "__main__":
    
gmail Gmail()
    
gmail.run()



J'ai du y aller un peu fort sur les print

@matttbe : ta version aussi plante!

matttbe, Thursday 19 September 2013 à 22:51


Subscription date : 24 January 2009
Messages : 12573
Bon j'ai tenté pas d'en mettre un maximum mais moi ça ne me parle pas...
Peux-tu essayé uniquement en prenant tout le code de mon précédent commentaire?

Car d'après l'erreur dans le terminal, il y a une erreur de syntaxe à la ligne 395 or ça n'a rien à voir avec le code que je t'ai donné (attention, en Python, il faut respecter l'indentation!)

lesebas, Thursday 19 September 2013 à 22:57


Subscription date : 24 November 2008
Messages : 298
Avec le tiens error line 202... je regarde!

matttbe, Thursday 19 September 2013 à 23:06


Subscription date : 24 January 2009
Messages : 12573
Pas de soucis chez moi avec ce code
=> http://pastebin.com/HVTF9s9m

lesebas, Thursday 19 September 2013 à 23:06


Subscription date : 24 November 2008
Messages : 298
Ok y'avait un espace en trop... Voila ce que ça donne, quand je rafraichi une fois le wifi connecté il appelle les lignes 228 - 426 - 231... idem toutes les minutes :

[sebastien@Vulpus Gmail]$ cairo-dock
warning : (/var/abs/local/yaourtbuild/cairo-dock-bzr/src/cairo-dock-core/src/implementations/cairo-dock-glx.c:_initialize_opengl_backend:179)
couldn't find an appropriate visual, trying to get one without Stencil buffer
(it may cause some little deterioration in the rendering) ...

============================================================================
    Cairo-Dock version : 3.2.99.beta2
    Compiled date : Sep 16 2013 22:58:09
    Built with GTK : 3.8
    Running with OpenGL: 0
============================================================================

libreoffice-writer -> pClassAppli->cStartupWMClass: libreoffice-writer
warning : (/var/abs/local/yaourtbuild/cairo-dock-bzr/src/cairo-dock-core/src/gldit/cairo-dock-packages.c:cairo_dock_list_net_packages:640)
couldn't retrieve packages on http://download.tuxfamily.org/glxdock/themes (check that your connection is alive, or retry later)
warning : (/var/abs/local/yaourtbuild/cairo-dock-bzr/src/cairo-dock-core/src/gldit/cairo-dock-packages.c:cairo_dock_list_packages:712)
while listing distant packages in 'http://download.tuxfamily.org/glxdock/themes/third-party/3.3.0' : Couldn't download file 'http://download.tuxfamily.org/glxdock/themes/third-party/3.3.0/list.conf' (Couldn't resolve host name)
shotwell -> pClassAppli->cStartupWMClass: (null)
wine -> pClassAppli->cStartupWMClass: (null)
gimp -> pClassAppli->cStartupWMClass: (null)
xfce4-terminal -> pClassAppli->cStartupWMClass: (null)
chromium -> pClassAppli->cStartupWMClass: (null)
thunderbird -> pClassAppli->cStartupWMClass: (null)
libreoffice-calc -> pClassAppli->cStartupWMClass: libreoffice-calc
cairo_dock_set_image_on_icon (/usr/share/cairo-dock/plug-ins/Dbus/third-party/Google/icon)
GldiShortkey '<Control>F12' failed!
warning : (/var/abs/local/yaourtbuild/cairo-dock-bzr/src/cairo-dock-core/src/gldit/cairo-dock-keybinder.c:init_object:455)
Couldn't bind '<Control>F12' (Se déconnecter: Afficher le menu de déconnexion)
This shortkey is probably already used by another applet or another application
cairo_dock_set_image_on_icon (/usr/share/cairo-dock/plug-ins/Dbus/third-party/Screensaver_inhibitor/icon)
cairo_dock_set_image_on_icon (/usr/share/cairo-dock/plug-ins/Dbus/third-party/Gmail/icon)
warning : (/var/abs/local/yaourtbuild/cairo-dock-plugins-bzr/src/cairo-dock-plug-ins/weather/src/applet-read-data.c:cd_weather_get_distant_data:308)
while downloading current conditions data:
http://xml.weather.com/weather/local/FRXX6146?cc=*&unit=m -> Couldn't download file 'http://xml.weather.com/weather/local/FRXX6146?cc=*&unit=m' (Couldn't resolve host name)
cairo_dock_set_image_on_icon (/home/sebastien/.config/cairo-dock/extras/dustbin/Silver/trashcan_empty.svg)
cairo_dock_set_image_on_icon (/usr/share/cairo-dock/plug-ins/showDesktop/icon.png)
GldiShortkey '<Control>F4' failed!
warning : (/var/abs/local/yaourtbuild/cairo-dock-bzr/src/cairo-dock-core/src/gldit/cairo-dock-keybinder.c:init_object:455)
Couldn't bind '<Control>F4' (Afficher le Bureau: Exposé de tous les bureaux)
This shortkey is probably already used by another applet or another application
cairo_dock_set_image_on_icon (/home/sebastien/.config/cairo-dock/extras/weather/7degrees/na.png)
cairo_dock_set_image_on_icon (/home/sebastien/.config/cairo-dock/extras/dustbin/Silver/trashcan_full.svg)
thunar -> pClassAppli->cStartupWMClass: (null)
pacmanxg -> pClassAppli->cStartupWMClass: (null)
wicd-client ---> (null)
cairo_dock_set_image_on_icon (/usr/share/cairo-dock/plug-ins/Dbus/third-party/Screensaver_inhibitor/icon.svg)
_cd_find_volume_name_from_drive_name: assertion `pDrive != NULL' failed
_cd_find_volume_name_from_drive_name: assertion `pDrive != NULL' failed
==== GMail: 228
==== GMail: 426
[+] Google: Applet started
cairo_dock_set_image_on_icon (/usr/share/cairo-dock/plug-ins/Dbus/third-party/Gmail/icon)
==== GMail: 231
cairo_dock_set_image_on_icon (/home/sebastien/.config/cairo-dock/extras/weather/7degrees/26.png)
==== GMail: 228
==== GMail: 426
==== GMail: 231
==== GMail: 228
==== GMail: 426
==== GMail: 231
==== GMail: 228
==== GMail: 426
==== GMail: 231


Par contre si j'ai le réseau dès le départ :

[sebastien@Vulpus Gmail]$ cairo-dock
warning : (/var/abs/local/yaourtbuild/cairo-dock-bzr/src/cairo-dock-core/src/implementations/cairo-dock-glx.c:_initialize_opengl_backend:179)
couldn't find an appropriate visual, trying to get one without Stencil buffer
(it may cause some little deterioration in the rendering) ...

============================================================================
    Cairo-Dock version : 3.2.99.beta2
    Compiled date : Sep 16 2013 22:58:09
    Built with GTK : 3.8
    Running with OpenGL: 0
============================================================================

sh : ligne 1 : 7515 Processus arrêté ./"Google" 1 "/org/cairodock/CairoDock/Google" "/home/sebastien/.config/cairo-dock/current_theme/plug-ins/Google/Google.conf" "/home/sebastien/.config/cairo-dock" cairo-dock 7508
libreoffice-writer -> pClassAppli->cStartupWMClass: libreoffice-writer
shotwell -> pClassAppli->cStartupWMClass: (null)
wine -> pClassAppli->cStartupWMClass: (null)
gimp -> pClassAppli->cStartupWMClass: (null)
xfce4-terminal -> pClassAppli->cStartupWMClass: (null)
chromium -> pClassAppli->cStartupWMClass: (null)
thunderbird -> pClassAppli->cStartupWMClass: (null)
libreoffice-calc -> pClassAppli->cStartupWMClass: libreoffice-calc
cairo_dock_set_image_on_icon (/usr/share/cairo-dock/plug-ins/Dbus/third-party/Google/icon)
GldiShortkey '<Control>F12' failed!
warning : (/var/abs/local/yaourtbuild/cairo-dock-bzr/src/cairo-dock-core/src/gldit/cairo-dock-keybinder.c:init_object:455)
Couldn't bind '<Control>F12' (Se déconnecter: Afficher le menu de déconnexion)
This shortkey is probably already used by another applet or another application
cairo_dock_set_image_on_icon (/usr/share/cairo-dock/plug-ins/Dbus/third-party/Screensaver_inhibitor/icon)
cairo_dock_set_image_on_icon (/usr/share/cairo-dock/plug-ins/Dbus/third-party/Gmail/icon)
cairo_dock_set_image_on_icon (/home/sebastien/.config/cairo-dock/extras/dustbin/Silver/trashcan_empty.svg)
cairo_dock_set_image_on_icon (/usr/share/cairo-dock/plug-ins/showDesktop/icon.png)
GldiShortkey '<Control>F4' failed!
warning : (/var/abs/local/yaourtbuild/cairo-dock-bzr/src/cairo-dock-core/src/gldit/cairo-dock-keybinder.c:init_object:455)
Couldn't bind '<Control>F4' (Afficher le Bureau: Exposé de tous les bureaux)
This shortkey is probably already used by another applet or another application
cairo_dock_set_image_on_icon (/home/sebastien/.config/cairo-dock/extras/dustbin/Silver/trashcan_full.svg)
thunar -> pClassAppli->cStartupWMClass: (null)
pacmanxg -> pClassAppli->cStartupWMClass: (null)
wicd-client ---> (null)
cairo_dock_set_image_on_icon (/usr/share/cairo-dock/plug-ins/Dbus/third-party/Screensaver_inhibitor/icon.svg)
_cd_find_volume_name_from_drive_name: assertion `pDrive != NULL' failed
_cd_find_volume_name_from_drive_name: assertion `pDrive != NULL' failed
[+] Google: Applet started
==== GMail: 228
==== GMail: 231
==== GMail: 238
==== GMail: 247
==== GMail: 253
==== GMail: 260 diff: 3
==== GMail: 380
==== GMail: 393
cairo_dock_set_image_on_icon (/usr/share/cairo-dock/plug-ins/Dbus/third-party/Gmail/icon)
==== GMail: 401
Lecture WAVE '/usr/share/cairo-dock/plug-ins/Dbus/third-party/Gmail/snd/pop.wav' : Float 32 bit Little Endian, Fréquence 44100 Hz, Stéréo
cairo_dock_set_image_on_icon (/home/sebastien/.config/cairo-dock/extras/weather/7degrees/26.png)
==== GMail: 228
==== GMail: 231
==== GMail: 238
==== GMail: 247
==== GMail: 253
==== GMail: 260 diff: 0

matttbe, Thursday 19 September 2013 à 23:19


Subscription date : 24 January 2009
Messages : 12573
Ça bloque dans request_gmail(): voilà une version avec plus de 'print' http://pastebin.com/qx5fa6Hi
(je pourrais ajouter plus de print mais il y aurait le contenu des mails dedans)

lesebas, Friday 20 September 2013 à 07:33


Subscription date : 24 November 2008
Messages : 298
Voila ce que ça donne... pour le contenu des mails c'est pas grave, je le remplacerait par des étoiles avant de le coller ici :

==== GMail: 228
==== GMail: 322
==== GMail: 331
<urlopen error [Errno -2] Nom ou service inconnu>
==== GMail: 433
cairo_dock_set_image_on_icon (/usr/share/cairo-dock/plug-ins/Dbus/third-party/Gmail/icon)
==== GMail: 231
cairo_dock_set_image_on_icon (/home/sebastien/.config/cairo-dock/extras/weather/7degrees/26.png)
==== GMail: 228
==== GMail: 322
==== GMail: 331
<urlopen error [Errno -2] Nom ou service inconnu>
==== GMail: 433
==== GMail: 231

matttbe, Friday 20 September 2013 à 10:41


Subscription date : 24 January 2009
Messages : 12573
Avec 2 prints de plus: http://pastebin.com/3TEfbrQm

lesebas, Friday 20 September 2013 à 17:45


Subscription date : 24 November 2008
Messages : 298
la ligne 334 print (handle) plante l'applet...

==== GMail: 228
==== GMail: 322
==== GMail: 331
HTTP Error 401: Unauthorized
<urllib.request.Request object at 0x7fd178740ad0>
Traceback (most recent call last):
File "./Gmail", line 663, in <module>
gmail.run()
File "/usr/lib/python3.3/site-packages/CDApplet.py", line 165, in run
self.begin()
File "./Gmail", line 521, in begin
self.check_subscription()
File "./Gmail", line 173, in check_subscription
self.check_mail()
File "./Gmail", line 230, in check_mail
data = self.request_gmail()
File "./Gmail", line 334, in request_gmail
print (handle)
UnboundLocalError: local variable 'handle' referenced before assignment
cairo_dock_set_image_on_icon (/home/sebastien/.config/cairo-dock/extras/weather/7degrees/28.png)


En la supprimant j'ai ça :

[+] Google: Applet started
==== GMail: 228
==== GMail: 322
==== GMail: 331
<urlopen error [Errno -2] Nom ou service inconnu>
<urllib.request.Request object at 0x7ffadb323e50>
==== GMail: 435
cairo_dock_set_image_on_icon (/usr/share/cairo-dock/plug-ins/Dbus/third-party/Gmail/icon)
==== GMail: 231
==== GMail: 228
==== GMail: 322
==== GMail: 331
<urlopen error [Errno -2] Nom ou service inconnu>
<urllib.request.Request object at 0x7ffadaeda150>
==== GMail: 435
==== GMail: 231
cairo_dock_set_image_on_icon (/home/sebastien/.config/cairo-dock/extras/weather/7degrees/28.png)
==== GMail: 228
==== GMail: 322
==== GMail: 331
<urlopen error [Errno -2] Nom ou service inconnu>
<urllib.request.Request object at 0x7ffadaeda8d0>
==== GMail: 435
==== GMail: 231

matttbe, Friday 20 September 2013 à 19:16


Subscription date : 24 January 2009
Messages : 12573
HTTP Error 401: Unauthorized

<urlopen error [Errno -2] Nom ou service inconnu>
Lorsque tu as eu le crash, tu étais connecté?
Car là, l'erreur est 401 mais après, elle est à -2.
Tu confirmes que tu as bien toujours la même erreur "-2" avant et après t'être connecté? (car dans le 2è log, je ne vois pas quand tu te connectes)

Il y a p-ê des caches sous ArchLinux? Bizarre...

lesebas, Friday 20 September 2013 à 19:52


Subscription date : 24 November 2008
Messages : 298
A force je ne sais plus ...

Donc non erreur à -2 avant et après connexion (on voit bien weather qui se met à jour):

==== GMail: 228
==== GMail: 322
==== GMail: 331
<urlopen error [Errno -2] Nom ou service inconnu>
<urllib.request.Request object at 0x7f886f908e50>
==== GMail: 435
cairo_dock_set_image_on_icon (/usr/share/cairo-dock/plug-ins/Dbus/third-party/Gmail/icon)
==== GMail: 231
==== GMail: 228
==== GMail: 322
==== GMail: 331
<urlopen error [Errno -2] Nom ou service inconnu>
<urllib.request.Request object at 0x7f886f4bf150>
==== GMail: 435
==== GMail: 231
cairo_dock_set_image_on_icon (/home/sebastien/.config/cairo-dock/extras/weather/7degrees/28.png)
==== GMail: 228
==== GMail: 322
==== GMail: 331
<urlopen error [Errno -2] Nom ou service inconnu>
<urllib.request.Request object at 0x7f886f4bf8d0>
==== GMail: 435
==== GMail: 231

matttbe, Sunday 22 September 2013 à 18:44


Subscription date : 24 January 2009
Messages : 12573
Bizarre

J'ai l'impression que le bug ne vient pas de l'applet.
En C, errno n'est mis à jour que s'il y a un problème mais ici, on récupère un nouvel objet 'error' s'il y en a une (et il devrait toujours en avoir une) donc on ne devrait pas avoir de soucis... (et je n'ai pas de soucis moi )

Pourrais-tu ouvrir un terminal et lancer 'python'. Puis entrer les lignes suivantes:
import urllib.request as _urllib
from pprint import pprint
from inspect import getmembers

request 
_urllib.Request('https://mail.google.com/mail/feed/atom/')
error None
try: 
    
handle _urllib.urlopen(request)
except IOError as err:
    
error err

print (error)
hasattr(error'code')
pprint(getmembers(error))
(tu peux copier-coller tout le bloc )
Le faire une fois avant la connexion puis une seconde fois (toujours dans le même terminal), relancer tout le bloc sans les imports (sans les 3 premières lignes)

Git Version | Version Git

Subjects Author Language Messages Last message
[Locked] Bug applets externes BZR avec Archlinux et dérivés
Page : 1 2
lylambda Français 33 matttbe [Read]
22 September 2013 à 18:44


Glx-Dock / Cairo-Dock List of forums Git Version | Version Git Bug applets externes BZR avec Archlinux et dérivés Top

Online users :

Powered by ElementSpeak © 2007 Adrien Pilleboue, 2009-2013 Matthieu Baerts.
Dock based on CSS Dock Menu (Ndesign) with jQuery. Icons by zgegball
Cairo-Dock is a free software under GNU-GPL3 licence. First stable version created by Fabounet.
Many thanks to TuxFamily for the web Hosting and Mav for the domain name.