Permalink
Browse files

Merge pull request #5 from amet/master

more cosmetics
  • Loading branch information...
2 parents 1e574ff + 30e7e55 commit d56caea5be820325f1b14e07483890c660b94652 @Memphiz Memphiz committed Mar 27, 2012
Showing with 36 additions and 38 deletions.
  1. +23 −26 script.xbmc.boblight/resources/lib/boblight.py
  2. +13 −12 script.xbmc.boblight/resources/lib/settings.py
@@ -42,6 +42,7 @@
import xbmc
import sys
import os
+from tools import log
__scriptname__ = sys.modules[ "__main__" ].__scriptname__
__settings__ = sys.modules[ "__main__" ].__settings__
@@ -81,35 +82,31 @@ def bob_loadLibBoblight():
# load g_libboblight.so/dylib
try:
if xbmc.getCondVisibility('system.platform.osx'):
- libname = xbmc.translatePath( os.path.join( __cwd__, 'resources', 'lib', __libnameosx__) )
- if not os.path.exists(libname):
- ret = 1
- else:
- cdll.LoadLibrary(libname)
- g_libboblight = CDLL(libname)
+ libname = xbmc.translatePath(
+ os.path.join( __cwd__, 'resources',
+ 'lib', __libnameosx__) )
+
elif xbmc.getCondVisibility('system.platform.ios'):
- libname = xbmc.translatePath( os.path.join( __cwd__, 'resources', 'lib', __libnameios__) )
- if not os.path.exists(libname):
- ret = 1
- else:
- cdll.LoadLibrary(libname)
- g_libboblight = CDLL(libname)
+ libname = xbmc.translatePath(
+ os.path.join( __cwd__, 'resources',
+ 'lib', __libnameios__) )
+
elif xbmc.getCondVisibility('system.platform.windows'):
- libname = xbmc.translatePath( os.path.join( __cwd__, 'resources', 'lib', __libnamewin__) )
- if not os.path.exists(libname):
- ret = 1
- else:
- cdll.LoadLibrary(libname)
- g_libboblight = CDLL(libname)
+ libname = xbmc.translatePath(
+ os.path.join( __cwd__, 'resources',
+ 'lib', __libnamewin__) )
+
+ if not os.path.exists(libname):
+ ret = 1
else:
- cdll.LoadLibrary("libboblight.so")
- g_libboblight = CDLL("libboblight.so")
- g_libboblight.boblight_init.restype = c_void_p
- g_libboblight.boblight_geterror.restype = c_char_p
- g_libboblight.boblight_getlightname.restype = c_char_p
- g_libboblight.boblight_getoptiondescript.restype = c_char_p
- g_boblightLoaded = True
- g_bobHandle = c_void_p(g_libboblight.boblight_init(None))
+ cdll.LoadLibrary(libname)
+ g_libboblight = CDLL(libname)
+ g_libboblight.boblight_init.restype = c_void_p
+ g_libboblight.boblight_geterror.restype = c_char_p
+ g_libboblight.boblight_getlightname.restype = c_char_p
+ g_libboblight.boblight_getoptiondescript.restype = c_char_p
+ g_boblightLoaded = True
+ g_bobHandle = c_void_p(g_libboblight.boblight_init(None))
except:
g_boblightLoaded = False
log("boblight: Error loading " + libname + " - only demo mode.")
@@ -26,6 +26,7 @@
sys.path.append (__cwd__)
from boblight import *
+from tools import log
#general
global g_networkaccess
@@ -246,19 +247,19 @@ def settings_handleNetworkSettings():
#we need to reconnect if networkaccess bool changes
#or if network access is enabled and ip or port have changed
if g_networkaccess != networkaccess or ((g_hostip != hostip or g_hostport != hostport) and g_networkaccess) :
- print "boblight: changed networkaccess to " + str(networkaccess)
+ log("boblight: changed networkaccess to " + str(networkaccess))
g_networkaccess = networkaccess
if not networkaccess:
g_hostip = None
g_hostport = -1
else:
if g_hostip != hostip:
- print "boblight: changed hostip to " + str(hostip)
+ log("boblight: changed hostip to " + str(hostip))
g_hostip = hostip
if g_hostport != hostport:
- print "boblight: changed hostport to " + str(hostport)
+ log("boblight: changed hostport to " + str(hostport))
g_hostport = hostport
reconnect = True
return reconnect
@@ -312,37 +313,37 @@ def settings_handleGlobalSettings(category):
if g_saturation != saturation:
ret = bob_setoption("saturation " + str(saturation))
settingChanged = True
- print "boblight: changed saturation to " + str(saturation) + "(ret " + str(ret) + ")"
+ log("boblight: changed saturation to " + str(saturation) + "(ret " + str(ret) + ")")
g_saturation = saturation
if g_value != value:
ret = bob_setoption("value " + str(value))
settingChanged = True
- print "boblight: changed value to " + str(value) + "(ret " + str(ret) + ")"
+ log("boblight: changed value to " + str(value) + "(ret " + str(ret) + ")")
g_value = value
if g_speed != speed:
ret = bob_setoption("speed " + str(speed))
settingChanged = True
- print "boblight: changed speed to " + str(speed) + "(ret " + str(ret) + ")"
+ log("boblight: changed speed to " + str(speed) + "(ret " + str(ret) + ")")
g_speed = speed
if g_autospeed != autospeed:
ret = bob_setoption("autospeed " + str(autospeed))
settingChanged = True
- print "boblight: changed autospeed to " + str(autospeed) + "(ret " + str(ret) + ")"
+ log("boblight: changed autospeed to " + str(autospeed) + "(ret " + str(ret) + ")")
g_autospeed = autospeed
if g_interpolation != interpolation:
ret = bob_setoption("interpolation " + str(interpolation))
settingChanged = True
- print "boblight: changed interpolation to " + str(interpolation) + "(ret " + str(ret) + ")"
+ log("boblight: changed interpolation to " + str(interpolation) + "(ret " + str(ret) + ")")
g_interpolation = interpolation
if g_threshold != threshold:
ret = bob_setoption("threshold " + str(threshold))
settingChanged = True
- print "boblight: changed threshold to " + str(threshold) + "(ret " + str(ret) + ")"
+ log("boblight: changed threshold to " + str(threshold) + "(ret " + str(ret) + ")")
g_threshold = threshold
return settingChanged
@@ -355,7 +356,7 @@ def settings_handleCategory(category):
if g_category != category:
categoryChanged = True #don't change notify when category changes
- print "boblight: use settings for " + category
+ log("boblight: use settings for " + category)
g_category = category
return categoryChanged
@@ -370,9 +371,9 @@ def settings_handleDisableSetting():
if bobdisable:
text = __settings__.getLocalizedString(503)
xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" % (__scriptname__,text,10,__icon__))
- print "boblight: boblight disabled"
+ log("boblight: boblight disabled")
else:
- print "boblight: boblight enabled"
+ log("boblight: boblight enabled")
g_bobdisable = bobdisable
#handles all settings of boblight and applies them as needed

0 comments on commit d56caea

Please sign in to comment.