Update Namespace unavailable in PyCrust
Update Namespace unavailable in PyCrust
I use the included PyCrust to see the current value of variables in EG (Is there a better tool?). Many of the menu items are grayed out, including Update Namespace. So, when EG changes, I have to exit PyCrust and start a new session to see the changed variables. Am I missing something about how to do this efficiently?
- kgschlosser
- Site Admin
- Posts: 5021
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Update Namespace unavailable in PyCrust
something could be made up quite easily. because all of the global variables are stored in eg.Bunch all we would have to do is to make a simple dialog to display all the variable names and their attributes and this can be populated by reading the eg.globals.__dict__ and all of the variables would be updated if create a __setattr__ method for eg.globals.
would you also like to see what the last function called for the variable is??? I can do that as well.
this would actually be a really good addition to any future releases of EG. and make it so that a global variable can be created and deleted as well from the dialog. this would be a good means to manage them.
would you also like to see what the last function called for the variable is??? I can do that as well.
this would actually be a really good addition to any future releases of EG. and make it so that a global variable can be created and deleted as well from the dialog. this would be a good means to manage them.
Re: Update Namespace unavailable in PyCrust
I'll leave that proposal to the programmers here who would know much better than me.
- kgschlosser
- Site Admin
- Posts: 5021
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Update Namespace unavailable in PyCrust
I have most of it done. working on the gui for it now. maybe i will finish up tonight,
- kgschlosser
- Site Admin
- Posts: 5021
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Update Namespace unavailable in PyCrust
OK. this is very much a prototype. There are a couple of issues that i am aware of.
One if you have to double right click the variable to bring up the popup menu for a variable.
I have set a mean in place to "nest" a global for organization. so if you had a global like this.
eg.globals.bedroomLightsCeiling
eg.globals.bedroomLightsWall
you could do this instead. grouping globals together
eg.globals.Bedroom.Lights.ceiling
eg.globals.Bedroom.Lights.wall
the 2 big uses
1: organizaton
2: i set up the class to be an iterator. meaning it can be used in a for loop to get the variable name and value. fo if you wanted to read all of the variables for a given group. or set all the values for a given group.
Example:
say you have a global that points to an action for set a light level, and you name the variable the same as what you would use in an action to set the lights.
set the globals
later on you call this python script to change the levels of the lights in the room
and this would set the levels to 40 and 10 for the respected device. now doing this for one or 2 things wouldn't make sense but if you had 40 items. this would reduce code greatly.
but the 2nd problem is. and i hope someone can help me on this.
is that when the plugin goes and looks at all the variables in eg.globals. if the variable is one of these nested classes it is supposed to add it as a tree Item. but it doesn't.. maybe someone could take a look see and figure out why. i have been messing with it for 2 days now. and i cannot get it to add the tree item.
the plugin is attached. and i will post it in the plugins section as soon as i get the thing operating at 100%
One if you have to double right click the variable to bring up the popup menu for a variable.
I have set a mean in place to "nest" a global for organization. so if you had a global like this.
eg.globals.bedroomLightsCeiling
eg.globals.bedroomLightsWall
you could do this instead. grouping globals together
eg.globals.Bedroom.Lights.ceiling
eg.globals.Bedroom.Lights.wall
the 2 big uses
1: organizaton
2: i set up the class to be an iterator. meaning it can be used in a for loop to get the variable name and value. fo if you wanted to read all of the variables for a given group. or set all the values for a given group.
Example:
say you have a global that points to an action for set a light level, and you name the variable the same as what you would use in an action to set the lights.
set the globals
Code: Select all
eg.globals.Bedroom.Lights.ActionCall = eg.plugins.SomeLightingController.SetLightLevel
eg.globals.Bedroom.Lights.ceiling = ['BedroomCeiling', 40]
eg.globals.Bedroom.Lights.wall = ['BedroomWall', 10]
Code: Select all
actionCall = eg.globals.Bedroom.Lights.ActionCall
for key, value in eg.globals.Bedroom.Lights:
if key != 'ActionCall':
deviceName, level = value
actionCall(deviceName, level)
# or you could just use actionCall(*value) for simplified code, but as an example i wanted to key it out
but the 2nd problem is. and i hope someone can help me on this.
is that when the plugin goes and looks at all the variables in eg.globals. if the variable is one of these nested classes it is supposed to add it as a tree Item. but it doesn't.. maybe someone could take a look see and figure out why. i have been messing with it for 2 days now. and i cannot get it to add the tree item.
the plugin is attached. and i will post it in the plugins section as soon as i get the thing operating at 100%
Re: Update Namespace unavailable in PyCrust
I'd love to give it a try, but GlobalMonitor.egplugin is hieroglyphics. What do I do with it?
Will this also check non-eg.globals variables? Thanks.
Will this also check non-eg.globals variables? Thanks.
- kgschlosser
- Site Admin
- Posts: 5021
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Update Namespace unavailable in PyCrust
I did not design it to check anything other then eg.global variables because the way EG was designed that's the only variables a "normal" user should be setting. if you want it to do more i can have it do that but what i would do is make a hidden action you can enter the module or class name into and it will launch another thread to scan those. but I will not be able to have it show what the last class was that did something with the variable. the eg.Bunch (eg.globals) was easy to do this with because all that was coded in was it updating __dict__. so for me to move everything to a new class that had all the monitoring code in place was easy.
.egplugin
just double click the file and away it goes. no need to restart eg. it will make the folders and files and install the plugin where it needs to be.
it will place the plugin into the c:\programdata\eventghost\plugins folder. not in the install directory folder
.egplugin
just double click the file and away it goes. no need to restart eg. it will make the folders and files and install the plugin where it needs to be.
it will place the plugin into the c:\programdata\eventghost\plugins folder. not in the install directory folder
- kgschlosser
- Site Admin
- Posts: 5021
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Update Namespace unavailable in PyCrust
here is another example of using the iterator feature. in this one if you make the variable name the same as the actual device on the controller that can be used instead of setting a list
set the globals
later on you call this python script to change the levels of the lights in the room
and this would set the levels to 40 and 10 for the respected device.
and if you wanted to set the values of the variables and you know what variable names are stored. the iterator sorts them alphabetically so if you do this
set the globals
the above code will change the Bedroom_Ceiling to 100 and the Bedroom_Wall to 50
set the globals
Code: Select all
eg.globals.Bedroom.Lights.Bedroom_Ceiling = 40
eg.globals.Bedroom.Lights.Bedroom_Wall = 10
Code: Select all
for deviceName, level in eg.globals.Bedroom.Lights:
eg.plugins.SomeLightingController.SetLightLevel(deviceName, level)
and if you wanted to set the values of the variables and you know what variable names are stored. the iterator sorts them alphabetically so if you do this
set the globals
Code: Select all
eg.globals.Bedroom.Lights.Bedroom_Ceiling = 40
eg.globals.Bedroom.Lights.Bedroom_Wall = 10
Code: Select all
lightLevel = [100, 50]
for deviceName, level in eg.globals.Bedroom.Lights:
setattr(deviceName, lightLevel.pop(0))
Re: Update Namespace unavailable in PyCrust
I didn't get the memo when I started using EG, so I just used regular variable names when I didn't need to pass values into a script. Sounds like it will be much easier for me to change my variable names than for you to program it.kgschlosser wrote:I did not design it to check anything other then eg.global variables because the way EG was designed that's the only variables a "normal" user should be setting. if you want it to do more i can have it do that but what i would do is make a hidden action you can enter the module or class name into and it will launch another thread to scan those. but I will not be able to have it show what the last class was that did something with the variable. the eg.Bunch (eg.globals) was easy to do this with because all that was coded in was it updating __dict__. so for me to move everything to a new class that had all the monitoring code in place was easy.
Wait...what? That's some kind of voodoo magic you're doing there. Everyone needs to make it that easy.kgschlosser wrote:.egplugin
just double click the file and away it goes. no need to restart eg. it will make the folders and files and install the plugin where it needs to be.
it will place the plugin into the c:\programdata\eventghost\plugins folder. not in the install directory folder

