aMule Forum

English => Feature requests => Topic started by: Ezeltje on December 01, 2006, 12:42:42 AM

Title: fun with Events
Post by: Ezeltje on December 01, 2006, 12:42:42 AM
Have I been asleep or is the Events tab in the Preferences notebook new? I only noticed after compiling the CVS from a few days ago... I dunno, maybe it has been there for longer...

In any case, I was playing around a bit with it and wrote a little script called doneDL.sh which uses this new (?) feature to send you an email when a download has completed:

Code: [Select]
#!/bin/bash
#
# Enter your email address here:
eMail=

NameShort=$1
NameLong=$2
Hash=$3
Size=$4

{
echo aMule completed this download:
echo ------------------------------
echo
echo File: "$NameLong"
echo Hash: $Hash
echo -n "Time: "
date | awk '{print $4}'
echo Size: $Size bytes
echo
echo --------------------------------------------------------------------
cas
echo -n "Resident memory: "
echo $(ps u -C amule --no-headers | cut -d" " -f10) kB
echo -n "Virtual memory:  "
echo $(ps u -C amule --no-headers | cut -d" " -f9) kB
echo --------------------------------------------------------------------
} | mail -s "$NameShort" $eMail

To use it, enter your email address where indicated in the code, save the file somewhere in your path (also chmod +x), and add this to the field Core Events on the Events page:

doneDL.sh "%NAME" "%FILE" %HASH %SIZE

MLdonkey has an email notification feature similar to this, except it also reports the amount time the download took. It would be nice if this could be added as one of the % vars.
Title: RE: fun with Events
Post by: phoenix on December 01, 2006, 02:18:40 PM
Quote
Originally posted by Ezeltje
Have I been asleep or is the Events tab in the Preferences notebook new? I only noticed after compiling the CVS from a few days ago... I dunno, maybe it has been there for longer...
You have been asleep. :P

Quote
Originally posted by Ezeltje
In any case, I was playing around a bit with it and wrote a little script called doneDL.sh which uses this new (?) feature to send you an email when a download has completed:
...
Nice script! Thanks!

Quote
Originally posted by Ezeltje
MLdonkey has an email notification feature similar to this, except it also reports the amount time the download took. It would be nice if this could be added as one of the % vars.
Well, I think that the problem here is how do we do that in a platform independent way. As far as I can tell, we don't store this information ourselves in met files. Of course, in Linux there is the part file creation date, that we can access through stat(), but that is probably not platform independent. There is an (undocumented?) function wxStat(), but to use it one would have to create a mess of #ifdefs in the code for each supported (?) platform.

There is, however, a tag in the met file that aMule does not currently use, which is called FT_DL_ACTIVE_TIME. I don't have the information here, but maybe that is the information you want. If I have some time I will see if that is true and if it is easy to integrate and keep this information.

Cheers!
Title: RE: fun with Events
Post by: Ezeltje on December 01, 2006, 03:05:51 PM
Quote
Originally posted by phoenix
Well, I think that the problem here is how do we do that in a platform independent way. As far as I can tell, we don't store this information ourselves in met files. Of course, in Linux there is the part file creation date, that we can access through stat(), but that is probably not platform independent. There is an (undocumented?) function wxStat(), but to use it one would have to create a mess of #ifdefs in the code for each supported (?) platform.

Hmmm, I see the problem.

FWIW, I tried writing a script do this by extracting the date and time the download was started, which, as you know, is recorded in the logfile like this:

Code: [Select]
2006-11-15 13:55:17: Downloading IPfilter.rev39.ShadowCast.rarThese I wrote to a separate file (since the logs get erased). I thought I could compare them with the entries that are logged when the downloads are done:
Code: [Select]
2006-12-01 13:55:17: Finished downloading: IPfilter.rev39.ShadowCast.rarThis would have worked, once I got the date math sorted out, except for the fact that I have the habit of cleaning up filenames; in my case, they almost never remain the same.

Now, if in addition to the file name  aMule would also write the hash of the file to logfile when the download starts, then I could get around this, since the hash is also available via the Events interface. Then, when my script is triggered by a finished download, it could look up the date and time the download was started via its hash in my file of start dates & times. Presto!

Do you follow me?

