Skip to content

Commit

Permalink
Future upgrades should no longer require a restart (service is hot-de…
Browse files Browse the repository at this point in the history
…ployed)
  • Loading branch information
killdash9 committed Aug 21, 2012
1 parent 22a379c commit 8d22c46
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 49 deletions.
2 changes: 1 addition & 1 deletion addons.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addons>
<addon id="script.video.parentalcontrols" name="Parental Controls" version="1.5.0" provider-name="killdash9">
<addon id="script.video.parentalcontrols" name="Parental Controls" version="1.5.2" provider-name="killdash9">
<requires>
<import addon="xbmc.python" version="2.0"/>
</requires>
Expand Down
2 changes: 1 addition & 1 deletion addons.xml.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c73624bb30c532990425605e07622323
741a087c59e1ba8dd0f16efbc4d6a347
6 changes: 5 additions & 1 deletion deploy-local.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
mkdir "$HOME/Library/Application Support/XBMC/addons/script.video.parentalcontrols"
cp -Rv script.video.parentalcontrols/* "$HOME/Library/Application Support/XBMC/addons/script.video.parentalcontrols"
while true
do
cp -R script.video.parentalcontrols/* "$HOME/Library/Application Support/XBMC/addons/script.video.parentalcontrols"
sleep 1
done
Binary file not shown.
2 changes: 1 addition & 1 deletion script.video.parentalcontrols/addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.video.parentalcontrols" name="Parental Controls" version="1.5.0" provider-name="killdash9">
<addon id="script.video.parentalcontrols" name="Parental Controls" version="1.5.2" provider-name="killdash9">
<requires>
<import addon="xbmc.python" version="2.0"/>
</requires>
Expand Down
6 changes: 5 additions & 1 deletion script.video.parentalcontrols/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
1.5.2
Future upgrades should no longer require a restart (service is hot-deployed)
Bug fixes

1.5.0
Better search integration
Adult addons are blocked at the top level
xbmc-adult addons are blocked at the top level
Bug fixes

1.4.11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re
import os
import xbmcaddon
import traceback

__addon__ = xbmcaddon.Addon()
__addonpath__ = __addon__.getAddonInfo('path')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,29 @@
import time
import common
import hook
import traceback
import xbmcgui
import xbmcaddon
import os
import xbmc

def checkProtection():
plugins = common.getProtectedPlugins()
for plugin in plugins:
state = hook.getPluginHookState(plugin)
if (not state['hooked']) or not (state['uptodate']):
p=hook.hookPlugin(plugin)
common.msg("Re-protecting plugin " + p['name'])

def closeProgressDialogIfInterfering():
pythonWindow = None
pythonWindowId=13000
try:
pythonWindow=xbmcgui.Window(pythonWindowId)
except:
pass
#window not found
if pythonWindow:
xmlfile = pythonWindow.getProperty('xmlfile')
codeDialogIsUp = xmlfile and xmlfile.find('DialogCode.xml')>=0
if codeDialogIsUp:
#close any other open dialogs so they don't interfere
common.closeProgressDialogIfOpen()
import common
import serviceiter

__addonpath__ = xbmcaddon.Addon().getAddonInfo('path')

common.msg("Started")
lastMessage = time.time()
counter=0
while (not xbmc.abortRequested):
try:
counter = counter+1
if counter % 20 == 0:
checkProtection()
common.getXbmcAdultIds() #keep the cache up to date
closeProgressDialogIfInterfering()

files = os.listdir(__addonpath__ + "/resources/lib/parentalcontrols")
for file in files:
if file.endswith(".py") and file != "service.py" and file != "settings.py":
module=file[:-3]
#reimport the module
try:
reload(eval(module))
except NameError:
exec("import " + module)
serviceiter.iterate()
except:
traceback.print_exc()
if (time.time() - lastMessage > 5*60): #we don't want to be too annoying with errors
common.msg("Error checking plugin protection status")
lastMessage = time.time()
time.sleep(.5)
time.sleep(10)

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import time
import xbmcgui
import xbmcaddon
import xbmc
import inspect

import common
import hook

__addon__ = xbmcaddon.Addon()
__addonpath__ = __addon__.getAddonInfo('path')

def checkProtection():
plugins = common.getProtectedPlugins()
for plugin in plugins:
state = hook.getPluginHookState(plugin)
if (not state['hooked']) or not (state['uptodate']):
p=hook.hookPlugin(plugin)
common.msg("Re-protecting plugin " + p['name'])

def closeProgressDialogIfInterfering():
pythonWindow = None
pythonWindowId=13000
try:
pythonWindow=xbmcgui.Window(pythonWindowId)
except:
pass
#window not found
if pythonWindow:
xmlfile = pythonWindow.getProperty('xmlfile')
codeDialogIsUp = xmlfile and xmlfile.find('DialogCode.xml')>=0
if codeDialogIsUp:
#close any other open dialogs so they don't interfere
common.closeProgressDialogIfOpen()


def iterate():
counter=0
while (not xbmc.abortRequested and counter < 20):
if counter % 20 == 0:
checkProtection()
common.getXbmcAdultIds() #keep the cache up to date
closeProgressDialogIfInterfering()
time.sleep(.5)
counter = counter+1

Original file line number Diff line number Diff line change
Expand Up @@ -208,20 +208,22 @@ def wrapper_import(*args,**kwargs):

#Determines whether to wrap the plugin. Also shows unlock dialog
def check():

unlockWindow = 5*60
if time.time() - getUnlockedTime() < unlockWindow:
return #early return, we're in unlock window so we don't wrap

# see if we're an adult plugin
showUnlockDialog = thisAddonId in common.getXbmcAdultIds()

showUnlockDialog = False

# see if our marker is present
match=re.search(overridemarkerPattern, sys.argv[2] if len(sys.argv) > 2 else None)
if match:
sys.argv[2] = re.sub(overridemarkerPattern,'',sys.argv[2]) #strip marker
showUnlockDialog=True

unlockWindow = 5*60
if time.time() - getUnlockedTime() < unlockWindow:
return #early return, we're in unlock window so we don't wrap

# see if we're an adult plugin
showUnlockDialog = showUnlockDialog or thisAddonId in common.getXbmcAdultIds()

if showUnlockDialog:
if codeui.unlockUI():
setUnlockedTime(int(time.time()))
Expand Down
2 changes: 1 addition & 1 deletion zip-plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ zip -r $FILENAME script.video.parentalcontrols/
git add $FILENAME
python addons_xml_generator.py
git status
echo "Don't forget to commit and push"
echo "Don't forget to add, commit and push"

0 comments on commit 8d22c46

Please sign in to comment.