Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Wait until file transfer is complete?

If you have a question or need help, this is the place to be.
piert
Experienced User
Posts: 321
Joined: Tue Jun 14, 2011 2:53 pm

Re: Wait until file transfer is complete?

Post by piert »

Hi Pako,

I think I understand the (clever!) basics of your solution, but Eventhgost complains with the following message:
14:32:11 Traceback (most recent call last):
14:32:11 Python script "18", line 9, in <module>
14:32:11 eg.scheduler.AddTask(20.0, clearMyTimerFlag)
14:32:11 NameError: name 'clearMyTimerFlag' is not defined
Is there an easy solution for the NameError message?
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Wait until file transfer is complete?

Post by Pako »

That's weird. For me it works correctly.
Did you try to close and restart EventGhost?

Pako
jonib
Plugin Developer
Posts: 1328
Joined: Thu Mar 26, 2009 9:33 pm
Location: Sweden

Re: Wait until file transfer is complete?

Post by jonib »

Pako wrote:

Code: Select all

eg.scheduler.AddTask(20.0, clearMyTimerFlag))
Looks like this last code line has a missing "(" or an extra ")".

jonib
Last edited by jonib on Sat Oct 01, 2011 2:19 pm, edited 2 times in total.
XBMC2 plugin to control XBMC. If you want to flatter me Image
hellow
Posts: 11
Joined: Tue Sep 27, 2011 4:36 pm

Re: Wait until file transfer is complete?

Post by hellow »

I get the same error message when i try to check if the macro can work for me. Does the script only act if the event is tiggered again after 20 sec? Or does it que it so it will trigger again when if its like 10 sec since it tiggered?
This is what i saw in eg.
This is what i saw in eg.
if i add the ()) the error stops, but i get new.

16:46:24 Traceback (most recent call last) (1527):
16:46:24 File "C:\Program Files (x86)\EventGhost\eg\Classes\Scheduler.py", line 137, in MainLoop
16:46:24 func(*args, **kwargs)
16:46:24 TypeError: 'NoneType' object is not callable
Last edited by hellow on Sat Oct 01, 2011 2:46 pm, edited 1 time in total.
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Wait until file transfer is complete?

Post by Pako »

I'm sorry, there has to be correctly

Code: Select all

eg.scheduler.AddTask(20.0, clearMyTimerFlag)
Pako
hellow
Posts: 11
Joined: Tue Sep 27, 2011 4:36 pm

Re: Wait until file transfer is complete?

Post by hellow »

Very nice, that sorteted it. But seems that the macro started the program twice. Is this script to designed to tigger the same event every 20 sec. I dont get it :P
Pako wrote:I'm sorry, there has to be correctly

Code: Select all

eg.scheduler.AddTask(20.0, clearMyTimerFlag)
Pako
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Wait until file transfer is complete?

Post by Pako »

The script makes it, that during the set time (eg 20 s) prevents the re-run the macro.

Pako
piert
Experienced User
Posts: 321
Joined: Tue Jun 14, 2011 2:53 pm

Re: Wait until file transfer is complete?

Post by piert »

If I use this in the action Python script and place it in the top of the macro :

Code: Select all

if not "myTimerFlag" in eg.globals.__dict__:
    eg.globals.myTimerFlag = False
    def clearMyTimerFlag():
        eg.globals.myTimerFlag = False
           
if eg.globals.myTimerFlag:
    eg.StopMacro()
eg.globals.myTimerFlag = True
eg.scheduler.AddTask(20.0, clearMyTimerFlag)
I get the following message:
17:29:22 eg.scheduler.AddTask(20.0, clearMyTimerFlag)
17:29:22 NameError: name 'clearMyTimerFlag' is not defined
It does not help to restart Eventghost.
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Wait until file transfer is complete?

Post by Pako »

I do not understand it because I do not have this problem.
But this code modification should help:

Code: Select all

