Main index > About existing desklets > mailer

By syfou (Core Developer & Desklet Author), on Sat Feb 26 13:29:03 2005: mailer.

mailer desklet issues are discussed here.

By syfou (Core Developer & Desklet Author), on Tue Mar 1 01:41:11 2005, last edited on Tue Mar 1 13:55:16 2005: Problem with gmail pop account.

Here is a copy of an email exchange I have been having with a user, slag:

Code:


On Tue, 1 Mar 2005 00:17:26 -0600, Slag wrote:

No, I think that's a great idea!  And you were right again  :-/ 
re-emerging python with SSL support did not fix the problem.  I am
certain, however, that pop.gmail.com is indeed the POP3 server for
gmail, and I did not have the case error that you listed as an option.

I finally tried, then, to apply the patch.  Here's what I did:
patch -p1 <mailer.diff mailer.py

Is this the correct syntax for the command?  I was given the following
error message:
patching file mailer.py
Hunk #1 FAILED at 164.
1 out of 1 hunk FAILED -- saving rejects to file mailer.py.rej

I've attached mailer.py.rej in case it is of additional use.  Any
suggestions on how to fix the problem would be most helpful!

On Mon, 28 Feb 2005 23:55:53 -0500 (EST), syfou@users.sourceforge.net
wrote:
> 
> I didn't say I gave you all the possibilities - not having SSL support 
> is just an educated guess. You'd better try out the patch, then you'd knew 
> for sure... and it's quicker than a emerging python.
> 
> Anyway, do you mind me reusing our exchange for a post on the forum?
> 
> Regards,
> 
> -- 
> Sylvain <syfou@users.sourceforge.net>
> 
> Intel CPUs are not defective, they just act that way.
> -- Henry Spencer
>  
> On Mon, 28 Feb 2005 22:04:29 -0600 Slag wrote:
> > 
> > Thanks!  I know for a fact, by means of elimination, that it's the SSL
> > support for python.  I'm re-emerging right now!  Thanks again!
> > 
> > Cheers,
> > Jay
> > 
> > On Mon, 28 Feb 2005 22:12:28 -0500 (EST), syfou@users.sourceforge.net
> > <syfou@users.sourceforge.net> wrote:
> > > Hi,
> > > 
> > > From what you tell me, you did everything right the first time (provided
> > > that pop.gmail.com is indeed the POP3 server name)... There is a couple of
> > > possibility for this error.
> > > 
> > > - The server name in dns is not 'pop.gmail.com'
> > > - Your Python wasn't compile with SSL support in
> > > - You did not know Python was case sensitive, and you wrote 'true' instead
> > > of 'True', which is False. :-)
> > > 
> > > - If you still do not see the problem, you can apply the enclosed patch to
> > > mailer.py (version 0.0.3):
> > > 
> > > patch -p1 <mailer.diff
> > > 
> > > - It will make the desklet crash on connection errors. No very nice
> > > usually, but you'll have a usefull error message.
> > > 
> > > Regards,
> > > 
> > > --
> > > S.Fourmanoit <syfou@users.sourceforge.net>
> > > 
> > > Programming is an unnatural act.
> > > 
> > > On Mon, 28 Feb 2005, Slag wrote:
> > > 
> > > > Hi, I'm wondering how to configure the mailer desklet for use with
> > > > gmail?  I set SSL to true, the host to "pop.gmail.com" and IMAP to
> > > > false (so that the desklet uses pop3, which is gmail's protocol) but
> > > > the desklet shows a connection error.
> > > >
> > > > According to gmail I need to use port 995 - but setting the host in
> > > > the desklet to "pop.gmail.com:995" does not solve the connection
> > > > problem.  Any ideas?
> > > >
> > > > Thanks,
> > > > -Jay



And here is the associated test patch I sent him. All it does is to remove the error checks from mailer.py (version 0.0.3), so we can see it crash on connection error.

By syfou (Core Developer & Desklet Author), on Tue Mar 1 01:43:32 2005.

I already gave you the right (Bourne Shell) line. For the mailer base directory on your disk:

Code:


patch -p1 <mailer.diff



Or, alternatively, still from this directory:

Code:


cat mailer.diff | patch -p1

By slag (User), on Tue Mar 1 13:49:17 2005.

Alright. I don't know what I was doing wrong when I tried to patch before, but I was able to apply the patch successfully. Here is the error output that I get when I try to run mailer.py now:

Code:


Traceback (most recent call last):
  File "./mailer.py", line 385, in ?
    Events(dirname(__file__)).pause()
  File "./mailer.py", line 193, in __init__
    adesklets.Events_handler.__init__(self)
  File "usr/lib/python2.3/site-packages/adesklets/events_handler.py", line 159,_
  File "usr/lib/python2.3/site-packages/adesklets/events_handler.py", line 296,m
  File "./mailer.py", line 233, in alarm
    mail = self.mailer()
  File "./mailer.py", line 167, in __call__
    s = self.imaplib.__dict__['IMAP4'+['','_SSL'][self.config['ssl']]]\
  File "/usr/lib/python2.3/imaplib.py", line 157, in __init__
    self.open(host, port)
  File "/usr/lib/python2.3/imaplib.py", line 225, in open
    self.sock.connect((host, port))
  File "<string>", line 1, in connect
socket.error: (111, 'Connection refused')



It looks like my host and port are not configured correctly? Or are there other problems?

By syfou (Core Developer & Desklet Author), on Tue Mar 1 13:54:46 2005, last edited on Tue Mar 1 14:18:01 2005.

Most probably, yes... Could you post your configuration file? (Strip the password, of course - it would be even better is you could just insert any XXX sequence over it, so i am sure to see all.).

When I pay more attention, I see that the desklet is invoking the imap code, not the pop one...

By slag (User), on Tue Mar 1 14:16:14 2005.

Code:

id0 = {'background_color': '1E1E1E',
 'background_gradient_cutpoint': 40,
 'background_opacity': 70,
 'caption': 'jayjech@gmail.com',
 'caption_color': 'FFFFFF',
 'caption_font': 'Vera',
 'caption_font_size': 10,
 'delay': 300,
 'host': 'pop.gmail.com:995',
 'icon_height': 48,
 'icon_width': 48,
 'icons': ['error.png', 'noemail.png', 'email.png'],
 'imap': False,
 'message_color': None,
 'message_font': None,
 'message_font_size': None,
 'messages': ['connection error',
              'no new message',
              '1 new message',
              'new messages'],
 'messages_prepend': True,
 'program_on_click': 'mozilla http://gmail.google.com',
 'program_on_new': 'snd.sh',
 'ssl': True,
 'text_padding': 10,
 'user_name': 'jayjech@gmail.com',
 'user_password': 'XXX_XXX_XXX'}

By syfou (Core Developer & Desklet Author), on Tue Mar 1 14:35:52 2005, last edited on Tue Mar 1 15:23:45 2005.

Ok. Two errors there:



So, a correct configuration file would probably look like:

Code:


id0 = {'background_color': '1E1E1E',
 'background_gradient_cutpoint': 40,
 'background_opacity': 70,
 'caption': 'jayjech@gmail.com',
 'caption_color': 'FFFFFF',
 'caption_font': 'Vera',
 'caption_font_size': 10,
 'delay': 300,
 'host': 'pop.gmail.com',
 'icon_height': 48,
 'icon_width': 48,
 'icons': ['error.png', 'noemail.png', 'email.png'],
 'imap': False,
 'message_color': None,
 'message_font': None,
 'message_font_size': None,
 'messages': ['connection error',
              'no new message',
              '1 new message',
              'new messages'],
 'messages_prepend': True,
 'program_on_click': 'mozilla http://gmail.google.com',
 'program_on_new': 'snd.sh',
 'ssl': True,
 'text_padding': 10,
 'user_name': 'jayjech',
 'user_password': 'XXX_XXX_XXX'}



This code is probably very similar to what you had at first. :-) I still do not understand your prevous ouput tough. I will be waiting for the next error you get.

By slag (User), on Tue Mar 1 15:02:08 2005, last edited on Tue Mar 1 15:12:13 2005.

Okay, made those two adjustments (so my config.txt now looks identical to the one you posted except for the password)... here's the new error message:

Code:


Traceback (most recent call last):
  File "./mailer.py", line 385, in ?
    Events(dirname(__file__)).pause()
  File "./mailer.py", line 193, in __init__
    adesklets.Events_handler.__init__(self)
  File "usr/lib/python2.3/site-packages/adesklets/events_handler.py", line 159,_
  File "usr/lib/python2.3/site-packages/adesklets/events_handler.py", line 296,m
  File "./mailer.py", line 233, in alarm
    mail = self.mailer()
  File "./mailer.py", line 167, in __call__
    s = self.imaplib.__dict__['IMAP4'+['','_SSL'][self.config['ssl']]]\
  File "/usr/lib/python2.3/imaplib.py", line 157, in __init__
    self.open(host, port)
  File "/usr/lib/python2.3/imaplib.py", line 225, in open
    self.sock.connect((host, port))
  File "<string>", line 1, in connect
socket.error: (111, 'Connection refused')



Seems to be the same. Maybe I should try reinstalling the mailer desklet?

EDIT: I just tried reinstalling the plugin, same error message...

