Page 2 of 2

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Mon Jan 07, 2013 4:06 pm
by Pako
Sorry, I incorrectly tried.
I still have to continue.

Pako

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Mon Jan 07, 2013 5:27 pm
by joaomgcd
Thank you very much.

I appreciate it.

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Mon Jan 07, 2013 7:56 pm
by Pako
I finally found out, where the next (and main) problem.
The module "pickle" can not handle the class "AutoRemoteDevice" (which is stored in the argument "devices").
It can be solved in different ways.
The easiest way is to use an ordinary class tuple or dictionary.

Pako

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Tue Jan 08, 2013 7:44 am
by Pako
Here is one possible way that required minimum modifications.

Pako

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Tue Jan 08, 2013 12:08 pm
by Pako
Sorry, now I fixed a small bug. :oops:

Pako

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Tue Jan 08, 2013 2:38 pm
by joaomgcd
Pako, I have to say, AWESOME!! :mrgreen:
Your latest version works as expected, thanks so much.

Any idea why pickler doesn't correctly support the AutoRemoteDevice class?

Anyway, now I want to keep backwards compatibility with the previous version so I changed

Code: Select all

self.devices = [AutoRemoteDevice(*i) for i in devices]
to

Code: Select all

if len(devices) > 0:
            if(isinstance(devices[0], AutoRemoteDevice)):            
                self.devices = devices
            else:
                self.devices = [AutoRemoteDevice(*i) for i in devices]
But there's just one problem: if a user doesn't open and save the AutoRemote plugin configuration at least once after using this version, they will still get the error because EventGhost still wouldn't use the tuple instead of the AutoRemoteDevice object.

Any way to force EventGhost to save the plugin's configuration without the user manually going into the plugin settings dialog and clicking "Ok"?

Again, thank you very much for your support. :D

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Tue Jan 08, 2013 5:11 pm
by Pako
joaomgcd wrote:Any idea why pickler doesn't correctly support the AutoRemoteDevice class?
I do not know.
You've read the documentation?
joaomgcd wrote: But there's just one problem: if a user doesn't open and save the AutoRemote plugin configuration at least once after using this version, they will still get the error because EventGhost still wouldn't use the tuple instead of the AutoRemoteDevice object.

Any way to force EventGhost to save the plugin's configuration without the user manually going into the plugin settings dialog and clicking "Ok"?
You can do it (simply) like this:

Code: Select all

        if len(devices) > 0:
            if(isinstance(devices[0], AutoRemoteDevice)):           
                self.devices = devices
                trItem = self.info.treeItem
                args = list(trItem.GetArguments())
                args[3] = [AutoRemoteDevice(*i) for i in devices]
                eg.actionThread.Func(trItem.SetArguments)(args)        
                eg.document.SetIsDirty()
                eg.document.Save()
            else:
                self.devices = [AutoRemoteDevice(*i) for i in devices]
        self.port = port
        self.publicIp = publicIp
        self.dname = dname
        self.server = MyServer(RequestHandler, port)
        self.server.Start()

    def __stop__(self):
        self.server.Stop()
Or a little more complicated as follows:

Code: Select all

        if len(devices) > 0:
            if(isinstance(devices[0], AutoRemoteDevice)):           
                self.devices = devices
                trItem = self.info.treeItem
                args = list(trItem.GetArguments())
                args[3] = [AutoRemoteDevice(*i) for i in devices]
                eg.actionThread.Func(trItem.SetArguments)(args)        
                eg.document.SetIsDirty()
                wx.CallAfter(self.SaveConfig)
            else:
                self.devices = [AutoRemoteDevice(*i) for i in devices]
        self.port = port
        self.publicIp = publicIp
        self.dname = dname
        self.server = MyServer(RequestHandler, port)
        self.server.Start()


    def SaveConfig(self):
        from eg.Classes.Document import SaveChangesDialog
        dialog = SaveChangesDialog(eg.document.frame)
        result = dialog.ShowModal()
        dialog.Destroy()
        if result == wx.ID_YES:
            eg.document.Save()


    def __stop__(self):
        self.server.Stop()
Note: untested

Pako

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Tue Jan 08, 2013 5:39 pm
by krambriw
Dear Pako,
This is absolutely a wonderful solution and information, very useful generally indeed. I will remember this for future.
Once again, thank you

Very best regards, Walter

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Tue Jan 08, 2013 5:56 pm
by joaomgcd
Thanks again Pako.

Unfortunately EventGhost hangs at

Code: Select all

eg.actionThread.Func(trItem.SetArguments)(args)  
and eventually times out with this error:

