First I want to say a huge thank you to the author of this software and all of you who have contributed with tips and plugins which really helps newbs like me to get up to speed pretty quickly!
Now for the question. I'm trying to control my wireless IP camera from eventghost but so far I am running into a ton of trouble trying to use the urlopen methods in a python script. For some reason when I try to execute the following code to make an HTTP reguest with the encoded url that I got from the camera's API I get errors. This is the format of the camera's encoded URL, (http://IP:PORT/decoder_control.cgi?command=33&onestep=&user=NAMEOFUSER&pwd=SECRETPASSWORD) This works fine in any browser and returns an "ok" message which I have no use for and then promptly moves the camera to the desired preset view. The trouble is that this url is not working in my Python script nor my Powershell script.
:::Python Script:::
import urllib
urllib.urlopen('http://IP:PORT/decoder_control.cgi?command=33&onestep=&user=NAMEOFUSER&pwd=SECRETPASSWORD')
:::END Python Script:::
This is the error I am getting back.
:::Errors that appear in Eventghost log:::
15:43:13 Traceback (most recent call last):
15:43:13 Python script "2", line 2, in <module>
15:43:13 urllib.urlopen('http://IP:PORT/decoder_control.cgi?command=33&onestep=&user=NAMEOFUSER&pwd=SECRETPASSWORD')
15:43:13 File "urllib.pyc", line 86, in urlopen
15:43:13 File "urllib.pyc", line 205, in open
15:43:13 File "urllib.pyc", line 360, in open_http
15:43:13 File "urllib.pyc", line 373, in http_error
15:43:13 File "urllib.pyc", line 688, in http_error_401
15:43:13 File "urllib.pyc", line 752, in retry_http_basic_auth
15:43:13 File "urllib.pyc", line 781, in get_user_passwd
15:43:13 File "urllib.pyc", line 792, in prompt_user_passwd
15:43:13 File "getpass.pyc", line 95, in win_getpass
15:43:13 TypeError: putch() argument 1 must be char, not unicode
:::End Error Log:::
I am on a Windows 7 64 bit computer and i am running Version 0.4.1.r1710.
Not being one to give up easily I have also tried
:::Python Script:::
import urllib2
urllib2.urlopen('http://IP:PORT/decoder_control.cgi?command=33&onestep=&user=NAMEOFUSER&pwd=SECRETPASSWORD')
:::END Python Script:::
I then decided to see if I could force this to happen with a powershell script.
:::Powershell Script:::
$IE=new-object -com internetexplorer.application
$IE.navigate2("http://IP:PORT/decoder_control.cgi?command=33&onestep=&user=NAMEOFUSER&pwd=SECRETPASSWORD")
$IE.visible=$false
Start-Sleep -s 10
Clear-Host
Get-Process iexplore | Stop-Process
:::End Powershell Script:::
Keep that script for your records by the way if you're learning powershell like I am! It's a really great way to run a program hidden. The only problem is that this method pops up an ugly Windows Security Window where I am forced to click ok to continue. I tried doing this with wshell within the script but it was messy and failed horribly...
Another issue with the powershell script is that I had to use the direct path to powershell.exe in my system directory and then put my script as a commandline parameter when I tried to run it as an application in eventghost. An extra step, but not the end of the world. Sadly when I tried to execute the powershell script in this way nothing happens. No error messages appear in the log of eventghost either so I'm not quite sure what's going on there.
Did I say this has been almost a 2 week journey? Lol. Anyways. If any of you could possibly point me in the right direction I would be forever grateful. I have a feeling that I am not writing my python code correctly but in addition to this there seems to be an additional login window that is asking for the user name in eventghost everytime I attempt to use the python method which I am confused about since the login information is already hard coded in the URL. Any ideas?