By syfou (Core Developer & Desklet Author), on Tue Mar 1 15:16:06 2005.

That makes no sense! It says your trying to connect as imap when you should be connecting by pop ???

Just hang on a little please. Add a print statement right at the beginning of the __call__ method from the Mailer class (around line 163 - do not forget to add two tabs at the beginning of the line so it is aligned with the 'if' below), so it looks like:

Code:


print self.config['imap'],self.config['ssl'],self.config['user_name'],self.config['host']
if self.config['imap']:
...



Then make sure you start everything right (no pending desklets). In bash:

Code:


killall -9 adesklets python
ADESKLETS_ID=0 python mailer.py

By slag (User), on Tue Mar 1 15:26:33 2005.

Done, and done -> new output:

Code:

False True jayjech pop.gmail.com
Traceback (most recent call last):
  File "mailer.py", line 386, in ?
    Events(dirname(__file__)).pause()
  File "mailer.py", line 194, in __init__
    adesklets.Events_handler.__init__(self)
  File "usr/lib/python2.3/site-packages/adesklets/events_handler.py", line 159,_
  File "usr/lib/python2.3/site-packages/adesklets/events_handler.py", line 296,m
  File "mailer.py", line 234, in alarm
    mail = self.mailer()
  File "mailer.py", line 175, in __call__
    s = self.poplib.__dict__['POP3'+['','_SSL'][self.config['ssl']]]\
KeyError: 'POP3_SSL

By syfou (Core Developer & Desklet Author), on Tue Mar 1 15:37:38 2005.

Well, now I know. Two things:

You really need to check how you start your desklets. Because the switch in messages means you had an instance running... Same joke than what you had with yab initially. You should invoke the script once. From there, you just call:

Code:


adesklets



on new X Session.

As for the other message, it's pretty clear: you do not have POP3_SSL support in your version of python. In fact, no official python release in the 2.3.x has it by default, It came as a patch. You can as well install Python 2.4.0 (Final), has it is present in base package..

By slag (User), on Tue Mar 1 16:09:36 2005.

Fixed! I just had to add in SSL support via the patch link you supplied. I had earlier tried recompiling python with USE="ssl" but that doesn't work! python2.4 is not yet unmasked in the portage tree due to some compile conflicts.

Thanks a lot! Your desklets kick ass! 8)

By syfou (Core Developer & Desklet Author), on Tue Mar 1 16:38:05 2005.

Do not forget to reinstall mailer in pristine state. This patch we used earlier removes recuperation from error in case of connection problems. Aplying it makes the mailer desklet crash on error displaying a console message instead of continuing running with a 'connection_error' display.

Clearly, you do not want to use such a patched mailer for anything but debugging purposes, as it will make the desklet exist every time it tries getting your mail info when your network is down, the server unavailable, etc.

To summarize, your problems were: I am happy we solved this too. Enjoy adesklets!

By jeepston (Desklet Author), on Tue Mar 15 20:23:41 2005.

A couple of more suggestions how to improve mailer desklet:

-- to show not only number of new messages, but also total number of mails in mailbox
-- possibility to monitor several (say, up to 4) mailboxes on one desklet
-- modify it to monitor such mail services as gmail (actually, not very important since they started to provide POP3 service) and hotmail.com

By DrWoland (Desklet Author), on Fri Mar 18 00:52:06 2005.

I feel kind of dumb, but I can't figure out how to apply that pop3_ssl patch... what folder am I supposed to place it in to run it?

By syfou (Core Developer & Desklet Author), on Fri Mar 18 01:13:42 2005.

This is not important. What is important is you passing along the right -p parameter, depending of where you are in the tree when you launch the patch program so it can find the files to alter. For instance, if you look at a diff file called my.diff, that reads:

Code:


--- Python-2.3-orig/Lib/poplib.py       2002-06-01 09:07:16.000000000 -0700
+++ Python-2.3/Lib/poplib.py    2003-08-19 22:32:50.000000000 -0700



If your current working directory were the Python-2.3 base directory, you would do:

Code:


patch -p1 </path/to/my.diff



While, from Python-2.3/Lib, it would be:

Code:


patch -p2 </path/to/my.diff



See man 1 patch for more details.

By DrWoland (Desklet Author), on Fri Mar 18 01:19:32 2005.

my path structure looks nothing like that.

I have python in /usr/lib/python2.3 and there is no Lib folder within that. Something is fishy here, and now, as ZeroDivide already knows, I just unmerge python ahahahahhahaahhaha yeah I'll be a bit out of commission until I reboot into Ubuntu and chroot and remerge python.

By syfou (Core Developer & Desklet Author), on Fri Mar 18 01:25:27 2005.

:ttt: Who made you think patches applies to live, installed system? Usually, you install patches on source distributions; why would it be different for Python?

By DrWoland (Desklet Author), on Fri Mar 18 01:59:53 2005.

syfou wrote:

:ttt: Who made you think patches applies to live, installed system? Usually, you install patches on source distributions; why would it be different for Python?


Like I said, while I may have some dev background (not that great anyway) I'm still very green at linux and coding and patching etc :oops: I copied my ubuntu python folders over, I'll reboot into gentoo shortly. How would I go about patching it anyway, emerge gets everything from the source archive anyway and I certainly do not know how to edit an ebuild.

By DrWoland (Desklet Author), on Fri Mar 18 02:17:06 2005.

I installed Python 2.4 and it works just fine now. Unfortunately it was masked as still being in testing, so many gentoo users may not be able/be willing to use it.

By falcon_za (User), on Fri Mar 18 11:32:10 2005.

No help needed here, but rather a minor feature request/modification

when the texts says "no new message" or "n new messages" with n between 2 and 9, it has the same lenght. with 1 message, it is shorter by one character. with more than 9, it is longer.

The problem is that the desklet's length changes with the string's length. when you have several instance of the mailer desklet runnning and verticaly alligned, this is not very nice, because it is impossible to keep the right border aligned. also, If you have it positioned against the right screen border, there will be a small gap appearing between the desklet and the border when you have only one mail.

Ax fix could be to be able fix the window's minimum size, making for example long enough for up to 99 (999?) mails, but not getting shorter when you have only one.

since there is no limit to the number of mails you can have, I don't see how to limit the maximum length of the desklet, but with the above change, it would be fine in most situations.

I know this is kind of a detail, but after all, desklets are about eye candy, so why not have it as nice as possible.

By syfou (Core Developer & Desklet Author), on Fri Mar 18 11:51:13 2005.

So you sometime have more than nine new messages in your mailbox in one shot? :shock:

I can think of at least one "one liner" (one characther, in fact) fix to this. See the line 299 from mailer 0.0.3? Change it from:

Code:


[('%d ' + self.config['messages'][3])% mail]


Into this:

Code:


[('%2d ' + self.config['messages'][3])% mail]


Of course, you will also need to adapt the messages dictionnary key from config.txt accordingly for the one message case. Regards,

By falcon_za (User), on Fri Mar 18 15:48:21 2005.

more than 9 messages is not unusual on one of my mail box which is rather heavily spammed. away from my computer for a couple of days, and yes, it definitely goes over 9.

I'll test your fix soon.

If what it does indeed makes me happy, would you include it in the next version?

btw: Seeing your name, I guess you are french. Or am I guessing wrong? I am french too.

By syfou (Core Developer & Desklet Author), on Fri Mar 18 15:56:16 2005.

falcon_za wrote:


ll test your fix soon. If what it does indeed makes me happy, would you include it in the next version?

That what it is, only a fix. Real code should probably do a little more to satify me for inclusion...

Quote:


btw: Seeing your name, I guess you are french. Or am I guessing wrong? I am french too.

Loup?, Belge. And hardly anymore - I lived in Canada for the last 25 years or so.

By MrGreen (User), on Fri Apr 1 09:17:37 2005.

I'm getting this when running mailer ....

Code:

