2014-01-25, 06:21
Hi everyone,
I am VERY new to python development, I have also searched the web high and low for some direction on the issue I am having. Any help or a point in the right direction is greatly appreciated.
All I am trying to do is to trigger the URL (btw, this works perfectly in any web browser) to trigger a scene using my INSTEON Hub (turn lights on when movie starts playing etc). The best I can find is I may need to add header information to the urllib2.urlopen url? Not too sure, tried everything, any help would be GREATLY appreciated. Thank you.
Python script:
This is the part I need help with (I think)...
I also tried
The error log...
I am VERY new to python development, I have also searched the web high and low for some direction on the issue I am having. Any help or a point in the right direction is greatly appreciated.
All I am trying to do is to trigger the URL (btw, this works perfectly in any web browser) to trigger a scene using my INSTEON Hub (turn lights on when movie starts playing etc). The best I can find is I may need to add header information to the urllib2.urlopen url? Not too sure, tried everything, any help would be GREATLY appreciated. Thank you.
Python script:
PHP Code:
import xbmc,xbmcgui
import subprocess,os
import urllib2
import xbmcaddon
import json
import time
#Initialize ADDON
settings = xbmcaddon.Addon(id='insteon.addon')
#Initialize ADDON INFORMATION
ip = settings.getSetting( "hub_ip" )
user = settings.getSetting( "hub_user" )
pword = settings.getSetting( "hub_pword" )
__addonname__ = settings.getAddonInfo('name')
__icon__ = settings.getAddonInfo('icon')
plugin_start = "Plugin started"
plugin_error = "Please insert your INSTEON Hub information in the addon setting"
time1 = 5000
time2 = 3000
url = 'http://admin:[email protected]:25105/0?1115=I=0'
class MyPlayer(xbmc.Player) :
def __init__ (self):
xbmc.Player.__init__(self)
def onPlayBackStarted(self):
if xbmc.Player().isPlayingVideo():
request = urllib2.urlopen('http://admin:[email protected]:25105/0?1115=I=0')
player=MyPlayer()
VIDEO = 0
while(1):
if xbmc.Player().isPlaying():
if xbmc.Player().isPlayingVideo():
VIDEO = 1
else:
VIDEO = 0
xbmc.sleep(1000)
This is the part I need help with (I think)...
PHP Code:
request = urllib2.urlopen('http://admin:[email protected]:25105/0?1115=I=0')
I also tried
PHP Code:
urllib2.urlopen('http://admin:[email protected]:25105/0?1115=I=0')
The error log...
Code:
15:14:50 T:4500549632 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <class 'urllib2.URLError'>
Error Contents: <urlopen error [Errno 8] nodename nor servname provided, or not known>
Traceback (most recent call last):
File "/Users/Brad/Library/Application Support/XBMC/addons/insteon.addon/default.py", line 33, in onPlayBackStarted
request = urllib2.urlopen(url)
File "/Applications/XBMC.app/Contents/Frameworks/lib/python2.6/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/Applications/XBMC.app/Contents/Frameworks/lib/python2.6/urllib2.py", line 391, in open
response = self._open(req, data)
File "/Applications/XBMC.app/Contents/Frameworks/lib/python2.6/urllib2.py", line 409, in _open
'_open', req)
File "/Applications/XBMC.app/Contents/Frameworks/lib/python2.6/urllib2.py", line 369, in _call_chain
result = func(*args)
File "/Applications/XBMC.app/Contents/Frameworks/lib/python2.6/urllib2.py", line 1161, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/Applications/XBMC.app/Contents/Frameworks/lib/python2.6/urllib2.py", line 1136, in do_open
raise URLError(err)
URLError: <urlopen error [Errno 8] nodename nor servname provided, or not known>
-->End of Python script error report<--