Can anyone tell me why this doesn't work?
f = open("E:\eventghost web server\test.txt")
data = f.read
if data=="622":
eg.TriggerEvent("HTTP.onkyo.receiver.zone2.poweroff");
if data=="922":
eg.TriggerEvent("HTTP.onkyo.receiver.zone2.poweron");
f.close()
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.
python newb here
-
scottbakertemp
- Posts: 17
- Joined: Sun Nov 28, 2010 7:21 pm
Re: python newb here
this is the error message I get:
Traceback (most recent call last):
Python script "2", line 1, in <module>
f = open("E:\eventghost web server\test.txt")
IOError: [Errno 22] invalid mode ('r') or filename: 'E:\\eventghost web server\test.txt'
Traceback (most recent call last):
Python script "2", line 1, in <module>
f = open("E:\eventghost web server\test.txt")
IOError: [Errno 22] invalid mode ('r') or filename: 'E:\\eventghost web server\test.txt'
Re: python newb here
Try this:
jonib
Code: Select all
f = open("E:\\eventghost web server\\test.txt")-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: python newb here
Unless you are 100% sure that the data content is exactly the string you write (no white space or hidden chars), I would do like this
Code: Select all
f = open("E:\\eventghost web server\\test.txt")
data = f.read
if data.find("622") != -1:
eg.TriggerEvent("HTTP.onkyo.receiver.zone2.poweroff");
if data.find("922") != -1:
eg.TriggerEvent("HTTP.onkyo.receiver.zone2.poweron");
f.close()
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
-
scottbakertemp
- Posts: 17
- Joined: Sun Nov 28, 2010 7:21 pm
Re: python newb here
it gave me an error saying: if data.find("622") != -1:
9:06:59 AM AttributeError: 'builtin_function_or_method' object has no attribute 'find'
I noticed in the latest version of event ghost I can put a query registry action followed by a jump to (if last action was successful) action. I can then add that 2 action combination in the same macro to effectively create an if-then-elseif-statement.
This program is REALLY powerful.
9:06:59 AM AttributeError: 'builtin_function_or_method' object has no attribute 'find'
I noticed in the latest version of event ghost I can put a query registry action followed by a jump to (if last action was successful) action. I can then add that 2 action combination in the same macro to effectively create an if-then-elseif-statement.
This program is REALLY powerful.
-
krambriw
- Plugin Developer
- Posts: 2570
- Joined: Sat Jun 30, 2007 2:51 pm
- Location: Stockholm, Sweden
- Contact:
Re: python newb here
Yes, there was one more error in the code:
should be
Code: Select all
data = f.read
Code: Select all
data = f.read()
My released plugins
https://drive.google.com/drive/folders/ ... y01eVBKeHM
https://drive.google.com/drive/folders/ ... y01eVBKeHM