./mailer.py
Traceback (most recent call last):
  File "./mailer.py", line 391, in ?
    Events(dirname(__file__)).pause()
  File "./mailer.py", line 199, in __init__
    adesklets.Events_handler.__init__(self)
  File "/usr/lib/python2.4/site-packages/adesklets/events_handler.py", line 157, in __init__
    self.ready()
  File "./mailer.py", line 209, in ready
    join(self.basedir,'config.txt'))
  File "./mailer.py", line 143, in __init__
    adesklets.ConfigFile.__init__(self,id,filename)
  File "/usr/lib/python2.4/site-packages/adesklets/configfile.py", line 159, in __init__
    self._load_and_save()
  File "/usr/lib/python2.4/site-packages/adesklets/configfile.py", line 202, in _load_and_save
    all= ConfigImport.load(buf[:])
  File "/usr/lib/python2.4/site-packages/adesklets/configfile.py", line 41, in __call__
    return dict(self._group(
  File "/usr/lib/python2.4/compiler/transformer.py", line 52, in parse
    return Transformer().parsesuite(buf)
  File "/usr/lib/python2.4/compiler/transformer.py", line 129, in parsesuite
    return self.transform(parser.suite(text))
  File "<string>", line 71
    'icon_height': 48,
                 ^



I have made some changes to config.txt. but nothing seems to work am I missing something ?

By ZeroDivide (Desklet Author), on Fri Apr 1 15:47:02 2005.

Post your config file and I might be able to help.

By syfou (Core Developer & Desklet Author), on Sat Apr 2 14:24:47 2005.

MrGreen wrote:


I have made some changes to config.txt. but nothing seems to work am I missing something ?

From your exception trace, ZeroDivide is probably right: this is most probably a syntax error in your config file (missing comma, brace, or similar). To make sure, just move your current confix.txt out of the way:

Code:


mv config.txt{,.bak}


And start things again. If you do not get this error, it means your syntax is indeed erroneous. Post it here, just overriding sensible fields with 'x' strings or similar.

By MrGreen (User), on Sat Apr 2 14:27:02 2005.

Yes you are right the ,s are missing my fault :lol: running ok now just got to get it to pick up mail from gmail

Thanks again

MrGreen

By Aresius (User), on Sun Apr 10 23:39:30 2005: More than one and number of mails..

Thanks for previous posts. Helped me alot.

My questions:
1. How do i make the mailer check more than one mailbox? Thought I just needed to add another one to the config-file, but only the default one in the mailer.py or id0 is checked..

2: The mailer tells me I have 67 unread messages in the mailbox, which is pretty weird, since I have just over 300 altogether, and they are all read.. Reason for this and how do I fix it? Is the mailer suppose to reset to no "new messages" when it is clicked, or when it registers that all mail are actually read?

Sorry if the questions are stupid, but never worked with python so have no idea what's going on.. :oops:

Cheers!

By syfou (Core Developer & Desklet Author), on Mon Apr 11 02:02:27 2005: Re: More than one and number of mails..

Aresius wrote:


How do i make the mailer check more than one mailbox? Thought I just needed to add another one to the config-file, but only the default one in the mailer.py or id0 is checked..


Just start as many desklets as you have mailboxes: on desklet will control one and only one mailbox.

Aresius wrote:


The mailer tells me I have 67 unread messages in the mailbox, which is pretty weird, since I have just over 300 altogether, and they are all read.. Reason for this and how do I fix it?


From what you say, I assume you use an imap server? What you describe is possible since the desklet doesn't respect the protocol by the book (see subsection 6.4.4 for the full specification.concerning this), due to the fact that many imap servers does not implement the full convention, and that I had to find a reasonnable compromise to read from most of them (this works at least with courier-imap, and UW IMAP). Luckyly, this behavior is easy to fine-tuned: line 172 from mailer.py in mailer 0.0.3 reads:

Code:


size = len(s.search(None, 'UNSEEN')[1][0].split()



Theorically speaking, this 'UNSEEN' flag is not entirely correct, as it should be 'RECENT UNSEEN'. Some others servers will want 'NEW' (which is normally the same as 'RECENT UNSEEN') or even the also slightly wrong 'RECENT'.. Just try out from yourself what suits your server. If nothing seems to work, just let me know: the name of the software in place would be helpful in that case.

Aresius wrote:


Is the mailer suppose to reset to no "new messages" when it is clicked, or when it registers that all mail are actually read?

mailer reactualize its state when the configurable 'delay' timeout by querying the imap server. This event is completely asynchronous from the configured clic operation. I hope this will help you.

By Aresius (User), on Mon Apr 11 05:27:42 2005.

Thanks for the help. Figured it out.

For further notice: I'm using GMail, and discovered that it works with all the RECENT-calls you mentioned. However, gmail gives you a choice when you activate POP3 on your account, which says "Enable POP for all mail (even mail that's already been downloaded)" and "Enable POP only for mail that arrives from now on", and the mailer-app will show all mail (both sent and received) from these two choices. The only way it's updated in the mailer-app is when you move it to trash or spam. This basically means the mailer-app shows all the mail comes in your sent- and inbox-directories since you activated pop3, unless you set it to start over or delete/spam all the messages.

If anyone else using gmail, doesn't have this problem, please let me know, but as far as i can see this is a gmail-problem.

By syfou (Core Developer & Desklet Author), on Mon Apr 11 06:10:48 2005.

With POP, nothing of what I said earlier applies, so it will not make a difference how you adapt line 172, since it is not used at all... With POP, the behavior is simplier, due to the way the protocol is made. As you probably know, POP was not written to manage remote messages on a server, but just to easily stack them for future download, at which time they are simply discarded. Hence, looking at new mails on a POP server is synonymous to looking at all mails.

What gmail provide you is a small convenience bridge on top of its native infrastructure, giving two different views of your messages via pop3... So yes, it's technically a gmail issue, but more a shortcoming than a real problem. There would be workarounds though, such as using fetchmail and setting up an imap server locally, or on one of your boxes...Many variations would be possible.

By Aresius (User), on Tue Apr 12 00:21:44 2005.

Hehe.. Yeah, I thought of that when I went to bed yesterday, and felt like such a n00b(or whatever 16 year old geeks call it :P ). But yeah, of course it would work if you actually download the mail or fetch of some sort.

My perticular problem is that I just use the mailer app to check for new messages, but use webmail to read them..
I think it might be possible to write a simple script to tell the pop-server to reset new mail in the same way as when you click the "All mail from now on"-option, but the guys who run gmail, will have to give out a bit of info on how to tell the server. But if they do, it should be possible to add this to the mailer-app, eg on the click-action..?.

Cheers for the help anyways!

By syfou (Core Developer & Desklet Author), on Tue Apr 12 00:52:52 2005.

I do not know how the gmail team set this POP3 compatibility bridge, but the operation you describe (setting back dates or other parameters from messages) is beyond the scope of what POP3 can do (I do not know about the compatibilty layer, though). But I nevertheless see at least two alternate ways you could do this without using higher-level access to the gmail-specific interface:

Finally no, there are no limitation on what action you can trigger through the left-click button... Let me know what you'll do! :-)

By syfou (Core Developer & Desklet Author), on Thu Apr 21 19:22:09 2005.

Copied verbatim from an original message by swim:
Trying to start mail checker nothing happens, cursor sits at prompt. A ctrl+z later and it spits out this code. I use other desklets successfully.

Code:


Traceback (most recent call last):
  File "./mailer.py", line 391, in ?
    Events(dirname(__file__)).pause()
  File "./mailer.py", line 199, in __init__
    adesklets.Events_handler.__init__(self)
  File "/usr/lib/python2.4/site-packages/adesklets/events_handler.py", line 159, in __init__
    self._alarm()
  File "/usr/lib/python2.4/site-packages/adesklets/events_handler.py", line 296, in _alarm
    timeout=self.alarm()
  File "./mailer.py", line 240, in alarm
    self._display()
  File "./mailer.py", line 304, in _display
    adesklets.context_set_font(self._caption_font)
  File "/usr/lib/python2.4/site-packages/adesklets/commands.py", line 383, in context_set_font
    print >> comm,   'context_set_font',   strings.String(font)
  File "/usr/lib/python2.4/site-packages/adesklets/commands_handler.py", line 45, in write
    print >> self.__comm, self.__command
  File "/usr/lib/python2.4/site-packages/adesklets/communicator.py", line 79, in write
    raise ADESKLETSError(1)
adesklets.error_handler.ADESKLETSError: adesklets process exited -

By syfou (Core Developer & Desklet Author), on Thu Apr 21 19:32:12 2005.

The trace is not helpful, unluckily... It only tells: "this desklet was interputted by unhooking stdin from the terminal". I would need a little more details... What does your configuration look like? You got no display at all, or is it just empty (can you left-click on it and get the contextual menu)? Are you sure the credential you provided to your mail server are correct, and that the server is answering, not hanging indefinitely? What happens if you plainly remove the config.txt file? Help me help you: I am a little in the dark here.

By swim (User), on Thu Apr 21 21:19:50 2005.

Hi sorry about that here is more information:

When I run it I see no display at all ever.


When I''ve configured the config.txt this way...

Code:


id0 = {'background_color': '1E1E1E',
 'background_gradient_cutpoint': 40,
 'background_opacity': 100,
 'caption': '',
 'caption_color': 'FFFFFF',
 'caption_font': 'Vera',
 'caption_font_size': 10,
 'delay': 300,
 'host': 'pop.gmail.com',
 'icon_height': 48,
 'icon_width': 48,
 'icons': ['error.png', 'noemail.png', 'email.png'],
 'imap': False,
 'message_color': None,
 'message_font': None,
 'message_font_size': None,
 'messages': ['connection error',
              'no new message',
              '1 new message',
              'new messages'],
 'messages_prepend': True,
 'program_on_click': None,
 'program_on_new': 'beep.sh',
 'ssl': True,
 'text_padding': 5,
 'user_name': 'joshua.lowell@gmail.com',
 'user_password': 'xxxxxxx'}




...I get this from "ADESKLETS_ID=0 python mailer.py"



Code:


Traceback (most recent call last):
  File "mailer.py", line 391, in ?
    Events(dirname(__file__)).pause()
  File "mailer.py", line 199, in __init__
    adesklets.Events_handler.__init__(self)
  File "/usr/lib/python2.4/site-packages/adesklets/events_handler.py", line 159, in __init__
    self._alarm()
  File "/usr/lib/python2.4/site-packages/adesklets/events_handler.py", line 296, in _alarm
    timeout=self.alarm()
  File "mailer.py", line 240, in alarm
    self._display()
  File "mailer.py", line 304, in _display
    adesklets.context_set_font(self._caption_font)
  File "/usr/lib/python2.4/site-packages/adesklets/commands.py", line 383, in context_set_font
    print >> comm,   'context_set_font',   strings.String(font)
  File "/usr/lib/python2.4/site-packages/adesklets/commands_handler.py", line 45, in write
    print >> self.__comm, self.__command
  File "/usr/lib/python2.4/site-packages/adesklets/communicator.py", line 79, in write
    raise ADESKLETSError(1)
adesklets.error_handler.ADESKLETSError: adesklets process exited -






This is what I get from "./mailer.py" after rm`ing the config.txt file.


Code:


Traceback (most recent call last):
  File "./mailer.py", line 391, in ?
    Events(dirname(__file__)).pause()
  File "./mailer.py", line 199, in __init__
    adesklets.Events_handler.__init__(self)
  File "/usr/lib/python2.4/site-packages/adesklets/events_handler.py", line 159, in __init__
    self._alarm()
  File "/usr/lib/python2.4/site-packages/adesklets/events_handler.py", line 296, in _alarm
    timeout=self.alarm()
  File "./mailer.py", line 240, in alarm
    self._display()
  File "./mailer.py", line 304, in _display
    adesklets.context_set_font(self._caption_font)
  File "/usr/lib/python2.4/site-packages/adesklets/commands.py", line 383, in context_set_font
    print >> comm,   'context_set_font',   strings.String(font)
  File "/usr/lib/python2.4/site-packages/adesklets/commands_handler.py", line 45, in write
    print >> self.__comm, self.__command
  File "/usr/lib/python2.4/site-packages/adesklets/communicator.py", line 79, in write
    raise ADESKLETSError(1)
adesklets.error_handler.ADESKLETSError: adesklets process exited -

By syfou (Core Developer & Desklet Author), on Thu Apr 21 21:47:09 2005.

Ok... Three dumb questions, just to make sure:

Code:


        adesklets.window_set_transparency(False)


I tried your very config, just changing the credentials to a test account of mine, and everything works here... But let's not despair, I am sure we will get to the bottom of this.

By swim (User), on Fri Apr 22 00:47:21 2005.

!! It does appear and even shows new messages properly. I just wasn't waiting long enough for it to start... it takes a good 10 seconds to do so... but otherwise is working, which is excellent :) But is a 10 second startup normal? if so I can live with it.
thx tons btw

By syfou (Core Developer & Desklet Author), on Fri Apr 22 01:12:12 2005.

swim wrote:

But is a 10 second startup normal?

Well, it mostly depends on the server (by itself, this desklet is not slower than any other)... Interrogating the pop3 interface of gmail has been somewhat slow lately, and I guess this caused your unfortunate experience. If you want to make sure this was the cause of the initial lag, I suggest you put print statements at the beginning and just before the return of the Mailer::__call__() method of mailer.py, and then watch things in a console. Let me know if this is not the cause. If it is and this really annoy you, a way around would be to fetch mail locally and have mailer read a local mail server instead.

swin wrote:

thx tons btw

I am glad I could help. Enjoy adesklets!

By swim (User), on Fri Apr 22 01:44:18 2005.

Hmm I can't seem to get mailer to start at xfce4 startup... though the Calendar adesklet does start... and .adesklets shows:

Code:


[/home/joshua/.desklets/mailer-0.0.3/mailer.py]
id=0 screen=0 x=4 y=6

[/home/joshua/.desklets/Calendar-0.5.0/Calendar.py]
id=2 screen=0 x=76 y=806



Odd, running "adesklets" after xfce4 is up brings both desklets up fine.

By dessaya (Desklet Author), on Fri Apr 29 07:35:16 2005: Simple request.

I think no one has brought this up yet. Could it be possible to get mailer to check a local maildir? I use fetchmail to check my POP3 account, so I would like to have mailer to show how many new messages I have in my local inbox.

Thanks,

Diego

By syfou (Core Developer & Desklet Author), on Fri Apr 29 13:51:13 2005, last edited on Sat Apr 30 21:58:55 2005.

Yes Diego, it should be fairly doable... Are you a bit of a programmer yourself? All you need to do it to add the few pertinent lines to the Mailer::__call__() routine from mailter.py, using what's appropriate from the mailbox module, bundled with the Python interpreter...

If you are not, just let me know what format are your local mailboxes in (mbox, maildir, others?)...

By dessaya (Desklet Author), on Sat Apr 30 18:01:48 2005.

syfou wrote:

Yes Diego, it should be fairly doable... Are you a bit of a programmer yourself? All you need to do it to add the few pertinent lines to the Mailer::__call__() routine from mailter.txt, using what's appropriate from the mailbox module, bundled with the Python interpreter...

If you are not, just let me know what format are your local mailboxes in (mbox, maildir, others?)...

Yes, I could do it, and I can't deny it would be fun :wink:
I'm a bit busy with work and studying these days; so as soon as I can get some free time, I will take a look at the code. I don't promess anything, because I'm not a Python programmer (yet) :D

Thanks!

Diego

By horacelau (User), on Mon May 2 19:08:38 2005.

I've locally modified the mailer desklet to read from a mbox mailbox. If anyone is interested, please let me know and I can send you a copy of the desklet (or a diff).

By syfou (Core Developer & Desklet Author), on Mon May 2 19:12:19 2005.

horacelau wrote:


I've locally modified the mailer desklet to read from a mbox mailbox. If anyone is interested, please let me know and I can send you a copy of the desklet (or a diff).

Of course, I am! Feel free to post your diff or your full update here, of send it to me be email (syfou@users.sourceforge.net), at your convenience. By the way, have you seen this announcement?

By syfou (Core Developer & Desklet Author), on Mon May 2 23:43:19 2005.

Thanks for the patch, horacelau. mailer 0.0.4 is now out, with your modification included. Regards,

By albinogirl (User), on Tue May 10 22:57:36 2005: IMAP4 problem.

I saw the previous discussion about POP3 and SSL, but does anyone know if there's an issue with IMAP4 and SSL? I've emerged the latest version of python, and I'm sure I have the right IMAP server in the host field because it's the same as what I have in thunderbird, and thunderbird has no problems getting my mail. As of right now, I'm getting the message "connection error". Here's my config.txt, minus the password.

Code:


id0 = {'background_color': '1E1E1E',
 'background_gradient_cutpoint': 40,
 'background_opacity': 100,
 'caption': '',
 'caption_color': 'FFFFFF',
 'caption_font': 'Vera',
 'caption_font_size': 10,
 'delay': 300,
 'host': 'mymail.rit.edu',
 'icon_height': 48,
 'icon_width': 48,
 'icons': ['error.png', 'noemail.png', 'email.png'],
 'mailspool': '/dev/null',
 'message_color': None,
 'message_font': None,
 'message_font_size': None, 'message_font_size': None,
 'messages': ['connection error',
              'no new message',
              '1 new message',
              'new messages'],
 'messages_prepend': True,
 'method': 'imap4',
 'program_on_click': None,
 'program_on_new': 'beep.sh',
 'ssl': True,
 'text_padding': 5,
 'user_name': 'cdm3791',
 'user_password': 'XXXXXXXXXXXXXXXXX'}



Although I'm not familiar with python, I'm familiar with programming, and looking through the mailer.py script I see that the word "Again" is printed out when it's trying to use the imap4 method. I get the word "Again" printed out, so I know it's trying to use the right method. Unfortunately, POP3 is not an option for me. Any suggestions/help would be much appreciated.

By syfou (Core Developer & Desklet Author), on Wed May 11 00:35:23 2005, last edited on Wed May 11 14:52:26 2005.

From what I see, everything seems fine. I am myself using IMAP4 over SSL from all my accounts: it is supposed to work. :? Just remove temporarily the exception control from the code so we can get the exception trace to the console using this patch (it will make the desklet crash instead of just reporting a connection error), and let us now what you get runnning mailer afterwards.

By albinogirl (User), on Wed May 11 08:16:37 2005.

syfou,

Ok, I'll do that when I after I get home from work. Thanks.

By albinogirl (User), on Wed May 11 17:50:00 2005.

syfou

The patch didn't cause mailer to crash - it still starts and gives me the connection error message. I saved your patch in a file named mailer_error.diff and I didn't get any errors when I applied it. Here's my terminal.

Code:


pocketfuzzies ~ $ cd desklets/mailer-0.0.4
pocketfuzzies mailer-0.0.4 $ ls
COPYING      README   config.txt       icons      mailer_error.diff
GNUmakefile  beep.sh  config.txt.save  mailer.py
pocketfuzzies mailer-0.0.4 $ patch < mailer_error.diff mailer.py
patching file mailer.py
pocketfuzzies mailer-0.0.4 $ killall -9 adesklets python
pocketfuzzies mailer-0.0.4 $ ADESKLETS_ID=0 python mailer.py 



Mailer appeared exactly as before. The only stack trace I get is when I do a ctrl C in the terminal to cancel mailer, but I get the same stack trace when I do that to any of the desklets. I'm pretty sure it's just telling me that the adesklet has been canceled, but I'll post the message just in case it is usful.

Code:


pocketfuzzies mailer-0.0.4 $ ADESKLETS_ID=0 python mailer.py 
Traceback (most recent call last):
  File "mailer.py", line 417, in ?
    Events(dirname(__file__)).pause()
  File "/usr/lib/python2.4/site-packages/adesklets/events_handler.py", line 228, in pause
    posix_signal.pause()
KeyboardInterrupt



I'm certainly no expert, but is the patch set to remove error handling for imap? Once again, I'm thankful for your help.

By syfou (Core Developer & Desklet Author), on Wed May 11 19:29:43 2005.

Hi albinogirl,

I re-read your previous messages many times, and I just cannot see anything wrong with what you did so far. What disturb me is that you just cannot get a usual "connection error" once the patch is applied as long as you use the imap4 code: it would need for the size to be explicitely set to -1, which is not possible anymore.

So I tried things myself, from scratch in bash:

Code:


rm -rf mailer-0.0.4; \
wget -q -O - http://easynews.dl.sourceforge.net/sourceforge/adesklets/mailer-0.0.4.tar.bz2 | tar xj && \
cd mailer-0.0.4 && \
wget -q -O - http://adesklets.sourceforge.net/verbatim/mailer_error.diff | \
patch -s mailer.py && \
echo OK && killall -q -9 adesklets python; \
sleep 1 && ADESKLETS_ID=0 ./mailer.py



Complete console output should look very much like (default method is imap4 without ssl):

Code:


OK
Traceback (most recent call last):
  File "./mailer.py", line 417, in ?
    Events(dirname(__file__)).pause()
  File "./mailer.py", line 225, in __init__
    adesklets.Events_handler.__init__(self)
  File "home/sylvain/python/lib/python2.4/site-packages/adesklets/events_handler.py", line 159, in __init__
  File "home/sylvain/python/lib/python2.4/site-packages/adesklets/events_handler.py", line 296, in _alarm
  File "./mailer.py", line 265, in alarm
    mail = self.mailer()
  File "./mailer.py", line 173, in __call__
    s = self.imaplib.__dict__['IMAP4'+['','_SSL']
  File "/home/sylvain/python/lib/python2.4/imaplib.py", line 160, in __init__
    self.open(host, port)
  File "/home/sylvain/python/lib/python2.4/imaplib.py", line 228, in open
    self.sock.connect((host, port))
  File "<string>", line 1, in connect
socket.gaierror: (-2, 'Name or service not known')



Which is expected, since it tries to connect to an imap4 account, nobody@voidvoid.org, that doesn't exist. Just to make sure, I also tried verbatim your configuration:

Code:


Traceback (most recent call last):                                                       
  File "./mailer.py", line 417, in ?                                                       
    Events(dirname(__file__)).pause()
  File "./mailer.py", line 225, in __init__
    adesklets.Events_handler.__init__(self)
  File "home/sylvain/python/lib/python2.4/site-packages/adesklets/events_handler.py", line 159, in __init__
  File "home/sylvain/python/lib/python2.4/site-packages/adesklets/events_handler.py", line 296, in _alarm
  File "./mailer.py", line 265, in alarm
    mail = self.mailer()
  File "./mailer.py", line 176, in __call__
    s.login(self.config['user_name'],self.config['user_password'])
  File "/home/sylvain/python/lib/python2.4/imaplib.py", line 482, in login
    raise self.error(dat[-1])
imaplib.error: Logon failure: unknown user name or bad password.


Which is perfectly right too since I do not have your password...

I must admit I am a bit out of ideas right now (anything special about your system I should know?): would you paste the automated commands above in a pseudo-terminal just to make sure? Thanks,

By albinogirl (User), on Wed May 11 19:48:32 2005.

ok, I did just as you asked - I ran the commands which got rid of mailer, got it using wget, got the patch using wget, patched it, and ran it before I did any configuration. I got the exact stack trace that you got. So then I put my informtion into the config.txt and ran it and I'm back to square one - no error output on the console, but I get the connection error message. Here's what I got before I edited the config file, and then after I edited it.



Code:

pocketfuzzies mailer-0.0.4 $ sleep 1 && ADESKLETS_ID=0 python mailer.py 
Traceback (most recent call last):
  File "mailer.py", line 417, in ?
    Events(dirname(__file__)).pause()
  File "mailer.py", line 225, in __init__
    adesklets.Events_handler.__init__(self)
  File "/usr/lib/python2.4/site-packages/adesklets/events_handler.py", line 159, in __init__
    self._alarm()
  File "/usr/lib/python2.4/site-packages/adesklets/events_handler.py", line 296, in _alarm
    timeout=self.alarm()
  File "mailer.py", line 265, in alarm
    mail = self.mailer()
  File "mailer.py", line 173, in __call__
    s = self.imaplib.__dict__['IMAP4'+['','_SSL']
  File "/usr/lib/python2.4/imaplib.py", line 160, in __init__
    self.open(host, port)
  File "/usr/lib/python2.4/imaplib.py", line 228, in open
    self.sock.connect((host, port))
  File "<string>", line 1, in connect
socket.gaierror: (-2, 'Name or service not known')
pocketfuzzies mailer-0.0.4 $ nano config.txt 
pocketfuzzies mailer-0.0.4 $ echo OK && killall -q -9 adesklets python
OK
pocketfuzzies mailer-0.0.4 $ sleep 1 && ADESKLETS_ID=0 python mailer.py 



There's nothing special about my system that I am aare of. I'm using a router, but that shouldn't matter, cause thunderbird gets my mail, so I know it's not blocking the SSL port. (I thought to check this before my first post as well) The only thing I can think of is that maybe my school (which is the e-mail account) isn't using imap4, but rather some other imap protocal. Is that possible? And if it is, how can I find out what type of imap they are using? I looked through all of the documentation at http://www.rit.edu/~wwwits/services/email/setup/setup_exchange_quick_reference.html, but all it says is "IMAP". Thanks again.

I also tried playing around with the host field, and whenever I change it, I do get error output, saying "connection refused" Also, if I change the username, or password, it tells me invalid username or password. But with mymail.rit.edu, there's still no error, just the connection error message. In short, it seems to connect because it does give errors when I put in information that I know is incorrect, but something is obviously still wrong. Maybe that helps a bit?

By syfou (Core Developer & Desklet Author), on Wed May 11 20:20:48 2005, last edited on Wed May 11 20:50:31 2005.

This is getting weirder by the minute... Here is another patch (apply against pristine mailer 0.0.4) so we can hopefully get a step by step trace of what happens.

When people say 'imap' these days, they almost always mean imap4. I telnet'ed your server through ssl, and it "speaks" imap4 allright... Getting the proper error messages in some circumstances was a good indication of that.

[EDIT]

:oops: I have been sloppy, forgive me for that: I made a obvious error in the code; I corrected the latest patch to reflect it, and I just published mailer 0.0.5 that hopefully corrects it too. I am pretty sure everything should work for you know (I wasn't running the latest version of the desklet myself, that's why It went undetected). Sorry for that, and thanks for taking the time to report this, albinogirl -- of course, due credit was given to you in the README.

By albinogirl (User), on Wed May 11 20:42:56 2005.

Alright, I applied the new patch to a fresh copy of mailer. Running it without modifying the config.txt file I got:

Code:


ocketfuzzies mailer-0.0.4 $ patch -s < mailer_error_bis.diff mailer.py
pocketfuzzies mailer-0.0.4 $ echo OK && killall -q -9 adesklets python
OK
pocketfuzzies mailer-0.0.4 $ sleep 1 && ADESKLETS_ID=0 python mailer.py 
Get information. Method is imap4
Imap. SSL is False, host is voidvoid.org
Object creation... Ouch! socket.gaierror (-2, 'Name or service not known')
Computed size is -1, now returning.



Now, I can't explain it, but when I put in my information this time it works! I promise you I haven't been jerking you around and wasting your time - I put in the exact same information that I posted the first time (changed the password to the correct thing of course) Here's the output after I changed the config.txt to my information

Code:


pocketfuzzies mailer-0.0.4 $ nano config.txt 
pocketfuzzies mailer-0.0.4 $ sleep 1 && ADESKLETS_ID=0 python mailer.py 
Get information. Method is imap4
Imap. SSL is True, host is mymail.rit.edu
Object creation... Created: <imaplib.IMAP4_SSL instance at 0xb7d21c6c>
Login... logged.
Selecting... selected.
Computing size... Size is 2
Login out... ok.
Computed size is 2, now returning.




I know your patch probably just added print statements, but I have to ask, did you do something in the patch that might have made it work? Regardless, I'm thrilled and sincerely appreciate the time you've spent helping me.

By syfou (Core Developer & Desklet Author), on Wed May 11 20:52:40 2005.

No problem, my pleasure. Sorry again (see above). Yours,

By MrGreen (User), on Sat Jun 11 14:03:24 2005: Gmail set up.

Would it be possibe to post the settings needed to get gmail mail under mailer ?

Or for that matter any email account

A wiki for each adesklet would be very handy so that users & developers alike could put information needed to get adesklets working

I would be glad to write some docs if it would be any help...

By syfou (Core Developer & Desklet Author), on Sat Jun 11 15:19:59 2005: Re: Gmail set up.

MrGreen wrote:


Would it be possibe to post the settings needed to get gmail mail under mailer ?

You can find all the needed settings for getting gmail through pop3 over ssl here. As for configuration examples, just look above in this thread: you will find many working ones. The configuration file also comes with a short description of the various fields.

MrGreen wrote:


A wiki for each adesklet would be very handy so that users & developers alike could put information needed to get adesklets working

I would be glad to write some docs if it would be any help...


I agree that a wiki would be nice. The problem is that this phpbb forum seems to be the best we can afford right now in term of interactive use: I performed some experimentations with tikiwiki and tikipro on sourceforge, and the server farm is just too slow to make them usable. But I am all opened to suggestions if you have any.

By MrGreen (User), on Sat Jun 11 16:59:10 2005.

Emmm maybe add another forum

adesklet tips & tricks (working title lol)

Or this information could be added to documentation .... (on your site)

MrGreen

(who should read a bit more before posting)

By MrGreen (User), on Sun Jun 12 06:10:09 2005, last edited on Mon Jun 13 04:38:06 2005.

EDIT see below .....

By syfou (Core Developer & Desklet Author), on Sun Jun 12 14:26:16 2005.

Here is an updated patch for mailer 0.0.5. It removes exception handling boundaries for the pop3 code, so the desklet crashes with a trace instead of displaying a mere "Connection error" message. Most errors become self-explanarory this way. Apply with:

Code:


patch -p1 <mailer_error2.diff mailer.py



Post the console output here if you still have problems, MrGreen.

By MrGreen (User), on Sun Jun 12 15:16:29 2005.

Right I updated to 0.0.5 :oops: added patch ... seems to work now ... though mail shows 10 new messages when there is none sent a test message to mailbox now shows 11 new emails lol

What if any output do you need ?

By syfou (Core Developer & Desklet Author), on Sun Jun 12 16:06:32 2005.

The provided patch only remove error control; I am glad it works now, but I is not my fault... Something else happened on your side, I am sure. :-) Anyway, I slightly rewrote the error handling code, and published a new version as mailer 0.0.6: you can now have both an error trace in case of transcient connection problem and a "working" desklet at the same time.

As for your number of mail report problem, there is no use giving me console outputs, since this is not a direct problem with mailer code. Keep in mind gmail only offers POP3 over SSL access as a convenience gateway to its real service; the only proper way to use mailer with it is to purge the INBOX periodically with a POP3 client, and set your account right (enable POP on all mails, and NOT keep gmail's copy in the inbox).

We could work out something else using libgmail for instance, but I am a bit reticent to use this when standard protocols exist. What would make more sense is gmail supporting IMAP4, which would map much more closely their persistent data model than POP (But I understand why they do not yet: it would be a huge resource usage increase)... My personal solution was just to use gmail's POP3 gateway to automatically migrate the mail to an IMAP4 server.

By MrGreen (User), on Mon Jun 13 04:37:11 2005.

After Clearing out Gmail mailboxes I get no new messages :P

This is my config file if it helps anyone else ...

** Gmail set up **

Code:

id0 = {'background_color': '1E1E1E',
 'background_gradient_cutpoint': 40,
 'background_opacity': 100,
 'caption': 'Gmail',
 'caption_color': 'FFFFFF',
 'caption_font': 'augie',
 'caption_font_size': 10,
 'delay': 300,
 'host': 'pop.gmail.com',
 'icon_height': 48,
 'icon_width': 48,
 'icons': ['error.png', 'noemail.png', 'email.png'],
 'mailspool': '/dev/null',
 'message_color': None,
 'message_font': None,
 'message_font_size': None,
 'messages': ['connection error',
              'no new message',
              '1 new message',
              'new messages'],
 'messages_prepend': True,
 'method': 'pop3',
 'program_on_click': '<your mail/browser',
 'program_on_new': 'beep.sh',
 'ssl': True,
 'text_padding': 5,
 'user_name': '<your user name>',
 'user_password': '<password>'}



Mr Green

By dessaya (Desklet Author), on Sat Jun 18 16:55:29 2005: Some patches.

Hi! I have made some custom modifications to mailer-0.0.6. I'm posting the output from 'diff -u', with comments added before each changeset. In my opinion, some new features are handy (eg, check inside mbox only if it has changed since last check), and some others are just custom preferences. So, of course you are free to take or leave what you want :wink: .

Code:


--- mailer.py.orig  2005-06-12 16:36:03.000000000 -0300
+++ mailer.py   2005-06-18 17:23:06.000000000 -0300
@@ -47,7 +47,7 @@
 from itertools import count
 import traceback
 import re
-from os import getenv, spawnlp, P_NOWAIT
+from os import getenv, spawnlp, P_NOWAIT, stat, utime
 from os.path import join, dirname

 #-------------------------------------------------------------------------------
@@ -144,7 +144,7 @@
# I like to use the 'beep' program from Debian package 'beep' to play a 
# customized tone. For this purpose I had to modify the line calling the
# program (see later). With this modification, 'beep.sh' won't work unless
# it is specified using full pathname.
                     'icon_height': 48,
                     'delay':300,
                     'program_on_click':None,
-                    'program_on_new':'beep.sh'}
+                    'program_on_new':None}

     def __init__(self,id,filename):
         adesklets.ConfigFile.__init__(self,id,filename)
@@ -168,6 +168,9 @@
# Declare some new variables:
         self.config=config
         self.last_size=-1
         self.size=-1
+        self.last_w = 0
+        self.mbox_last_mtime = 0
+        self.mbox_last_size = 0

     def __call__(self):
         self.last_size=self.size
@@ -198,10 +201,22 @@
# This is the mdification for the mbox method. Two features have been added:
# 1) Check for new messages only if the file has been modified, and 
# 2) Restore modification time after check, in order to not confuse mutt, and
#    maybe other mail clients.
             #
             if self.config['method'] == 'mbox':
                 size=0
-                for m in self.mailbox.PortableUnixMailbox(
-                    file(getenv('MAIL',self.config['mailspool']))):
+                mbox_path = getenv('MAIL',self.config['mailspool'])
+                # Get mbox inode properties:
+                s = stat(mbox_path)
+                # If it hasn't changed since last check, don't bother:
+                if s.st_size == self.mbox_last_size and s.st_mtime == self.mbox_last_mtime:
+                    return self.last_size
+                # It has changed: check again.
+                for m in self.mailbox.PortableUnixMailbox(file(mbox_path)):
                     if m.get('status','N').find('N') != -1:
                        size += 1
+                # Restore inode times: 
+                utime(mbox_path, (s.st_atime, s.st_mtime))
+                # Remember size & time: 
+                self.mbox_last_size = s.st_size
+                self.mbox_last_mtime = s.st_mtime
+       
         except:
             # Exception handling: output a significant printout
             #
@@ -269,10 +284,11 @@
# Use full pathname for program_on_new, ie, don't prepend basedir.
         self._display()
         if mail > self.mailer.last_size and mail>0:
             if self.config['program_on_new']:
-                self._execute(join(self.basedir,
-                                   self.config['program_on_new']))
+                self._execute(self.config['program_on_new'])
         self.unblock()
# Allow for delay < 60 for mbox method.
-        return max(self.config['delay'],60)
+        if self.config['method'] == 'mbox':
+            return self.config['delay']
+        return max(self.config['delay'], 60)

     def menu_fire(self, delayed, menu_id, item):
         if item=='Configure':@@ -282,8 +298,7 @@
# Allow to execute program_on_click even when there are no new messages.
# (Sometimes I want to open mutt to check some old mail).
                               join(self.basedir,'config.txt'))

     def button_press(self, delayed, x, y, button):
-        if self.mailer.size>0:
-            self._execute(self.config['program_on_click'])
+        self._execute(self.config['program_on_click'])

     def background_grab(self,delayed):
         if self.config['background_color']:
@@ -337,8 +352,10 @@
# Never draw using a smaller window width. This is because I don't like to 
# have my desklets changing sizes. The window width will only be changed when
# more space is needed.

         # Compute the window dimensions
         #
-        w=self.config['icon_width']+2*self.config['text_padding']+\
-           max(caption_dim[0],message_dim[0])
+        w=max(self.mailer.last_w, 
+           self.config['icon_width']+2*self.config['text_padding']+
+           max(caption_dim[0],message_dim[0]))
+        self.mailer.last_w = w
         h=max(self.config['icon_height'],caption_dim[1]+message_dim[1]+
               2*self.config['text_padding'])

By syfou (Core Developer & Desklet Author), on Tue Jun 21 16:25:35 2005.

dessaya wrote:


Hi! I have made some custom modifications to mailer-0.0.6. I'm posting the output from 'diff -u',

Thanks for sharing your code, dessaya. Here are random comments on your patch:

Code:


--- mailer.py.orig  2005-06-12 16:36:03.000000000 -0300
+++ mailer.py   2005-06-18 17:23:06.000000000 -0300
@@ -47,7 +47,7 @@
# The new import statements probably belongs to 
# hte Mailer class, just for coding style consistency.
#
 from itertools import count
 import traceback
 import re
-from os import getenv, spawnlp, P_NOWAIT
+from os import getenv, spawnlp, P_NOWAIT, stat, utime

 from os.path import join, dirname

 #-------------------------------------------------------------------------------
@@ -144,7 +144,7 @@
# > I like to use the 'beep' program from Debian package 'beep' to play a
# > customized tone. For this purpose I had to modify the line calling the
# > program (see later). With this modification, 'beep.sh' won't work unless
# > it is specified using full pathname.
#
# Nothing wrong there, this is why there is a 'program_on_new' parameter.
# But there is no need to break current behavior: look at the documentation of
# os.path.join(). Specifying the absolute path name to Debian's beep will do the job
# fine too.
                     'icon_height': 48,
                     'delay':300,
                     'program_on_click':None,
-                    'program_on_new':'beep.sh'}
+                    'program_on_new':None}

     def __init__(self,id,filename):
         adesklets.ConfigFile.__init__(self,id,filename)
@@ -168,6 +168,9 @@
# Declare some new variables:
         self.config=config
         self.last_size=-1
         self.size=-1
+        self.last_w = 0
+        self.mbox_last_mtime = 0
+        self.mbox_last_size = 0

     def __call__(self):
         self.last_size=self.size
@@ -198,10 +201,22 @@
# > This is the mdification for the mbox method. Two features have been added:
# > 1) Check for new messages only if the file has been modified, and
# > 2) Restore modification time after check, in order to not confuse mutt, and
# >   maybe other mail clients.
#
# Mmh. I wasn't aware current code would confuse mutt (isn't it a somewhat bad design, 
# or is it just me? Isn't what ctime is for?). I take your word for it, but I'd like to have 
# confirmation from someone else that this work, as I do not use mbox+mutt on a regular
# basis (what about access race conditions?). Another small coding style issue:
# I used a single return point for the __call__ method.

             #
             if self.config['method'] == 'mbox':
                 size=0
-                for m in self.mailbox.PortableUnixMailbox(
-                    file(getenv('MAIL',self.config['mailspool']))):
+                mbox_path = getenv('MAIL',self.config['mailspool'])
+                # Get mbox inode properties:
+                s = stat(mbox_path)
+                # If it hasn't changed since last check, don't bother:
+                if s.st_size == self.mbox_last_size and s.st_mtime == self.mbox_last_mtime:
+                    return self.last_size
+                # It has changed: check again.
+                for m in self.mailbox.PortableUnixMailbox(file(mbox_path)):
                     if m.get('status','N').find('N') != -1:
                        size += 1
+                # Restore inode times:
+                utime(mbox_path, (s.st_atime, s.st_mtime))
+                # Remember size & time:
+                self.mbox_last_size = s.st_size
+                self.mbox_last_mtime = s.st_mtime
+       
         except:
             # Exception handling: output a significant printout
             #
@@ -269,10 +284,11 @@
# > Use full pathname for program_on_new, ie, don't prepend basedir.
# Bad idea. See above.

         self._display()
         if mail > self.mailer.last_size and mail>0:
             if self.config['program_on_new']:
-                self._execute(join(self.basedir,
-                                   self.config['program_on_new']))
+                self._execute(self.config['program_on_new'])
         self.unblock()
# > Allow for delay < 60 for mbox method.
#
# Why not, this is your CPU cycles. ;-) This was just instroduced to avoid
# people from being banned from their online services. You could have written:
#
# return (max(self.config['delay'],60),self.config['delay'])[self.config['method'] == 'mbox']
-        return max(self.config['delay'],60)
+        if self.config['method'] == 'mbox':
+            return self.config['delay']
+        return max(self.config['delay'], 60)

     def menu_fire(self, delayed, menu_id, item):
         if item=='Configure':@@ -282,8 +298,7 @@
# > Allow to execute program_on_click even when there are no new messages.
# > (Sometimes I want to open mutt to check some old mail).
#
# Not a bad idea, I should probably add a new configurable parameter for this...
                               join(self.basedir,'config.txt'))

     def button_press(self, delayed, x, y, button):
-        if self.mailer.size>0:
-            self._execute(self.config['program_on_click'])
+        self._execute(self.config['program_on_click'])

     def background_grab(self,delayed):
         if self.config['background_color']:
@@ -337,8 +352,10 @@
# > Never draw using a smaller window width. This is because I don't like to
# > have my desklets changing sizes. The window width will only be changed when
# > more space is needed.
#
# Indeed... But I personally like the actual behavior more. Another way around would
# be to introduce a minimal width and height, so that people that would like this behavior
# more could customize this.


         # Compute the window dimensions
         #
-        w=self.config['icon_width']+2*self.config['text_padding']+\
-           max(caption_dim[0],message_dim[0])
+        w=max(self.mailer.last_w,
+           self.config['icon_width']+2*self.config['text_padding']+
+           max(caption_dim[0],message_dim[0]))
+        self.mailer.last_w = w
         h=max(self.config['icon_height'],caption_dim[1]+message_dim[1]+
               2*self.config['text_padding']) 

By dessaya (Desklet Author), on Wed Jun 22 09:09:04 2005.

syfou wrote:

Thanks for sharing your code, dessaya.


Any time :wink:. More comments added below. Removed most of the code for briefness' sake.

Code:


--- mailer.py.orig  2005-06-12 16:36:03.000000000 -0300
+++ mailer.py   2005-06-18 17:23:06.000000000 -0300
@@ -47,7 +47,7 @@
# > The new import statements probably belongs to 
# > hte Mailer class, just for coding style consistency.
#
# Hmm... I don't get it. But yet, I am no Python programmer, 
# so I won't argue ;)
#
-from os import getenv, spawnlp, P_NOWAIT
+from os import getenv, spawnlp, P_NOWAIT, stat, utime
 #-------------------------------------------------------------------------------
@@ -144,7 +144,7 @@
# >> I like to use the 'beep' program from Debian package 'beep' to play a
# >> customized tone. 
#
# > Nothing wrong there, this is why there is a 'program_on_new' parameter.
# > But there is no need to break current behavior: look at the documentation of
# > os.path.join(). Specifying the absolute path name to Debian's beep will do the job
# > fine too.
#
# I confess! I didn't read the docs! :P
#
-                    'program_on_new':'beep.sh'}
+                    'program_on_new':None}
@@ -198,10 +201,22 @@
# >> This is the mdification for the mbox method. Two features have been added:
# >> 1) Check for new messages only if the file has been modified, and
# >> 2) Restore modification time after check, in order to not confuse mutt, and
# >>   maybe other mail clients.
#
# > Mmh. I wasn't aware current code would confuse mutt (isn't it a somewhat bad design, 
# > or is it just me? Isn't what ctime is for?). I take your word for it, but I'd like to have 
# > confirmation from someone else that this work, as I do not use mbox+mutt on a regular
# > basis (what about access race conditions?). Another small coding style issue:
# > I used a single return point for the __call__ method.
#
# Two things to comment here. The first 'new feature' is independent of
# the 'mutt confusing' problem. It just saves CPU cycles. And about this
# mutt problem, It may be a bad design, but this is the way it is :-\
# Check, for instance: http://lists.debian.org/debian-user/2000/05/msg02838.html
#
@@ -269,10 +284,11 @@
# >> Allow for delay < 60 for mbox method.
#
# > Why not, this is your CPU cycles. ;-) This was just instroduced to avoid
# > people from being banned from their online services. You could have written:
# > 
# > return (max(self.config['delay'],60),self.config['delay'])[self.config['method'] == 'mbox']
#
# Come on! Is this really the python coding style? It makes me want
# to go back to C :) .
#
-        return max(self.config['delay'],60)
+        if self.config['method'] == 'mbox':
+            return self.config['delay']
+        return max(self.config['delay'], 60)

By syfou (Core Developer & Desklet Author), on Wed Jun 22 14:20:05 2005.

dessaya wrote:


syfou wrote:


dessaya wrote:


This is the mdification for the mbox method. Two features have been added:

  • Check for new messages only if the file has been modified, and
  • Restore modification time after check, in order to not confuse mutt, and maybe other mail clients.


Mmh. I wasn't aware current code would confuse mutt (isn't it a somewhat bad design, or is it just me? Isn't what ctime is for?). I take your word for it, but I'd like to have confirmation from someone else that this work, as I do not use mbox+mutt on a regular basis (what about access race conditions?). Another small coding style issue: I used a single return point for the __call__ method.


Two things to comment here. The first 'new feature' is independent of the 'mutt confusing' problem. It just saves CPU cycles. And about this mutt problem, It may be a bad design, but this is the way it is :-\ Check, for instance: http://lists.debian.org/debian-user/2000/05/msg02838.html


I knew there were two independent features implemented. I wonder if there is any use of the first, since it seems to be particuliarly useful for very short update times, such as what you allow later by removing the artificial 1 minute minimal refresh delay. I recall reading a 25 MB / 3000 emails mbox on an athlon tbird 1.4 GHz: it takes less than a second from a cold disk state. And about the 'mutt confusing', what if there is an access race, or if the filesystem is mounted with the noatime flag or over NFS (not uncommon for mboxes) ? But do not worry, since it does no harm, I will integrate this.

dessaya wrote:


syfou wrote:


Code:


return (max(self.config['delay'],60),self.config['delay'])[self.config['method'] == 'mbox'] 



Come on! Is this really the python coding style? It makes me want to go back to C :) .


:lol:. You are right: this is ugly. Just a bad habit I took playing around with static analysis programs that require single return points.

Here is a reviewed patch summarizing your changes against mailer 0.0.6; let me know if it still works for you -- I tested everything but the updated mbox code, since I do not have any at my disposal right now. I will release mailer 0.0.7 if everything behaves as expected. Regards,

By dessaya (Desklet Author), on Wed Jun 22 22:02:22 2005.

syfou wrote:


I knew there were two independent features implemented. I wonder if there is any use of the first, since it seems to be particuliarly useful for very short update times, such as what you allow later by removing the artificial 1 minute minimal refresh delay. I recall reading a 25 MB / 3000 emails mbox on an athlon tbird 1.4 GHz: it takes less than a second from a cold disk state.

Of course, the only reason I want a delay of less than 1 minute is because I'm ridiculously impatient and I can't wait to read my new mail :wink:. If you set delay=5 like I do, it makes sense to add this 'read mbox only if needed' feature.

syfou wrote:


And about the 'mutt confusing', what if there is an access race, or if the filesystem is mounted with the noatime flag or over NFS (not uncommon for mboxes) ? But do not worry, since it does no harm, I will integrate this.

Yes, yes, all these are potential issues with mutt and I don't know what would happen in those cases. For now, this works and it's what most biff-like programs do, iirc.

syfou wrote:


Here is a reviewed patch summarizing your changes against mailer 0.0.6; let me know if it still works for you -- I tested everything but the updated mbox code, since I do not have any at my disposal right now. I will release mailer 0.0.7 if everything behaves as expected. Regards,

Works like a charm. Thanks for your time, syfou!

By syfou (Core Developer & Desklet Author), on Thu Jun 23 00:43:12 2005.

dessaya wrote:


Works like a charm. Thanks for your time, syfou!

Thanks to you, dessaya. mailer 0.0.7 is now out, including your changes. You made yourself up to the special rank of Desklet Contributor. 8)

By alec (User), on Thu Jul 14 12:11:05 2005: Icon and text not showing.

I'm using mailer-0.07 with imap and ssl and most of the time I just get the background image without the icon nor the text. Sometimes, after restarting the desklet a few times, I can get these to appear and the desklet works fine. Other than specifying the host, username, password and ssl options, I have not changed anything.

By syfou (Core Developer & Desklet Author), on Thu Jul 14 13:42:01 2005.

alec, there is a haunting timing problem with display on start in my adesklets python module code; just wait long enough (the delay between two refreshes), and you should see the information you seek... This not only affect this desklet but many others that uses completely static displays updated periodically, and only on certain systems (not my primary one, unfortunately). I will be investigating this, but I cannot get you a deadline for a clean resolution. For now, a simple fix is just to fiddle with the return value of the alarm() function: just make sure you lower the update delay to a few seconds on the first call.

By zveanturz (User), on Wed Feb 15 18:07:34 2006.

Hi

I'm using adesklets 0.5 with the mailer (0.0.8)desklets. Everything works fine but when I click on the desklets; the desklets disapear. If I restart adesklets it reapper. Anyone has got an idea to solve this problem?

Here it is my configuration file

id0 = {'background_color': '1E1E1E',
'background_gradient_cutpoint': 40,
'background_opacity': 100,
'caption': '',
'caption_color': 'FFFFFF',
'caption_font': 'Vera',
'caption_font_size': 10,
'click_anytime': False,
'delay': 300,
'host': 'pop.free.fr',
'icon_height': 48,
'icon_width': 48,
'icons': ['error.png', 'noemail.png', 'email.png'],
'mailspool': '/dev/null',
'message_color': None,
'message_font': None,
'message_font_size': None,
'messages': ['connection error', 'no new message', '1 new message', 'new messages'],
'messages_prepend': True,
'method': 'pop3',
'program_on_click': None,
'program_on_new': 'beep.sh',
'ssl': False,
'text_padding': 5,
'user_name': 'ldelettre',
'user_password': 'XXX secret XXX',
'window_never_shrink': False}

By zveanturz (User), on Wed Feb 15 18:20:24 2006.

Ok i've found the solution
here it is my new conf

id0 = {'background_color': '1E1E1E',
'background_gradient_cutpoint': 40,
'background_opacity': 100,
'caption': '',
'caption_color': 'FFFFFF',
'caption_font': 'Vera',
'caption_font_size': 10,
'click_anytime': False,
'delay': 300,
'host': 'pop.free.fr',
'icon_height': 48,
'icon_width': 48,
'icons': ['error.png', 'noemail.png', 'email.png'],
'mailspool': '/dev/null',
'message_color': None,
'message_font': None,
'message_font_size': None,
'messages': ['connection error', 'no new message', '1 new message', 'new messages'],
'messages_prepend': True,
'method': 'pop3',
'program_on_click': '/usr/bin/thunderbird',
'program_on_new': 'beep.sh',
'ssl': False,
'text_padding': 5,
'user_name': 'ldelettre',
'user_password': 'XXX secret XXX',
'window_never_shrink': False}

By Bitpicker (User), on Wed Sep 6 03:24:42 2006.

I've got a problem with mailer 0.0.8. I've been using it for quite a while on my Gentoo system, with two different e-mail accounts, one is imap, one pop3. Now I wanted to add a third one, so with no X server and no instance of adesklets running I edited the config.txt file by copying the id1 entry and editing it to look as follows:

Code:


id0 = {'background_color': 'DDDDDD',
 'background_gradient_cutpoint': 0,
 'background_opacity': 0,
 'caption': 'web.de',
 'caption_color': 'd0d0ff',
 'caption_font': 'Vera',
 'caption_font_size': 10,
 'click_anytime': False,
 'delay': 300,
 'host': 'imap.web.de',
 'icon_height': 48,
 'icon_width': 48,
 'icons': ['error.png', 'noemail.png', 'email.png'],
 'mailspool': '/dev/null',
 'message_color': False,
 'message_font': None,
 'message_font_size': None,
 'messages': ['Fehler', '0 Mails', '1 Mail', 'Mails'],
 'messages_prepend': True,
 'method': 'imap4',
 'program_on_click': '/opt/thunderbird/thunderbird',
 'program_on_new': 'beep.sh',
 'ssl': False,
 'text_padding': 5,
 'user_name': 'myuser',
 'user_password': 'mypassword',
 'window_never_shrink': False}

id1 = {'background_color': 'DDDDDD',
 'background_gradient_cutpoint': 0,
 'background_opacity': 0,
 'caption': 'compuserve.de',
 'caption_color': 'd0d0ff',
 'caption_font': 'Vera',
 'caption_font_size': 10,
 'click_anytime': False,
 'delay': 300,
 'host': 'pop.compuserve.de',
 'icon_height': 48,
 'icon_width': 48,
 'icons': ['error.png', 'noemail.png', 'email.png'],
 'mailspool': '/dev/null',
 'message_color': False,
 'message_font': None,
 'message_font_size': None,
 'messages': ['Fehler', '0 Mails', '1 Mail', 'Mails'],
 'messages_prepend': True,
 'method': 'pop3',
 'program_on_click': '/opt/thunderbird/thunderbird',
 'program_on_new': 'beep.sh',
 'ssl': False,
 'text_padding': 5,
 'user_name': 'myuser',
 'user_password': 'mypassword',
 'window_never_shrink': False}

id2 = {'background_color': 'DDDDDD',
 'background_gradient_cutpoint': 0,
 'background_opacity': 0,
 'caption': 'nyboria.de',
 'caption_color': 'd0d0ff',
 'caption_font': 'Vera',
 'caption_font_size': 10,
 'click_anytime': False,
 'delay': 300,
 'host': 'imap.1und1.de',
 'icon_height': 48,
 'icon_width': 48,
 'icons': ['error.png', 'noemail.png', 'email.png'],
 'mailspool': '/dev/null',
 'message_color': False,
 'message_font': None,
 'message_font_size': None,
 'messages': ['Fehler', '0 Mails', '1 Mail', 'Mails'],
 'messages_prepend': True,
 'method': 'imap4',
 'program_on_click': '/opt/thunderbird/thunderbird',
 'program_on_new': 'beep.sh',
 'ssl': False,
 'text_padding': 5,
 'user_name': 'myuser',
 'user_password': 'mypassword',
 'window_never_shrink': False}



Then I started my X server and desktop (XFce), and only the two former accounts appeared, not the id2 one. I tried starting a third instance of mailer from the command line in mailer's directory like this:

Code:


./mailer.py &



The instance started, but it did not show any icon, nor did anything invisible appear on the top left (which I checked by trying to right-click it); instead, if I shutdown all adesklets (adesklets -k), then another web.de mailer appears, and if I quit that one, yet another, and only after I quit that all adesklets are gone.

Next I tried swapping the ids around, and in fact when I edit the config file so that the new account (nyboria.de) gets id0, then it actually starts and works but I don't get any of the other two accounts.

I'm at a loss, I don't know what to try next. Can anyone make a suggestion?

Robin


adesklets is proud to be hosted on:

SourceForge.net Logo

Back to adesklets.sf.net.