Zwei Makros gleichzeitig ausführen?

Allgemeines zum Thema EventGhost
Ron The Don
Posts: 19
Joined: Sun Dec 22, 2013 11:34 am

Zwei Makros gleichzeitig ausführen?

Post by Ron The Don » Sat Dec 28, 2013 6:02 pm

Ich grüße Euch,

ich poste auch mal hier im dt. Forum, weil ich die mir hier entgegen gebrachte Hilfe eher verstehe :lol:.

Ich möchte im Prinzip nur die Kontrolle über mein XBMC mit der Fernbedienung behalten, also weiter XBMX bedienen, während
EventGhost an anderer Stelle ein Makro von oben nach Unten durch arbeitet. Ich weiß nicht ob das möglich ist,
denn momentan ist XBMC für die Dauer der Ausführung des anderen Makros nicht zu benutzen.

Image

XML:
https://www.dropbox.com/s/k1dvgbocrgr4sap/XBMC.xml

Ron The Don
Posts: 19
Joined: Sun Dec 22, 2013 11:34 am

Re: Zwei Makros gleichzeitig ausführen?

Post by Ron The Don » Wed Jan 01, 2014 11:47 am

Frohes Neues! Hat jemand vielleicht eine Idee? Habe ich es schlecht formuliert?

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Zwei Makros gleichzeitig ausführen?

Post by krambriw » Wed Jan 01, 2014 3:35 pm

Also, dass geht nicht so einfach, ich hoffe ein bisschen english ist okay?

EG is running in a single thread so to do many things *at the same time* you have to use several threads. Also if you use the eg.Scheduler it is possible since it is also using separate threads.

But what you would like to do requires python scripting or writing a new plugin that handles it.

Best regards, Walter

Ron The Don
Posts: 19
Joined: Sun Dec 22, 2013 11:34 am

Re: Zwei Makros gleichzeitig ausführen?

Post by Ron The Don » Thu Jan 02, 2014 2:27 pm

Hello Walter,

Thanks for your reply and English is fine! To use the scheduler and retain control while those are executed, how would I go about doing that?
I added the scheduler plugin, but it's asking for an XML file. Should I create a separate XML file with those "directory watch" parts?

Edit: I couldn't figure it out and I am hoping for your expert expertise :cry:

I'll write down the logic:
1. When a folder is moved to "M:\incoming\", a program called "The Renamer" should start and move this folder to "M:\Movies".
2. When a folder is moved to "M:\Movies\", "Ember Media Manager" should start and automatically scrape information for this movie and then update the XBMC video library.

This should happen in the background while XBMC is running. I keep focus on XBMC through "FocusBitch", but I lose control of XBMC during the time process 1) and 2) are
running, because Eventghost will not process any inputs while these makros are running.

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Zwei Makros gleichzeitig ausführen?

Post by krambriw » Fri Jan 03, 2014 7:00 am

I added the scheduler plugin, but it's asking for an XML file. Should I create a separate XML file with those "directory watch" parts?
No, not the Scheduler plugin. I am talking about the eg.scheduler, it is functions built into eg itself to be used when you are writing plugins or python scripts.
The only way to make things happen "at the same time" is to have them running in individual threads but it will require python programming

Best regards, Walter

Ron The Don
Posts: 19
Joined: Sun Dec 22, 2013 11:34 am

Re: Zwei Makros gleichzeitig ausführen?

Post by Ron The Don » Sat Jan 04, 2014 12:43 pm

Oh... I cannot program/script. Guess I have to live with it :D
Thanks anyway Walter

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Zwei Makros gleichzeitig ausführen?

Post by krambriw » Sat Jan 04, 2014 1:14 pm

I will try to give you an example python script running in a thread based on your description above...
Give me a day or so

Best regards, Walter

Also, ich verstehe auch Deutsch aber ich schreibe lieber in English...

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Zwei Makros gleichzeitig ausführen?

Post by krambriw » Sat Jan 04, 2014 1:46 pm

I gave it a shot

Try this:

Instead of starting the programs "the Renamer" and "Ember Media Manager" directly from EG as you do now, replace those with the python scripts instead. The programs will then be started by separate threads and will not block EG.

You have to edit the scripts so that they fit with the correct program names and paths, I did the samples using wordpad as example...

To get the correct syntax for a program start, you can just do "Copy As Python" with your existing configuration.

I do not know if this will be enough to make EG work directly, it might be that your 'Kill Powershell" commands must be moved to the scripts as well but we can start without to see what happens

Best regards

Python Script for 'the Renamer'

Code: Select all