Quote
There is, however, a tag in the met file that aMule does not currently use, which is called FT_DL_ACTIVE_TIME. I don't have the information here, but maybe that is the information you want. If I have some time I will see if that is true and if it is easy to integrate and keep this information.

Thanks, that would also be helpful, if it is not too much trouble...
Title: Re: fun with Events
Post by: Vollstrecker on December 01, 2006, 03:13:58 PM
The createion or start of a download, and the end if that, aren't an adequate way to find out, how long the files needed to be downloaded. Consider you are in a high queue rank and are waiting 2 hours and then the file get's finished in 2 Minutes, your calculated download time would be 2:02 which isn't really the info you are searching for. And what happens if you stop aMule, and start it 2 days or even longer later?
The only way to get the right info is a counter that counts the time the download is active. If the .met-file has this field, it's got. is this field thought for something else, it can by used for this, or the info has to go to an additional file.
Title: Re: fun with Events
Post by: Ezeltje on December 01, 2006, 04:01:37 PM
I understand your point. To be honest, I am not really that interested in the exact amount of time needed to download a given file. As a piece of anecdotal information, the time it was in the DL queue is kinda nice to know. I am not performing statstical analysis or something....
Title: Re: fun with Events
Post by: Kry on December 01, 2006, 04:07:07 PM
You gotta think of  "development time" versus "is it useful at all?".
Title: RE: fun with Events
Post by: Ezeltje on December 01, 2006, 04:14:04 PM
Quote
Originally posted by phoenix
Nice script! Thanks!
:D

Since I already made some fixes to it, I decided to put it on the wiki. Since there is no page for Events, I created a very rudimentary one:

http://www.amule.org/wiki/index.php/Events

(I gotta say: that captcha is a real PITA)

Maybe someone who knows more than me can explain what the difference is between a core command and a GUI command.

I hope that if other people write scripts using the events hooks, they will add them there.
Title: RE: fun with Events
Post by: phoenix on December 02, 2006, 04:30:37 AM
Quote
Originally posted by Ezeltje
Since I already made some fixes to it, I decided to put it on the wiki. Since there is no page for Events, I created a very rudimentary one:

http://www.amule.org/wiki/index.php/Events
Once again, thanks for your cooperation!

Quote
Originally posted by Ezeltje
(I gotta say: that captcha is a real PITA)
Unfortunatelly, we must use it or the wiki spammers won't leave us.

Quote
Originally posted by Ezeltje
Maybe someone who knows more than me can explain what the difference is between a core command and a GUI command.
Done.

Quote
Originally posted by Ezeltje
I hope that if other people write scripts using the events hooks, they will add them there.
So do I.

Cheers!
Title: RE: fun with Events
Post by: phoenix on December 02, 2006, 08:13:59 PM
Ezeltje,

Quote
Originally posted by Ezeltje
Do you follow me?

Quote
Originally posted by phoenix
There is, however, a tag in the met file that aMule does not currently use, which is called FT_DL_ACTIVE_TIME. I don't have the information here, but maybe that is the information you want. If I have some time I will see if that is true and if it is easy to integrate and keep this information.

Thanks, that would also be helpful, if it is not too much trouble...
Try tomorrow cvs code, please. I have added support for the FT_DL_ACTIVE_TIME tag and it's value can be seen in the file details dialog (middle button mouse click on the file name in the download queue).

On the user event side, I have added the variable DLACTIVETIME that can be used in a script. Also, I have updated the wiki to reflect the change.

Please, give us your feedback with your impressions.

Cheers!
Title: Re: fun with Events
Post by: Ezeltje on December 03, 2006, 05:32:30 PM
Works perfectly -- thanks!   :baby:
Title: suggestion
Post by: Ezeltje on December 11, 2006, 11:06:46 PM
I have a suggestion for two more events:

What do you think?
Title: Re: fun with Events
Post by: wuischke on December 11, 2006, 11:17:06 PM
I like this idea, would be very useful. :)
Title: Re: fun with Events
Post by: phoenix on December 16, 2006, 04:59:05 AM
Hi folks,

Tomorrow's CVS tarball will have code for two new events:

1) Out of space on temporary partition;
2) Error upon completion (which also accounts for out of space on destination partition).