Code: Select all

      Traceback (most recent call last) (1582):
        File "C:\Program Files\EventGhost\eg\Classes\ThreadWorker.py", line 326, in __DoOneEvent
          self.HandleAction(action)
        File "C:\Program Files\EventGhost\eg\Classes\ThreadWorker.py", line 289, in HandleAction
          action()
        File "C:\Program Files\EventGhost\eg\Classes\ThreadWorker.py", line 62, in __call__
          self.returnValue = self.func(*self.args, **self.kwargs)
        File "C:\Program Files\EventGhost\eg\Classes\EventThread.py", line 142, in StartSession
          actionThread.Func(actionThread.StartSession, 120)(filename)
        File "C:\Program Files\EventGhost\eg\Classes\ThreadWorker.py", line 214, in Wrapper
          raise Exception("Timeout while calling %s" % func.__name__)
      Exception: Timeout while calling StartSession
Any ideas?

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Wed Jan 09, 2013 8:26 am
by Pako
Ah, so we have to do it a little differently.
And anyway there was another bug ...

Automatic method:

Code: Select all

        if len(devices) > 0:
            if(isinstance(devices[0], AutoRemoteDevice)):           
                self.devices = devices
                wx.CallAfter(self.SaveConfig, devices)
            else:
                self.devices = [AutoRemoteDevice(*i) for i in devices]
        self.port = port
        self.publicIp = publicIp
        self.dname = dname
        self.server = MyServer(RequestHandler, port)
        self.server.Start()


    def SaveConfig(self, devices):
        trItem = self.info.treeItem
        args = list(trItem.GetArguments())
        args[3] = [(i.name, i.url, i.key) for i in self.devices]
        eg.actionThread.Func(trItem.SetArguments)(args)       
        eg.document.SetIsDirty()
        eg.document.Save()


    def __stop__(self):
        self.server.Stop()
Interactive method:

Code: Select all

        if len(devices) > 0:
            if(isinstance(devices[0], AutoRemoteDevice)):           
                self.devices = devices
                wx.CallAfter(self.SaveConfig, devices)
            else:
                self.devices = [AutoRemoteDevice(*i) for i in devices]
        self.port = port
        self.publicIp = publicIp
        self.dname = dname
        self.server = MyServer(RequestHandler, port)
        self.server.Start()


    def SaveConfig(self, devices):
        trItem = self.info.treeItem
        args = list(trItem.GetArguments())
        args[3] = [(i.name, i.url, i.key) for i in self.devices]
        eg.actionThread.Func(trItem.SetArguments)(args)       
        eg.document.SetIsDirty()
        dialog = eg.Classes.Document.SaveChangesDialog(eg.document.frame)
        result = dialog.ShowModal()
        dialog.Destroy()
        if result == wx.ID_YES:
            eg.document.Save()

    def __stop__(self):
        self.server.Stop()
Pako

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Wed Jan 09, 2013 10:54 am
by joaomgcd
Awesome, that did it!! :mrgreen:

Brilliant! thank you you very much.

The other bug you mentioned I was able to figure out myself as well but thanks for fixing it nonetheless. :)

Awesome, awesome support, thanks!

By the way, how do I apply to be part of the "official" EventGhost plugins? Or is that not open right now?

Thanks again!

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Wed Jan 09, 2013 12:06 pm
by Pako
joaomgcd wrote:By the way, how do I apply to be part of the "official" EventGhost plugins? Or is that not open right now?
B is correct.
Author program (Bitmonster) just before he left the project, worked on major change.
You can read about it here.
I think there is no doubt that it is not appropriate to continually add new plugins to the program.
So we are looking for a person (or team) who could implement this idea. New plugins will not be added.

BTW: If I do (in the future) Android phone I buy, I'll try AutoRemote. I get a discount? :wink:

Pako

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Wed Jan 09, 2013 12:11 pm
by joaomgcd
Better than that, you'll get all my apps for free. :)

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Wed Jan 09, 2013 12:47 pm
by Nelsun
Thanks for help getting this sorted Pako :D I'd say it's worth getting yourself an Android phone (a Nexus 4 if you can) just because of what it + AutoRemote + EventGhost can all achieve together. I cannot imagine not using any of them on a regular basis every single day 8)

Re: AutoRemote EventGhost plugin:EG->Android and Android->EG

Posted: Wed Jan 09, 2013 1:03 pm
by Pako
joaomgcd wrote:Better than that, you'll get all my apps for free. :)
This is amazing!
And how do I do it, when it will current? (You can use PM ...)

Pako