- kgschlosser
- Site Admin
- Posts: 5021
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Update Namespace unavailable in PyCrust
yep voodoo.. it worked so well it crashed EG
LOL
i will see if it does the same on my end. it might. who knows.
LOL
i will see if it does the same on my end. it might. who knows.
- kgschlosser
- Site Admin
- Posts: 5021
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Update Namespace unavailable in PyCrust
now it installed correctly. you just can't add it????
- kgschlosser
- Site Admin
- Posts: 5021
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Update Namespace unavailable in PyCrust
it installed and added properly on mine. what version of EG are you running????
***edit***
Never mind.
it works with .5 but not .4 and it is not throwing any errors either. and i really can't think of anything that has changed in how a plugin loads or possibly how the config dialog loads that would crash it..
but at any rate. it works with EG .5 beta 4.
***edit***
Never mind.
it works with .5 but not .4 and it is not throwing any errors either. and i really can't think of anything that has changed in how a plugin loads or possibly how the config dialog loads that would crash it..
but at any rate. it works with EG .5 beta 4.
- kgschlosser
- Site Admin
- Posts: 5021
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Update Namespace unavailable in PyCrust
ok i have it sorted. it now runs in EG .4 and eg .5 still the original 2 problems. the menu click thing i am not concerned about. the issue with the nested globals is annoying.
what a pain it was getting this thing to play nice nice with the 2 different versions of eg. the biggest issue was getting it to close properly without hanging. and because the wx versions were different that produced it's own complications.
and just when i thought i get it all done. pow! the menu's don't work. oye!
everything but the double right click and it now showing nested variables. the only 2 issues i could find. there are probably more i am sure. but i didn't stumble across them
here it is tho
what a pain it was getting this thing to play nice nice with the 2 different versions of eg. the biggest issue was getting it to close properly without hanging. and because the wx versions were different that produced it's own complications.
and just when i thought i get it all done. pow! the menu's don't work. oye!
everything but the double right click and it now showing nested variables. the only 2 issues i could find. there are probably more i am sure. but i didn't stumble across them
here it is tho
Re: Update Namespace unavailable in PyCrust
Hmmm. Well, the prior error is resolved, but there is no longer the option to add actions to the configuration tree when adding the plug-in. There also doesn't appear to be any option to add actions manually; nothing shows up in the list of choices:

EG also hangs when trying to exit if the GlobalMonitor plugin is loaded. Isn't it axiomatic in programming that if you think something is going to be easy, well...maybe not. 
- kgschlosser
- Site Admin
- Posts: 5021
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Update Namespace unavailable in PyCrust
open yer eyeballs f00
just because it's a plugin doesn't mean it has to have any actions to do something.
all the fun stuff is in the menus. but it's just like using eg.globals as usual. just some niceties and convenience things added
and the hanging on close.. if you could do me a favor and run EG from a command line with -debug after it..
then close EG
and navigate to you Users\SOMEUSER\appdata\roaming\eventghost folder and attach the log.txt to a forum post. or send it to me in a pm if you think it may have personal stuff in it (it shouldn't but who knows)
just because it's a plugin doesn't mean it has to have any actions to do something.
all the fun stuff is in the menus. but it's just like using eg.globals as usual. just some niceties and convenience things added
and the hanging on close.. if you could do me a favor and run EG from a command line with -debug after it..
then close EG
and navigate to you Users\SOMEUSER\appdata\roaming\eventghost folder and attach the log.txt to a forum post. or send it to me in a pm if you think it may have personal stuff in it (it shouldn't but who knows)