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.
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.
Anyone use Webserver extensively?
Anyone use Webserver extensively?
I'm hoping someone has some pretty extensive example code I can use as an example.
Ideally, the plug-in would allow some autogenerated code based on devices... not sure if this is possible. Girder does this and it is very cool!
Ideally, the plug-in would allow some autogenerated code based on devices... not sure if this is possible. Girder does this and it is very cool!
setup... XBMC, W7MC for DVR & Live OTA TV, JRMC for multi-zone audio, EG, MiCasaVerde Vera3, USB-UIRT IR receiver, Harmony remote, 5.2 home theater system
Re: Anyone use Webserver extensively?
What, specifically, did you have in mind?
I don't know what all EG's web server is capable of; I haven't researched it enough to even know if it's capable of being scripted, but you can certainly build ASP pages and just direct links to trigger EG's web server.... and since ASP uses VBScript or JavaScript, you can do a lot there.
I don't know what all EG's web server is capable of; I haven't researched it enough to even know if it's capable of being scripted, but you can certainly build ASP pages and just direct links to trigger EG's web server.... and since ASP uses VBScript or JavaScript, you can do a lot there.
Re: Anyone use Webserver extensively?
It would be ideal to have the ability for the web server to auto-generate "objects" to be displayed on the web page for items such as Receivers, lights, keyboard keys, etc -- thus the user could decide which would get displayed on the web pages and which are hidden (maybe using a simple property on the EG item).
setup... XBMC, W7MC for DVR & Live OTA TV, JRMC for multi-zone audio, EG, MiCasaVerde Vera3, USB-UIRT IR receiver, Harmony remote, 5.2 home theater system
Re: Anyone use Webserver extensively?
How would you choose how these items are selected? I'm still trying to figure out precisely what you mean.
-
holyspidoo
- Posts: 14
- Joined: Wed Apr 08, 2009 5:18 pm
Re: Anyone use Webserver extensively?
Do you mean like: If application X is running, then items Y and Z are shown on the web page?
Personnally, that's what I'd like to do. Like if you have a PLAY feature on your webpage, it only appears when the player is running on the PC (or even just some status indicator that an application is running).
Personnally, that's what I'd like to do. Like if you have a PLAY feature on your webpage, it only appears when the player is running on the PC (or even just some status indicator that an application is running).
Re: Anyone use Webserver extensively?
Okay, I gotcha.
You can do all of that with ASP; I can think of several ways to accomplish that.
In any event, you'd use XP's (or Windows Server) built in web server, and the action links (Play, pause, etc) would either link to EG's own web server or would be activated by COM. In fact, with COM and ASP, you don't even need the EG web server.
You can do all of that with ASP; I can think of several ways to accomplish that.
In any event, you'd use XP's (or Windows Server) built in web server, and the action links (Play, pause, etc) would either link to EG's own web server or would be activated by COM. In fact, with COM and ASP, you don't even need the EG web server.
Re: Anyone use Webserver extensively?
If you are going to run a separate webserver I'd recommend apache with a scripting language like php, perl, jsp or something else.. No offense to TomXP411 but In my opinion Microsoft's IIS is a pile of steaming s*** not to mention what I think of ASP..
But really the best option would be to have the internal EG webserver scriptable with python (or perhaps something else like php through a plugin?). I havn't looked into how much work this would mean but I'm thinking it should be doable, don't hold your breath on it though.
But really the best option would be to have the internal EG webserver scriptable with python (or perhaps something else like php through a plugin?). I havn't looked into how much work this would mean but I'm thinking it should be doable, don't hold your breath on it though.
Re: Anyone use Webserver extensively?
I won't get in to a web server debate; there's no point. I will say that if it were a steaming pile, the company I work for wouldn't be using it exclusively in a mutli-billion dollar application that's used by law enforcement, EMS, and government agencies all over the country.
If you know ASP or ASP.Net, it's fairly simple to integrate with EventGhost. Every Windows system out there has IIS built in, so turning it on is as simple as clicking a checkbox.
If you know ASP or ASP.Net, it's fairly simple to integrate with EventGhost. Every Windows system out there has IIS built in, so turning it on is as simple as clicking a checkbox.
Re: Anyone use Webserver extensively?
Yes, that's exactly the only circumstance it gets used in. Somebody makes or has made 10 years ago the executive decision to use IIS and other microsoft systems in a corporate or government environment. I have some experience in this with a medical company and I never ever want to even see IIS again.
That's my 5 cents on it anyhow.
That's my 5 cents on it anyhow.
Re: Anyone use Webserver extensively?
So back to the original question.
Is it possible to create a web page that actually interacts with EG, tracking the state of active applications, and using that to dynamically build the appropriate menus on demand?
Yes, it can be done very easily.
Perhaps the simplest method that requires the least coding would be to use the File Output plugin in EG coupled with task change events. I already use task change events to switch keymaps; it would be trivial to add a step in each event that writes out a short data file that lets the web server pick which page or menu item would be visible. Your master web page then reads that file and uses it to determine which set of controls gets loaded when the page is refreshed.
This method is pretty simple, and it can be applied to any web server, so you could just as easily use it on Apache running PHP. It's just a matter of being able to access a file that both EventGhost and the web server can read and write.
Re: Anyone use Webserver extensively?
I've been doing this for a while with my own changes to the Webserver plugin. The primary thing that I've done is to have it parse the page and run any python code it happens to see. Now bear in mind that for an external webserver, this is an EXTREMELY BAD IDEA. There are all kinds of injection exploits and disasters you are asking for by doing this. As a matter of fact, if you make these changes and then face it towards the internet rather than your own personal network, you will almost certainly get hacked or compromised and Eventghost is a very powerful thing for a bad person to have control over.
I use it exclusively on my internal network and it works great though. There are two changes you'll need to make. One goes to the webserver plug-in. The other is a change to the core eventghost processing. If you check the "bug fix" thread, I proposed the second change but was denied. =) I'm sure there's a better way to do it, but for my own purposes, this gets the job done.
An example of how I use these changes: My Vista Media Center plugin returns information about the current track that's playing. I update some global variables with this information. Then I use a webpage to display them, and some simple AJAX to update the page. There are controls on the page that fast forward, rewind, stop, power on my HK receiver (with my HK plugin), control the lights with my Insteon ISY-26 plugin, etc. You get the idea.
Step 1: Make these changes to the Webserver plugin. Find the lines with "# Main Handler" and replace down to "payload=None" with this part. It will read the HTML file from the disk and then parse it looking for python before transmitting:
Step 2: You'll need to change the core ParseString procedure for Eventghost. This is in c:\program files\EventGhost\eg\utils.py. Search down and find the line "def ParseString(text, filterFunc=None):". We're going to change it so that the ParseString fails silently and returns the unexecuted text when the Python interpreter errors out. If you don't make this change, Eventghost throws an exception when it hits code (such as javascript) that it doesn't understand, but still uses curly brackets.
Step 3: In your eventghost configuration, create a python command or other macro that generates a global variable.
Step 4: Create a Web page like this:
Now this is far from perfect. Because there's tons of overlap between javascript and python in terms of syntax, it's better to keep it in .JS files, otherwise the whole thing gets kicked out and your macros don't get run.
A much more elegant solution would be to look for some more unique indicator such as "{{" and parse for different sections of python code. But since this works for me, it's as far as I've gone with it. As I have to deal with more problems, maybe I'll write a more thorough solution.
Again, this is all at-your-own-risk code. It works fine for me. It doesn't seem to break anything. I understand the risks of executing arbitrary code through my webserver and prevent external access. If it works for you too, awesome.
~K
I use it exclusively on my internal network and it works great though. There are two changes you'll need to make. One goes to the webserver plug-in. The other is a change to the core eventghost processing. If you check the "bug fix" thread, I proposed the second change but was denied. =) I'm sure there's a better way to do it, but for my own purposes, this gets the job done.
An example of how I use these changes: My Vista Media Center plugin returns information about the current track that's playing. I update some global variables with this information. Then I use a webpage to display them, and some simple AJAX to update the page. There are controls on the page that fast forward, rewind, stop, power on my HK receiver (with my HK plugin), control the lights with my Insteon ISY-26 plugin, etc. You get the idea.
Step 1: Make these changes to the Webserver plugin. Find the lines with "# Main Handler" and replace down to "payload=None" with this part. It will read the HTML file from the disk and then parse it looking for python before transmitting:
Code: Select all
# Main Handler
f = None
try:
p = self.path.split('?', 1)
self.path = p[0]
f = self.send_head()
if not f:
return
tempwpage=f.read()
if (f.mode=="r"):
tempwpage=eg.ParseString(tempwpage)
self.wfile.write(tempwpage)
# self.copyfile(f, self.wfile)
f.close()
f = None
if len(p) < 2:
return
a = p[1].split('&')
event = urllib.unquote_plus(a[0]).decode("latin1")
withoutRelease = False
payload = None
Code: Select all
def ParseString(text, filterFunc=None):
start = 0
chunks = []
last = len(text) - 1
while 1:
pos = text.find('{', start)
if pos < 0:
break
if pos == last:
break
chunks.append(text[start:pos])
if text[pos+1] == '{':
chunks.append('{')
start = pos + 2
else:
eg.PrintDebugNotice("0")
start = pos + 1
end = text.find('}', start)
if end == -1:
raise SyntaxError("unmatched bracket")
word = text[start:end]
res = None
try:
if filterFunc:
res = filterFunc(word)
if res is None:
res = eval(word, {}, eg.globals.__dict__)
except:
res = "{"+word+"}"
eg.PrintDebugNotice("1")
res=res.encode('latin-1')
chunks.append(unicode(res))
eg.PrintDebugNotice("2")
start = end + 1
chunks.append(text[start:])
return "".join(chunks)
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1484">
<Action>
EventGhost.PythonCommand(u'eg.globals.webvar="Hello World"')
</Action>
</EventGhost>
Code: Select all
<HTML><HEAD></HEAD><BODY>
Testing {eg.globals.webvar}
</BODY></HTML>
A much more elegant solution would be to look for some more unique indicator such as "{{" and parse for different sections of python code. But since this works for me, it's as far as I've gone with it. As I have to deal with more problems, maybe I'll write a more thorough solution.
Again, this is all at-your-own-risk code. It works fine for me. It doesn't seem to break anything. I understand the risks of executing arbitrary code through my webserver and prevent external access. If it works for you too, awesome.
~K