SABnzbd-Suite: rework: a failed part of suite should NEVER block another part.

This commit is contained in:
Stefan Saraev 2012-06-21 12:36:06 +03:00
parent 8dfbdba67b
commit ba695d3da3

View File

@ -182,32 +182,33 @@ except:
signal.signal(signal.SIGCHLD, signal.SIG_DFL) signal.signal(signal.SIGCHLD, signal.SIG_DFL)
os.environ['PYTHONPATH'] = str(os.environ.get('PYTHONPATH')) + ':' + pPylib os.environ['PYTHONPATH'] = str(os.environ.get('PYTHONPATH')) + ':' + pPylib
# write SABnzbd settings # SABnzbd start
# ---------------------- try:
# write SABnzbd settings
# ----------------------
sabNzbdConfig = ConfigObj(pSabNzbdSettings,create_empty=True)
defaultConfig = ConfigObj()
defaultConfig['misc'] = {}
defaultConfig['misc']['disable_api_key'] = '0'
defaultConfig['misc']['check_new_rel'] = '0'
defaultConfig['misc']['auto_browser'] = '0'
defaultConfig['misc']['username'] = user
defaultConfig['misc']['password'] = pwd
defaultConfig['misc']['port'] = '8081'
defaultConfig['misc']['https_port'] = '9081'
defaultConfig['misc']['https_cert'] = 'server.cert'
defaultConfig['misc']['https_key'] = 'server.key'
defaultConfig['misc']['host'] = host
defaultConfig['misc']['web_dir'] = 'Plush'
defaultConfig['misc']['web_dir2'] = 'Plush'
defaultConfig['misc']['web_color'] = 'gold'
defaultConfig['misc']['web_color2'] = 'gold'
defaultConfig['misc']['log_dir'] = 'logs'
defaultConfig['misc']['admin_dir'] = 'admin'
defaultConfig['misc']['nzb_backup_dir'] = 'backup'
defaultConfig['misc']['script_dir'] = 'scripts'
sabNzbdConfig = ConfigObj(pSabNzbdSettings,create_empty=True) if firstLaunch:
defaultConfig = ConfigObj()
defaultConfig['misc'] = {}
defaultConfig['misc']['disable_api_key'] = '0'
defaultConfig['misc']['check_new_rel'] = '0'
defaultConfig['misc']['auto_browser'] = '0'
defaultConfig['misc']['username'] = user
defaultConfig['misc']['password'] = pwd
defaultConfig['misc']['port'] = '8081'
defaultConfig['misc']['https_port'] = '9081'
defaultConfig['misc']['https_cert'] = 'server.cert'
defaultConfig['misc']['https_key'] = 'server.key'
defaultConfig['misc']['host'] = host
defaultConfig['misc']['web_dir'] = 'Plush'
defaultConfig['misc']['web_dir2'] = 'Plush'
defaultConfig['misc']['web_color'] = 'gold'
defaultConfig['misc']['web_color2'] = 'gold'
defaultConfig['misc']['log_dir'] = 'logs'
defaultConfig['misc']['admin_dir'] = 'admin'
defaultConfig['misc']['nzb_backup_dir'] = 'backup'
defaultConfig['misc']['script_dir'] = 'scripts'
if firstLaunch:
defaultConfig['misc']['download_dir'] = pSabNzbdIncomplete defaultConfig['misc']['download_dir'] = pSabNzbdIncomplete
defaultConfig['misc']['complete_dir'] = pSabNzbdComplete defaultConfig['misc']['complete_dir'] = pSabNzbdComplete
servers = {} servers = {}
@ -231,60 +232,64 @@ if firstLaunch:
defaultConfig['servers'] = servers defaultConfig['servers'] = servers
defaultConfig['categories'] = categories defaultConfig['categories'] = categories
sabNzbdConfig.merge(defaultConfig) sabNzbdConfig.merge(defaultConfig)
sabNzbdConfig.write() sabNzbdConfig.write()
# also keep the autoProcessTV config up to date # also keep the autoProcessTV config up to date
autoProcessConfig = ConfigObj(os.path.join(pSabNzbdScripts, 'autoProcessTV.cfg'), create_empty=True) autoProcessConfig = ConfigObj(os.path.join(pSabNzbdScripts, 'autoProcessTV.cfg'), create_empty=True)
defaultConfig = ConfigObj() defaultConfig = ConfigObj()
defaultConfig['SickBeard'] = {} defaultConfig['SickBeard'] = {}
defaultConfig['SickBeard']['host'] = 'localhost' defaultConfig['SickBeard']['host'] = 'localhost'
defaultConfig['SickBeard']['port'] = '8082' defaultConfig['SickBeard']['port'] = '8082'
defaultConfig['SickBeard']['username'] = user defaultConfig['SickBeard']['username'] = user
defaultConfig['SickBeard']['password'] = pwd defaultConfig['SickBeard']['password'] = pwd
autoProcessConfig.merge(defaultConfig) autoProcessConfig.merge(defaultConfig)
autoProcessConfig.write() autoProcessConfig.write()
# launch SABnzbd and get the API key # launch SABnzbd and get the API key
# ---------------------------------- # ----------------------------------
if "true" in sabnzbd_launch: if "true" in sabnzbd_launch:
logging.debug('Launching SABnzbd...') logging.debug('Launching SABnzbd...')
subprocess.call(sabnzbd,close_fds=True) subprocess.call(sabnzbd,close_fds=True)
logging.debug('...done') logging.debug('...done')
# SABnzbd will only complete the .ini file when we first access the web interface # SABnzbd will only complete the .ini file when we first access the web interface
if firstLaunch: if firstLaunch:
loadWebInterface('http://' + sabNzbdHost,user,pwd) loadWebInterface('http://' + sabNzbdHost,user,pwd)
sabNzbdConfig.reload() sabNzbdConfig.reload()
sabNzbdApiKey = sabNzbdConfig['misc']['api_key'] sabNzbdApiKey = sabNzbdConfig['misc']['api_key']
logging.debug('SABnzbd api key: ' + sabNzbdApiKey) logging.debug('SABnzbd api key: ' + sabNzbdApiKey)
except Exception,e:
print 'SABnzbd: exception occurred:', e
# SABnzbd end
# write SickBeard settings # SickBeard start
# ------------------------ try:
# write SickBeard settings
sickBeardConfig = ConfigObj(pSickBeardSettings,create_empty=True) # ------------------------
defaultConfig = ConfigObj() sickBeardConfig = ConfigObj(pSickBeardSettings,create_empty=True)
defaultConfig['General'] = {} defaultConfig = ConfigObj()
defaultConfig['General']['launch_browser'] = '0' defaultConfig['General'] = {}
defaultConfig['General']['version_notify'] = '0' defaultConfig['General']['launch_browser'] = '0'
defaultConfig['General']['log_dir'] = 'logs' defaultConfig['General']['version_notify'] = '0'
defaultConfig['General']['web_port'] = '8082' defaultConfig['General']['log_dir'] = 'logs'
defaultConfig['General']['web_host'] = host defaultConfig['General']['web_port'] = '8082'
defaultConfig['General']['web_username'] = user defaultConfig['General']['web_host'] = host
defaultConfig['General']['web_password'] = pwd defaultConfig['General']['web_username'] = user
if "true" in sabnzbd_launch: defaultConfig['General']['web_password'] = pwd
if "true" in sabnzbd_launch:
defaultConfig['SABnzbd'] = {} defaultConfig['SABnzbd'] = {}
defaultConfig['SABnzbd']['sab_username'] = user defaultConfig['SABnzbd']['sab_username'] = user
defaultConfig['SABnzbd']['sab_password'] = pwd defaultConfig['SABnzbd']['sab_password'] = pwd
defaultConfig['SABnzbd']['sab_apikey'] = sabNzbdApiKey defaultConfig['SABnzbd']['sab_apikey'] = sabNzbdApiKey
defaultConfig['SABnzbd']['sab_host'] = 'http://' + sabNzbdHost + '/' defaultConfig['SABnzbd']['sab_host'] = 'http://' + sabNzbdHost + '/'
defaultConfig['XBMC'] = {} defaultConfig['XBMC'] = {}
defaultConfig['XBMC']['use_xbmc'] = '1' defaultConfig['XBMC']['use_xbmc'] = '1'
defaultConfig['XBMC']['xbmc_host'] = '127.0.0.1:' + xbmcPort defaultConfig['XBMC']['xbmc_host'] = '127.0.0.1:' + xbmcPort
defaultConfig['XBMC']['xbmc_username'] = xbmcUser defaultConfig['XBMC']['xbmc_username'] = xbmcUser
defaultConfig['XBMC']['xbmc_password'] = xbmcPwd defaultConfig['XBMC']['xbmc_password'] = xbmcPwd
if firstLaunch: if firstLaunch:
defaultConfig['General']['metadata_xbmc'] = '1|1|1|1|1|1' defaultConfig['General']['metadata_xbmc'] = '1|1|1|1|1|1'
defaultConfig['General']['nzb_method'] = 'sabnzbd' defaultConfig['General']['nzb_method'] = 'sabnzbd'
defaultConfig['General']['keep_processed_dir'] = '0' defaultConfig['General']['keep_processed_dir'] = '0'
@ -302,41 +307,45 @@ if firstLaunch:
defaultConfig['XBMC']['xbmc_notify_ondownload'] = '1' defaultConfig['XBMC']['xbmc_notify_ondownload'] = '1'
defaultConfig['XBMC']['xbmc_update_library'] = '1' defaultConfig['XBMC']['xbmc_update_library'] = '1'
sickBeardConfig.merge(defaultConfig) sickBeardConfig.merge(defaultConfig)
sickBeardConfig.write() sickBeardConfig.write()
# launch SickBeard # launch SickBeard
# ---------------- # ----------------
if "true" in sickbeard_launch: if "true" in sickbeard_launch:
logging.debug('Launching SickBeard...') logging.debug('Launching SickBeard...')
subprocess.call(sickBeard,close_fds=True) subprocess.call(sickBeard,close_fds=True)
logging.debug('...done') logging.debug('...done')
except Exception,e:
print 'SickBeard: exception occurred:', e
# SickBeard end
# write CouchPotato settings # CouchPotato start
# -------------------------- try:
# write CouchPotato settings
couchPotatoConfig = ConfigObj(pCouchPotatoSettings,create_empty=True) # --------------------------
defaultConfig = ConfigObj() couchPotatoConfig = ConfigObj(pCouchPotatoSettings,create_empty=True)
defaultConfig['global'] = {} defaultConfig = ConfigObj()
defaultConfig['global']['launchbrowser'] = 'False' defaultConfig['global'] = {}
defaultConfig['global']['updater'] = 'False' defaultConfig['global']['launchbrowser'] = 'False'
defaultConfig['global']['password'] = pwd defaultConfig['global']['updater'] = 'False'
defaultConfig['global']['username'] = user defaultConfig['global']['password'] = pwd
defaultConfig['global']['port'] = '8083' defaultConfig['global']['username'] = user
defaultConfig['global']['host'] = host defaultConfig['global']['port'] = '8083'
if "true" in sabnzbd_launch: defaultConfig['global']['host'] = host
if "true" in sabnzbd_launch:
defaultConfig['Sabnzbd'] = {} defaultConfig['Sabnzbd'] = {}
defaultConfig['Sabnzbd']['username'] = user defaultConfig['Sabnzbd']['username'] = user
defaultConfig['Sabnzbd']['password'] = pwd defaultConfig['Sabnzbd']['password'] = pwd
defaultConfig['Sabnzbd']['apikey'] = sabNzbdApiKey defaultConfig['Sabnzbd']['apikey'] = sabNzbdApiKey
defaultConfig['Sabnzbd']['host'] = sabNzbdHost defaultConfig['Sabnzbd']['host'] = sabNzbdHost
defaultConfig['XBMC'] = {} defaultConfig['XBMC'] = {}
defaultConfig['XBMC']['enabled'] = 'True' defaultConfig['XBMC']['enabled'] = 'True'
defaultConfig['XBMC']['host'] = '127.0.0.1:' + xbmcPort defaultConfig['XBMC']['host'] = '127.0.0.1:' + xbmcPort
defaultConfig['XBMC']['username'] = xbmcUser defaultConfig['XBMC']['username'] = xbmcUser
defaultConfig['XBMC']['password'] = xbmcPwd defaultConfig['XBMC']['password'] = xbmcPwd
if firstLaunch: if firstLaunch:
defaultConfig['Sabnzbd']['category'] = 'movies' defaultConfig['Sabnzbd']['category'] = 'movies'
defaultConfig['Sabnzbd']['ppdir'] = pSabNzbdCompleteMov defaultConfig['Sabnzbd']['ppdir'] = pSabNzbdCompleteMov
defaultConfig['Renamer'] = {} defaultConfig['Renamer'] = {}
@ -346,55 +355,59 @@ if firstLaunch:
defaultConfig['Renamer']['separator'] = '.' defaultConfig['Renamer']['separator'] = '.'
defaultConfig['Renamer']['cleanup'] = 'True' defaultConfig['Renamer']['cleanup'] = 'True'
couchPotatoConfig.merge(defaultConfig) couchPotatoConfig.merge(defaultConfig)
couchPotatoConfig.write() couchPotatoConfig.write()
# launch CouchPotato # launch CouchPotato
# ------------------ # ------------------
if "true" in couchpotato_launch and "0" in couchpotato_version: if "true" in couchpotato_launch and "0" in couchpotato_version:
logging.debug('Launching CouchPotato...') logging.debug('Launching CouchPotato...')
subprocess.call(couchPotato,close_fds=True) subprocess.call(couchPotato,close_fds=True)
logging.debug('...done') logging.debug('...done')
except Exception,e:
print 'CouchPotato: exception occurred:', e
# CouchPotato end
#convert password to md5 # CouchPotatoServer start
md5pwd = hashlib.md5(pwd).hexdigest() try:
#convert password to md5
md5pwd = hashlib.md5(pwd).hexdigest()
# write CouchPotatoServer settings # write CouchPotatoServer settings
# -------------------------- # --------------------------
couchPotatoServerConfig = ConfigObj(pCouchPotatoServerSettings,create_empty=True)
couchPotatoServerConfig = ConfigObj(pCouchPotatoServerSettings,create_empty=True) defaultConfig = ConfigObj()
defaultConfig = ConfigObj() defaultConfig['newznab'] = {}
defaultConfig['newznab'] = {} defaultConfig['newznab']['api_key'] = ''
defaultConfig['newznab']['api_key'] = '' defaultConfig['core'] = {}
defaultConfig['core'] = {} defaultConfig['core']['username'] = user
defaultConfig['core']['username'] = user defaultConfig['core']['password'] = md5pwd
defaultConfig['core']['password'] = md5pwd defaultConfig['core']['port'] = '8083'
defaultConfig['core']['port'] = '8083' defaultConfig['core']['launchbrowser'] = '0'
defaultConfig['core']['launchbrowser'] = '0' defaultConfig['core']['host'] = host
defaultConfig['core']['host'] = host defaultConfig['core']['data_dir'] = pAddonHome
defaultConfig['core']['data_dir'] = pAddonHome defaultConfig['core']['permission_folder'] = '0644'
defaultConfig['core']['permission_folder'] = '0644' defaultConfig['core']['permission_file'] = '0644'
defaultConfig['core']['permission_file'] = '0644' defaultConfig['core']['show_wizard'] = '0'
defaultConfig['core']['show_wizard'] = '0' defaultConfig['core']['debug'] = '0'
defaultConfig['core']['debug'] = '0' defaultConfig['core']['development'] = '0'
defaultConfig['core']['development'] = '0' defaultConfig['updater'] = {}
defaultConfig['updater'] = {} defaultConfig['updater']['enabled'] = '0'
defaultConfig['updater']['enabled'] = '0' defaultConfig['updater']['notification'] = '0'
defaultConfig['updater']['notification'] = '0' defaultConfig['updater']['automatic'] = '0'
defaultConfig['updater']['automatic'] = '0' if "true" in sabnzbd_launch:
if "true" in sabnzbd_launch:
defaultConfig['Sabnzbd'] = {} defaultConfig['Sabnzbd'] = {}
defaultConfig['Sabnzbd']['username'] = user defaultConfig['Sabnzbd']['username'] = user
defaultConfig['Sabnzbd']['password'] = pwd defaultConfig['Sabnzbd']['password'] = pwd
defaultConfig['Sabnzbd']['api_key'] = sabNzbdApiKey defaultConfig['Sabnzbd']['api_key'] = sabNzbdApiKey
defaultConfig['Sabnzbd']['host'] = sabNzbdHost defaultConfig['Sabnzbd']['host'] = sabNzbdHost
defaultConfig['xbmc'] = {} defaultConfig['xbmc'] = {}
defaultConfig['xbmc']['enabled'] = '1' defaultConfig['xbmc']['enabled'] = '1'
defaultConfig['xbmc']['host'] = '127.0.0.1:' + xbmcPort defaultConfig['xbmc']['host'] = '127.0.0.1:' + xbmcPort
defaultConfig['xbmc']['username'] = xbmcUser defaultConfig['xbmc']['username'] = xbmcUser
defaultConfig['xbmc']['password'] = xbmcPwd defaultConfig['xbmc']['password'] = xbmcPwd
if firstLaunch: if firstLaunch:
defaultConfig['Sabnzbd']['category'] = 'movies' defaultConfig['Sabnzbd']['category'] = 'movies'
defaultConfig['Sabnzbd']['pp_directory'] = pSabNzbdCompleteMov defaultConfig['Sabnzbd']['pp_directory'] = pSabNzbdCompleteMov
defaultConfig['Renamer'] = {} defaultConfig['Renamer'] = {}
@ -404,35 +417,39 @@ if firstLaunch:
defaultConfig['Renamer']['separator'] = '.' defaultConfig['Renamer']['separator'] = '.'
defaultConfig['Renamer']['cleanup'] = 'False' defaultConfig['Renamer']['cleanup'] = 'False'
couchPotatoServerConfig.merge(defaultConfig) couchPotatoServerConfig.merge(defaultConfig)
couchPotatoServerConfig.write() couchPotatoServerConfig.write()
# launch CouchPotatoServer # launch CouchPotatoServer
# ------------------ # ------------------
if "true" in couchpotato_launch and "1" in couchpotato_version: if "true" in couchpotato_launch and "1" in couchpotato_version:
logging.debug('Launching CouchPotatoServer...') logging.debug('Launching CouchPotatoServer...')
subprocess.call(couchPotatoServer,close_fds=True) subprocess.call(couchPotatoServer,close_fds=True)
logging.debug('...done') logging.debug('...done')
except Exception,e:
print 'CouchPotatoServer: exception occurred:', e
# CouchPotatoServer end
# write Headphones settings # Headphones start
# ------------------------- try:
# write Headphones settings
headphonesConfig = ConfigObj(pHeadphonesSettings,create_empty=True) # -------------------------
defaultConfig = ConfigObj() headphonesConfig = ConfigObj(pHeadphonesSettings,create_empty=True)
defaultConfig['General'] = {} defaultConfig = ConfigObj()
defaultConfig['General']['launch_browser'] = '0' defaultConfig['General'] = {}
defaultConfig['General']['http_port'] = '8084' defaultConfig['General']['launch_browser'] = '0'
defaultConfig['General']['http_host'] = host defaultConfig['General']['http_port'] = '8084'
defaultConfig['General']['http_username'] = user defaultConfig['General']['http_host'] = host
defaultConfig['General']['http_password'] = pwd defaultConfig['General']['http_username'] = user
if "true" in sabnzbd_launch: defaultConfig['General']['http_password'] = pwd
if "true" in sabnzbd_launch:
defaultConfig['SABnzbd'] = {} defaultConfig['SABnzbd'] = {}
defaultConfig['SABnzbd']['sab_apikey'] = sabNzbdApiKey defaultConfig['SABnzbd']['sab_apikey'] = sabNzbdApiKey
defaultConfig['SABnzbd']['sab_host'] = sabNzbdHost defaultConfig['SABnzbd']['sab_host'] = sabNzbdHost
defaultConfig['SABnzbd']['sab_username'] = user defaultConfig['SABnzbd']['sab_username'] = user
defaultConfig['SABnzbd']['sab_password'] = pwd defaultConfig['SABnzbd']['sab_password'] = pwd
if firstLaunch: if firstLaunch:
defaultConfig['SABnzbd']['sab_category'] = 'music' defaultConfig['SABnzbd']['sab_category'] = 'music'
defaultConfig['General']['music_dir'] = '/storage/music' defaultConfig['General']['music_dir'] = '/storage/music'
defaultConfig['General']['destination_dir'] = '/storage/music' defaultConfig['General']['destination_dir'] = '/storage/music'
@ -440,12 +457,15 @@ if firstLaunch:
defaultConfig['General']['move_files'] = '1' defaultConfig['General']['move_files'] = '1'
defaultConfig['General']['rename_files'] = '1' defaultConfig['General']['rename_files'] = '1'
headphonesConfig.merge(defaultConfig) headphonesConfig.merge(defaultConfig)
headphonesConfig.write() headphonesConfig.write()
# launch Headphones # launch Headphones
# ----------------- # -----------------
if "true" in headphones_launch: if "true" in headphones_launch:
logging.debug('Launching Headphones...') logging.debug('Launching Headphones...')
subprocess.call(headphones,close_fds=True) subprocess.call(headphones,close_fds=True)
logging.debug('...done') logging.debug('...done')
except Exception,e:
print 'Headphones: exception occurred:', e
# Headphones end