if not "myTimerFlag" in eg.globals.__dict__:
    eg.globals.myTimerFlag = False
    def clearMyTimerFlag():
        eg.globals.myTimerFlag = False
    eg.globals.clearMyTimerFlag = clearMyTimerFlag
        
if eg.globals.myTimerFlag:
    eg.StopMacro()
eg.globals.myTimerFlag = True
eg.scheduler.AddTask(20.0, eg.globals.clearMyTimerFlag)
Pako
piert
Experienced User
Posts: 321
Joined: Tue Jun 14, 2011 2:53 pm

Re: Wait until file transfer is complete?

Post by piert »

I really appreciate your persistance, Pako!

This time I do not get error messages and it manages to do one correct cycle. However, then it goes wrong again.

To explain my test procedure: I have a macro that starts with your Python script, followed by an Action to play a sound.
I have another macro below it (in same folder), that triggers automatically every 5 seconds an event which, in turn, executes the macro above

The following happens when I start the second macro (the 5-seconds looped event generator for triggering the main macro every 5 seconds):

After the first execution the sound plays (=good)
After the second automatic execution, (=5 seconds later), the sound does not play (=good)
After the third automatic execution (=10 seconds later), the sound still does not play (=good)
After the fourth automatic execution (=15 seconds later), the sound still does not play (=good)
After the fifth automatic execution (=20 seconds later), the sound plays again (=good)
After the sixth automatic execution (=25 seconds later), the sound also plays (= not good)
After the seventh automatic execution (=30 seconds later), the sound also plays (= not good)
After the eight automatic execution (=35 seconds later), the sound also plays (= not good)
Etc.

Can you think of an explanation for that behaviour?
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Wait until file transfer is complete?

Post by Pako »

I apologize and thank you for a very illustrative description problem.
I have tested poorly, you are absolutely right.
However, the correction is very simple:

Code: Select all

if not "myTimerFlag" in eg.globals.__dict__:
    eg.globals.myTimerFlag = False
    def clearMyTimerFlag():
        eg.globals.myTimerFlag = False
    eg.globals.clearMyTimerFlag = clearMyTimerFlag
        
if eg.globals.myTimerFlag:
    eg.StopMacro()
else:
    eg.globals.myTimerFlag = True
    eg.scheduler.AddTask(10.0, eg.globals.clearMyTimerFlag)
Pako
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Wait until file transfer is complete?

Post by Pako »

Again, sorry, I forgot to return the timeout to 20 seconds.
Pako
piert
Experienced User
Posts: 321
Joined: Tue Jun 14, 2011 2:53 pm

Re: Wait until file transfer is complete?

Post by piert »

Excellent!!!!!!

Thank you very much Pako! This is a very efficient and clever solution to my problem (and I trust many others' too).

I am just amazed by the fact that you describe this as "This task is really not difficult." :mrgreen:

Best regards,
Perry
hellow
Posts: 11
Joined: Tue Sep 27, 2011 4:36 pm

Re: Wait until file transfer is complete?

Post by hellow »

Thanks alot for this one! :) Gj

Pako wrote:I apologize and thank you for a very illustrative description problem.
I have tested poorly, you are absolutely right.
However, the correction is very simple:

Code: Select all

if not "myTimerFlag" in eg.globals.__dict__:
    eg.globals.myTimerFlag = False
    def clearMyTimerFlag():
        eg.globals.myTimerFlag = False
    eg.globals.clearMyTimerFlag = clearMyTimerFlag
        
if eg.globals.myTimerFlag:
    eg.StopMacro()
else:
    eg.globals.myTimerFlag = True
    eg.scheduler.AddTask(10.0, eg.globals.clearMyTimerFlag)
Pako
celtics101
Posts: 2
Joined: Mon Jun 25, 2012 5:37 am

Re: Wait until file transfer is complete?

Post by celtics101 »

would it be possible to reverse the script?

i.e. if 5 events occur within 1 min, the macro starts on the last one
Post Reply