from threading import Thread, Event

def theRenamer(theRenamerThreadEvent):
    eg.plugins.System.Execute(
        u'C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe',
        u'',
        0,
        False,
        2,
        u'C:\\Program Files\\Windows NT\\Accessories',
        False
    )
    theRenamerThreadEvent.set()
    print "theRenamer thread finished"


theRenamerThreadEvent = Event()
theRenamerThread = Thread(
    target=theRenamer,
    args=(theRenamerThreadEvent,)
)
theRenamerThread.start()
print "Starting theRenamer thread"
Python Script for 'Ember Media Manager'

Code: Select all

from threading import Thread, Event

def emberMediaManager(emberMediaManagerThreadEvent):
    eg.plugins.System.Execute(
        u'C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe',
        u'',
        0,
        False,
        2,
        u'C:\\Program Files\\Windows NT\\Accessories',
        False
    )
    emberMediaManagerThreadEvent.set()
    print "emberMediaManager thread finished"


emberMediaManagerThreadEvent = Event()
emberMediaManagerThread = Thread(
    target=emberMediaManager,
    args=(emberMediaManagerThreadEvent,)
)
emberMediaManagerThread.start()
print "Starting emberMediaManager thread"

Ron The Don
Posts: 19
Joined: Sun Dec 22, 2013 11:34 am

Re: Zwei Makros gleichzeitig ausführen?

Post by Ron The Don » Sun Jan 05, 2014 6:07 pm

Ah, thank you Walter!

I am getting an error message when I add the python script, any idea why?

Code: Select all

    from threading import Thread, Event

    def theRenamer(theRenamerThreadEvent):
        eg.plugins.System.Execute(
            u'C:\Program Files (x86)\theRenamer\theRenamer.exe',
            u'',
            0,
            False,
            2,
            u'C:\Program Files (x86)\theRenamer\',
            False
        )
        theRenamerThreadEvent.set()
        print "theRenamer thread finished"


    theRenamerThreadEvent = Event()
    theRenamerThread = Thread(
        target=theRenamer,
        args=(theRenamerThreadEvent,)
    )
    theRenamerThread.start()
    print "Starting theRenamer thread"
Image

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Zwei Makros gleichzeitig ausführen?

Post by krambriw » Sun Jan 05, 2014 9:47 pm

I think there might be several problems

a) you have to use double \\ in program name and paths like ''C:\\Program Files (x86)\\theRenamer\\theRenamer.exe'

b) the path must look like this u'C:\\Program Files (x86)\\theRenamer', (you have a \ at the end of the line

c) it might be you have to run EG as admin

Please post some screenshots or 'Copy As Python' of your previous configurations for
- Kill Powershell
- Start theRenamer
- Start emberMediaManager

and I can analyze them in detail

Ron The Don
Posts: 19
Joined: Sun Dec 22, 2013 11:34 am

Re: Zwei Makros gleichzeitig ausführen?

Post by Ron The Don » Mon Jan 06, 2014 11:37 am

Hello Walter,

to narrow down the mistake, I created an entirely new Eventghost script.
I changed the path to include \\ and started it as Administrator.

Code: Select all

        from threading import Thread, Event

        def theRenamer(theRenamerThreadEvent):
            eg.plugins.System.Execute(
                u'C:\\Program Files (x86)\\theRenamer\\theRenamer.exe',
                u'',
                0,
                False,
                2,
                u'C:\\Program Files (x86)\\theRenamer',
                False
            )
            theRenamerThreadEvent.set()
            print "theRenamer thread finished"


        theRenamerThreadEvent = Event()
        theRenamerThread = Thread(
            target=theRenamer,
            args=(theRenamerThreadEvent,)
        )
        theRenamerThread.start()
        print "Starting theRenamer thread"
I still get error messages:

Image


This is my entire XML File:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1610" Guid="{29199875-B84A-4757-BA40-2E54D0F1CF02}" Time="1389008043.66">
    <Autostart Name="Autostart" />
    <Macro Name="Python Skript" Expanded="True">
        <Action>
            EventGhost.PythonScript(u'        from threading import Thread, Event\n\n        def theRenamer(theRenamerThreadEvent):\n            eg.plugins.System.Execute(\n                u\'C:\\\\Program Files (x86)\\\\theRenamer\\\\theRenamer.exe\',\n                u\'\',\n                0,\n                False,\n                2,\n                u\'C:\\\\Program Files (x86)\\\\theRenamer\',\n                False\n            )\n            theRenamerThreadEvent.set()\n            print "theRenamer thread finished"\n\n\n        theRenamerThreadEvent = Event()\n        theRenamerThread = Thread(\n            target=theRenamer,\n            args=(theRenamerThreadEvent,)\n        )\n        theRenamerThread.start()\n        print "Starting theRenamer thread"\n')
        </Action>
    </Macro>
