SABnzbd-Suite: update addon version, remove trailing whitespaces

Signed-off-by: Stephan Raue <stephan@openelec.tv>
This commit is contained in:
Stephan Raue 2012-04-10 14:09:10 +02:00
parent 7696d7c099
commit 4fb33be0f7
4 changed files with 41 additions and 78 deletions

View File

@ -1,3 +1,6 @@
2.1.2
- improve startup script
2.1.1
- update to addon version 2.1
- update to SABnzbd-0.6.15

View File

@ -20,7 +20,7 @@
PKG_NAME="SABnzbd-Suite"
PKG_VERSION="2.1"
PKG_REV="1"
PKG_REV="2"
PKG_ARCH="any"
PKG_LICENSE="OSS"
PKG_SITE="http://www.openelec.tv"

View File

@ -1,23 +1,22 @@
################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2012 Lukas Heiniger
#
# This Program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This Program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenELEC.tv; see the file COPYING. If not, write to
# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
# http://www.gnu.org/copyleft/gpl.html
################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2012 Lukas Heiniger
#
# This Program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version
#
# This Program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenELEC.tv; see the file COPYING. If not, write to
# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
# http://www.gnu.org/copyleft/gpl.html
################################################################################
# Initializes and launches SABnzbd, Couchpotato, Sickbeard and Headphones
@ -33,24 +32,21 @@ import logging
logging.basicConfig(filename='/var/log/sabnzbd-suite.log',
filemode='w',
format='%(asctime)s SABnzbd-Suite: %(message)s',
format='%(asctime)s SABnzbd-Suite: %(message)s',
level=logging.WARNING)
# helper functions
# ----------------
def createDir(dir):
if not os.path.isdir(dir):
os.makedirs(dir)
def getAddonSetting(doc,id):
for element in doc.getElementsByTagName('setting'):
if element.getAttribute('id')==id:
return element.getAttribute('value')
def loadWebInterface(url,user,pwd):
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, url, user, pwd)
@ -59,9 +55,6 @@ def loadWebInterface(url,user,pwd):
urllib2.install_opener(opener)
pagehandle = urllib2.urlopen(url)
return pagehandle.read()
# define some things that we're gonna need, mainly paths
# ------------------------------------------------------
@ -87,27 +80,23 @@ pSabNzbdIncomplete = '/storage/downloads/incomplete'
pSickBeardTvScripts = os.path.join(pAddon, 'SickBeard/autoProcessTV')
pSabNzbdScripts = os.path.join(pAddonHome, 'scripts')
# pylib
pPylib = os.path.join(pAddon, 'pylib')
# service commands
sabnzbd = ['python', os.path.join(pAddon, 'SABnzbd/SABnzbd.py'),
sabnzbd = ['python', os.path.join(pAddon, 'SABnzbd/SABnzbd.py'),
'-d', '-f', pSabNzbdSettings, '-l 0']
sickBeard = ['python', os.path.join(pAddon, 'SickBeard/SickBeard.py'),
sickBeard = ['python', os.path.join(pAddon, 'SickBeard/SickBeard.py'),
'--daemon', '--datadir', pAddonHome]
couchPotato = ['python', os.path.join(pAddon, 'CouchPotato/CouchPotato.py'),
couchPotato = ['python', os.path.join(pAddon, 'CouchPotato/CouchPotato.py'),
'-d', '--datadir', pAddonHome, '--config', pCouchPotatoSettings]
headphones = ['python', os.path.join(pAddon, 'Headphones/Headphones.py'),
headphones = ['python', os.path.join(pAddon, 'Headphones/Headphones.py'),
'-d', '--datadir', pAddonHome, '--config', pHeadphonesSettings]
# Other stuff
sabNzbdHost = '127.0.0.1:8081'
addonId = 'service.downloadmanager.SABnzbd-Suite'
# create directories and settings on first launch
# -----------------------------------------------
@ -130,9 +119,6 @@ if firstLaunch:
for utility in {'par2','unrar','unzip'}:
os.chmod(os.path.join(pAddon, 'bin', utility), 0755)
# read addon and xbmc settings
# ----------------------------
@ -162,17 +148,12 @@ try:
except:
xbmcPwd = ''
# prepare execution environment
# -----------------------------
signal.signal(signal.SIGCHLD, signal.SIG_DFL)
os.environ['PYTHONPATH'] = str(os.environ.get('PYTHONPATH')) + ':' + pPylib
# write SABnzbd settings
# ----------------------
@ -207,7 +188,7 @@ if firstLaunch:
servers['localhost']['port'] = '119'
servers['localhost']['enable'] = '0'
categories = {}
categories['tv'] = {}
categories['tv'] = {}
categories['tv']['name'] = 'tv'
categories['tv']['script'] = 'sabToSickBeard.py'
categories['tv']['priority'] = '-100'
@ -221,7 +202,7 @@ if firstLaunch:
categories['music']['priority'] = '-100'
defaultConfig['servers'] = servers
defaultConfig['categories'] = categories
sabNzbdConfig.merge(defaultConfig)
sabNzbdConfig.write()
@ -236,9 +217,6 @@ defaultConfig['SickBeard']['password'] = pwd
autoProcessConfig.merge(defaultConfig)
autoProcessConfig.write()
# launch SABnzbd and get the API key
# ----------------------------------
@ -253,9 +231,6 @@ sabNzbdConfig.reload()
sabNzbdApiKey = sabNzbdConfig['misc']['api_key']
logging.debug('SABnzbd api key: ' + sabNzbdApiKey)
# write SickBeard settings
# ------------------------
@ -297,22 +272,16 @@ if firstLaunch:
defaultConfig['SABnzbd']['sab_host'] = sabNzbdHost
defaultConfig['XBMC']['xbmc_notify_ondownload'] = '1'
defaultConfig['XBMC']['xbmc_update_library'] = '1'
sickBeardConfig.merge(defaultConfig)
sickBeardConfig.write()
# launch SickBeard
# ----------------
logging.debug('Launching SickBeard...')
subprocess.call(sickBeard)
logging.debug('...done')
# write CouchPotato settings
# --------------------------
@ -345,13 +314,10 @@ if firstLaunch:
defaultConfig['Renamer']['destination'] = '/storage/videos'
defaultConfig['Renamer']['separator'] = '.'
defaultConfig['Renamer']['cleanup'] = 'True'
couchPotatoConfig.merge(defaultConfig)
couchPotatoConfig.write()
# launch CouchPotato
# ------------------
@ -359,9 +325,6 @@ logging.debug('Launching CouchPotato...')
subprocess.call(couchPotato)
logging.debug('...done')
# write Headphones settings
# -------------------------
@ -383,16 +346,13 @@ if firstLaunch:
defaultConfig['SABnzbd']['sab_category'] = 'music'
defaultConfig['General']['music_dir'] = '/storage/music'
defaultConfig['General']['destination_dir'] = '/storage/music'
defaultConfig['General']['download_dir'] = '/storage/downloads/music'
defaultConfig['General']['move_files'] = '1'
defaultConfig['General']['download_dir'] = '/storage/downloads/music'
defaultConfig['General']['move_files'] = '1'
defaultConfig['General']['rename_files'] = '1'
headphonesConfig.merge(defaultConfig)
headphonesConfig.write()
# launch Headphones
# -----------------

View File

@ -60,10 +60,10 @@ if shouldKeepAwake:
xbmc.log('SABnzbd-Suite: will prevent idle sleep/shutdown while downloading')
while (not xbmc.abortRequested):
# reread setting in case it has changed
shouldKeepAwake = __settings__.getSetting('SABNZBD_KEEP_AWAKE')
# check if SABnzbd is downloading
sabIsActive = False
req = urllib2.Request(sabNzbdQueue)
@ -74,16 +74,16 @@ while (not xbmc.abortRequested):
queue = handle.read()
handle.close()
sabIsActive = (queue.find('<status>Downloading</status>') >= 0)
# reset idle timer when we're close to idle sleep/shutdown
if (shouldKeepAwake and sabIsActive):
response = xbmc.executehttpapi("GetGUISetting(0;powermanagement.shutdowntime)").replace('<li>','')
shutdownTime = int(response) * 60
idleTime = xbmc.getGlobalIdleTime()
timeToShutdown = shutdownTime - idleTime
if (sabIsActive and timeToShutdown <= checkInterval - timeout):
xbmc.log('SABnzbd-Suite: still downloading. Resetting XBMC idle timer.')
xbmc.executehttpapi("SendKey(0xF000)")
xbmc.sleep(checkInterval * 1000)