Please test and report!

Cheers!
Title: Re: fun with Events
Post by: Ezeltje on December 16, 2006, 01:43:29 PM
Phoenix, I just downloaded today's CVS and am getting a compile error, see:
http://forum.amule.org/thread.php?threadid=11817

It looks like it has something to do with the ActiveDLtime stuff, but I am no expert.

I look forward to trying out the new Events...
Title: Re: fun with Events
Post by: phoenix on December 16, 2006, 03:07:11 PM
Please, try it again, I believe you used an old tarball by mistake.

Cheers!
Title: so far so good
Post by: Ezeltje on December 17, 2006, 03:51:04 PM
Error upon incompletion seems to work ok; I haven't tested the other yet (I still have a lot space in the temp partition).

I noticed that when Events commands fail, this is logged. Very useful!

In the meantime, I have updated the Events page on the Wiki.
Title: Re: fun with Events
Post by: phoenix on December 17, 2006, 10:11:05 PM
Nice!

You can test the other by creating a very large file on the temp partition just to see if it alarms, and deleting it afterwards.

Thanks for your support!
Title: Re: fun with Events
Post by: Fenix-TX on December 23, 2006, 07:23:02 PM
Hi! i'm using amule on kde, and i want to know if it's possible associate kdialog with amule tray icon.
If i use kdialog --passivepopup %NAME 10 i show a popup but at left top of the screen, so i want to know if it is possible associate kdialog with an application or systray application...

Sorry for my bad english and explanation
Title: Re: fun with Events
Post by: phoenix on December 24, 2006, 12:53:43 AM
Hi Fenix-TX,

Sorry, I did not understand you, try to explain to me what do you mean by "associate kdialog with amule tray icon". I don't understand "associate" in this context. What do you want to do?

Cheers!
Title: Re: fun with Events
Post by: wuischke on December 24, 2006, 01:00:40 AM
I think he means, that the message should appear above the aMule tray icon, not in the top-left corner.
Title: Re: fun with Events
Post by: Fenix-TX on December 24, 2006, 11:36:39 AM
Quote
Originally posted by phoenix
Hi Fenix-TX,

Sorry, I did not understand you, try to explain to me what do you mean by "associate kdialog with amule tray icon". I don't understand "associate" in this context. What do you want to do?

Cheers!

Sorry, i mean....

Quote
Originally posted by wuischke
I think he means, that the message should appear above the aMule tray icon, not in the top-left corner

....that.

And i have a problem with %NAME: If the file name is like "This is a file", it only shows "This".

I'm using this: kdialog --title "aMule Download Completed" --passivepopup %NAME 10
Title: Re: fun with Events
Post by: wuischke on December 24, 2006, 11:40:54 AM
Put the name in quotation marks: "%NAME" , than it should work.
Title: Re: fun with Events
Post by: Fenix-TX on December 24, 2006, 11:42:58 AM
Quote
Originally posted by wuischke
Put the name in quotation marks: "$NAME" , than it should work.

But "$NAME" or "%NAME" ?
Title: Re: fun with Events
Post by: wuischke on December 24, 2006, 11:47:00 AM
Sorry, "%NAME".
Title: Re: fun with Events
Post by: Fenix-TX on December 24, 2006, 11:50:45 AM
Ok, i'll try it. Thanks

EDITED: It's working thanks!!!!!!!!
Title: Re: fun with Events
Post by: phoenix on December 24, 2006, 03:04:38 PM
Quote
Originally posted by Fenix-TX
Quote
Originally posted by wuischke
I think he means, that the message should appear above the aMule tray icon, not in the top-left corner

....that.
Very interesting, I did not know about kdialog, really nice. I have searched a lot to find a way to do it, but I did not manage to succeed :(

Maybe with the parameter --embed? But I found absolutely no documentation about it, except for the man page, and I tried with some X windows id's using xwininfo, but no results.
Title: Re: fun with Events
Post by: Fenix-TX on December 24, 2006, 04:55:30 PM
I don't know how it works embed. But i see examples using dcop+kdialog,(i think that) it's possible with dcop+kdialog associate events to an application, but only on kde applications.

Gnome equivalent to kdialog is zenity.