</EventGhost>

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Zwei Makros gleichzeitig ausführen?

Post by krambriw » Mon Jan 06, 2014 3:01 pm

Something goes obviously wrong here. I have made a simplified EG xml file just to start Notepad that you can try to open but since you are running win7 64 bit, you need to modify it.

1) Open the xml file with EG

2) Add an action inside the macro "Start Application" for your Notepad application

3) Now right click on this action and select "Copy As Python"

4) Open the python script configuration and replace the line "eg.plugins.System.Execute(..." with what you just copied

5) Save and test, Notepad should start if everything is ok

6) If successful, do the same but now for theRenamer application instead

BestR
theRenamer.xml
You do not have the required permissions to view the files attached to this post.

Ron The Don
Posts: 19
Joined: Sun Dec 22, 2013 11:34 am

Re: Zwei Makros gleichzeitig ausführen?

Post by Ron The Don » Tue Jan 07, 2014 7:55 pm

Thanks Walter,

"Copy to Python" is greyed out. I cannot select it. Any ideas why?

Edit: Nevermind, I didn't understand what you meant. The Renamer now starts using your script. Do I need to do the same for Ember Media Manager as well and this solves my problem?

Thanks again!!


Edit2: I think I got "The Renamer" going using your template and just replacing the parts, but Ember is not really cooperative :D

Code: Select all

    from threading import Thread, Event

    def emberMediaManager(emberMediaManagerThreadEvent):
eg.plugins.System.Execute(u'C:\\Users\\Illium\\Downloads\\EmberMM-Deploy_20131122\\EmberMM-Deploy_20131122\\Ember Media Manager.exe', u'-newauto -all -nowindow', 1, True, 2, u'C:\\Users\\Illium\\Downloads\\EmberMM-Deploy_20131122\\EmberMM-Deploy_20131122, False)
        emberMediaManagerThreadEvent.set()
        print "emberMediaManager thread finished"


    emberMediaManagerThreadEvent = Event()
    emberMediaManagerThread = Thread(
        target=emberMediaManager,
        args=(emberMediaManagerThreadEvent,)
    )
    emberMediaManagerThread.start()
    print "Starting emberMediaManager thread"

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Zwei Makros gleichzeitig ausführen?

Post by krambriw » Tue Jan 07, 2014 9:22 pm

You have to be very careful when copying the script
Python is very sensitive to formatting
Look at my first examples

In yours, you have a lot of spaces starting the lines

This not accepted by the Python compiler

You can combine everything in one script but it will be more complex so I made two to make it easier to understand the logic

Br

Ron The Don
Posts: 19
Joined: Sun Dec 22, 2013 11:34 am

Re: Zwei Makros gleichzeitig ausführen?

Post by Ron The Don » Tue Jan 07, 2014 9:54 pm

I thought as much. I still cannot get it to work though and I think my command line options must be at fault.
I seem unable to incorporate those into your template, could you take a look.

I need to incorporate this into your template but I keep getting errors.

Code: Select all

eg.plugins.System.Execute(u'C:\\Users\\Illium\\Downloads\\EmberMM-Deploy_20131122\\EmberMM-Deploy_20131122\\Ember Media Manager.exe', u'-newauto -all -nowindow', 1, True, 2, u'', False)
This is how it looks finished:

Code: Select all

    from threading import Thread, Event

    def emberMediaManager(emberMediaManagerThreadEvent):
        eg.plugins.System.Execute(
            u'C:\\Users\\Illium\\Downloads\\EmberMM-Deploy_20131122\\EmberMM-Deploy_20131122\\Ember Media Manager.exe',
            u'-newauto -all -nowindow',
            1,
            True,
            2,
            u'C:\\Users\\Illium\\Downloads\\EmberMM-Deploy_20131122\\EmberMM-Deploy_20131122',
            False
        )
        emberMediaManagerThreadEvent.set()
        print "emberMediaManager thread finished"


    emberMediaManagerThreadEvent = Event()
    emberMediaManagerThread = Thread(
        target=emberMediaManager,
        args=(emberMediaManagerThreadEvent,)
    )
    emberMediaManagerThread.start()
    print "Starting emberMediaManager thread"
Errors are "traceback" and 22:57:41 IndentationError: unexpected indent (28, line 1)

Post Reply