示例#1
0
def save_config():

	new_config = ConfigObj()
	new_config.filename = CONFIG_FILE
	
	new_config['General'] = {}
	new_config['General']['config_version'] = CONFIG_VERSION
	new_config['General']['log_dir'] = ACTUAL_LOG_DIR if ACTUAL_LOG_DIR else 'Logs'
	new_config['General']['web_port'] = WEB_PORT
	new_config['General']['web_host'] = WEB_HOST
	new_config['General']['web_ipv6'] = int(WEB_IPV6)
	new_config['General']['web_log'] = int(WEB_LOG)
	new_config['General']['web_root'] = WEB_ROOT
	new_config['General']['web_username'] = WEB_USERNAME
	new_config['General']['web_password'] = WEB_PASSWORD
	new_config['General']['launch_browser'] = LAUNCH_BROWSER
	new_config['General']['ff_profile_path'] = FF_PROFILE_PATH
	new_config['General']['nw_user_name'] = NW_USER_NAME
	new_config['General']['nw_password'] = NW_PASSWORD
	new_config['General']['nw_account_name'] = NW_ACCOUNT_NAME
	new_config['General']['use_twitter'] = USE_TWITTER
	new_config['General']['twitter_username'] = TWITTER_USERNAME
	new_config['General']['twitter_password'] = TWITTER_PASSWORD
	new_config['General']['twitter_prefix'] = TWITTER_PREFIX
	new_config['General']['twitter_notify_on_levelup'] = TWITTER_NOTIFY_ON_LEVELUP
	new_config['General']['twitter_notify_on_raretask'] = TWITTER_NOTIFY_ON_RARETASK
	new_config['General']['blackout_en'] = BLACKOUT_EN
	new_config['General']['blackout_start_hour'] = BLACKOUT_START_HOUR
	new_config['General']['blackout_end_hour'] = BLACKOUT_END_HOUR
	new_config.write()
示例#2
0
def config_write():
    new_config = ConfigObj()
    new_config.filename = CONFIGFILE

    new_config['General'] = {}
    new_config['General']['http_port'] = HTTP_PORT
    new_config['General']['http_host'] = HTTP_HOST
    new_config['General']['http_user'] = HTTP_USER
    new_config['General']['http_pass'] = HTTP_PASS
    new_config['General']['http_root'] = HTTP_ROOT
    new_config['General']['http_look'] = HTTP_LOOK
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    new_config['General']['logdir'] = LOGDIR

    new_config['General']['imp_onlyisbn'] = int(IMP_ONLYISBN)
    new_config['General']['imp_preflang'] = IMP_PREFLANG
    new_config['General']['imp_autoadd'] =  IMP_AUTOADD

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['sab_host'] = SAB_HOST
    new_config['SABnzbd']['sab_port'] = SAB_PORT
    new_config['SABnzbd']['sab_subdir'] = SAB_SUBDIR
    new_config['SABnzbd']['sab_user'] = SAB_USER
    new_config['SABnzbd']['sab_pass'] = SAB_PASS
    new_config['SABnzbd']['sab_api'] = SAB_API
    new_config['SABnzbd']['sab_cat'] = SAB_CAT

    new_config['General']['destination_dir'] = DESTINATION_DIR
    new_config['General']['destination_copy'] = int(DESTINATION_COPY)
    new_config['General']['download_dir'] = DOWNLOAD_DIR
    new_config['General']['blackhole'] = int(BLACKHOLE)
    new_config['General']['blackholedir'] = BLACKHOLEDIR
    new_config['General']['usenet_retention'] = USENET_RETENTION

    new_config['NZBMatrix'] = {}
    new_config['NZBMatrix']['nzbmatrix'] = int(NZBMATRIX)
    new_config['NZBMatrix']['nzbmatrix_user'] = NZBMATRIX_USER
    new_config['NZBMatrix']['nzbmatrix_api'] = NZBMATRIX_API

    new_config['Newznab'] = {}
    new_config['Newznab']['newznab'] = int(NEWZNAB)
    new_config['Newznab']['newznab_host'] = NEWZNAB_HOST
    new_config['Newznab']['newznab_api'] = NEWZNAB_API


    new_config['Newzbin'] = {}
    new_config['Newzbin']['newzbin'] = int(NEWZBIN)
    new_config['Newzbin']['newzbin_uid'] = NEWZBIN_UID
    new_config['Newzbin']['newzbin_pass'] = NEWZBIN_PASS

    new_config['UsenetCrawler'] = {}
    new_config['UsenetCrawler']['usenetcrawler'] = int(USENETCRAWLER)
    new_config['UsenetCrawler']['usenetcrawler_host'] = USENETCRAWLER_HOST
    new_config['UsenetCrawler']['usenetcrawler_api'] = USENETCRAWLER_API

    new_config.write()
示例#3
0
def config_write():

	new_config = ConfigObj()
	new_config.filename = CONFIG_FILE

	new_config['General'] = {}
	new_config['General']['http_port'] = HTTP_PORT
	new_config['General']['http_host'] = HTTP_HOST
	new_config['General']['http_username'] = HTTP_USERNAME
	new_config['General']['http_password'] = HTTP_PASSWORD
	new_config['General']['http_root'] = HTTP_ROOT
	new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
	new_config['General']['git_path'] = GIT_PATH

	new_config['General']['music_dir'] = MUSIC_DIR
	new_config['General']['prefer_lossless'] = int(PREFER_LOSSLESS)
	new_config['General']['flac_to_mp3'] = int(FLAC_TO_MP3)
	new_config['General']['move_files'] = int(MOVE_FILES)
	new_config['General']['rename_files'] = int(RENAME_FILES)
	new_config['General']['folder_format'] = FOLDER_FORMAT
	new_config['General']['file_format'] = FILE_FORMAT
	new_config['General']['cleanup_files'] = int(CLEANUP_FILES)
	new_config['General']['add_album_art'] = int(ADD_ALBUM_ART)
	new_config['General']['download_dir'] = DOWNLOAD_DIR
	new_config['General']['blackhole'] = int(BLACKHOLE)
	new_config['General']['blackhole_dir'] = BLACKHOLE_DIR
	new_config['General']['usenet_retention'] = USENET_RETENTION
	
	new_config['General']['nzb_search_interval'] = NZB_SEARCH_INTERVAL
	new_config['General']['libraryscan_interval'] = LIBRARYSCAN_INTERVAL

	new_config['SABnzbd'] = {}
	new_config['SABnzbd']['sab_host'] = SAB_HOST
	new_config['SABnzbd']['sab_username'] = SAB_USERNAME
	new_config['SABnzbd']['sab_password'] = SAB_PASSWORD
	new_config['SABnzbd']['sab_apikey'] = SAB_APIKEY
	new_config['SABnzbd']['sab_category'] = SAB_CATEGORY

	new_config['NZBMatrix'] = {}
	new_config['NZBMatrix']['nzbmatrix'] = int(NZBMATRIX)
	new_config['NZBMatrix']['nzbmatrix_username'] = NZBMATRIX_USERNAME
	new_config['NZBMatrix']['nzbmatrix_apikey'] = NZBMATRIX_APIKEY

	new_config['Newznab'] = {}
	new_config['Newznab']['newznab'] = int(NEWZNAB)
	new_config['Newznab']['newznab_host'] = NEWZNAB_HOST
	new_config['Newznab']['newznab_apikey'] = NEWZNAB_APIKEY

	new_config['NZBsorg'] = {}
	new_config['NZBsorg']['nzbsorg'] = int(NZBSORG)
	new_config['NZBsorg']['nzbsorg_uid'] = NZBSORG_UID
	new_config['NZBsorg']['nzbsorg_hash'] = NZBSORG_HASH
	
	new_config.write()
示例#4
0
def config_write():
    new_config = ConfigObj()
    new_config.filename = CONFIG_FILE

    new_config['General'] = {}
    new_config['General']['http_port'] = HTTP_PORT
    new_config['General']['http_host'] = HTTP_HOST
    new_config['General']['http_username'] = HTTP_USER
    new_config['General']['http_password'] = HTTP_PASS
    new_config['General']['http_root'] = HTTP_ROOT
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    
    new_config.write()
示例#5
0
def config_write():
    new_config = ConfigObj()
    new_config.filename = CONFIGFILE

    new_config['General'] = {}
    new_config['General']['http_port'] = HTTP_PORT
    new_config['General']['http_host'] = HTTP_HOST
    new_config['General']['http_user'] = HTTP_USER
    new_config['General']['http_pass'] = HTTP_PASS
    new_config['General']['http_root'] = HTTP_ROOT
    new_config['General']['http_look'] = HTTP_LOOK
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    new_config['General']['logdir'] = LOGDIR

    new_config['General']['imp_onlyisbn'] = int(IMP_ONLYISBN)
    new_config['General']['imp_preflang'] = IMP_PREFLANG

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['sab_host'] = SAB_HOST
    new_config['SABnzbd']['sab_port'] = SAB_PORT
    new_config['SABnzbd']['sab_user'] = SAB_USER
    new_config['SABnzbd']['sab_pass'] = SAB_PASS
    new_config['SABnzbd']['sab_api'] = SAB_API
    new_config['SABnzbd']['sab_cat'] = SAB_CAT
    new_config['SABnzbd']['sab_dir'] = SAB_DIR
    new_config['SABnzbd']['blackhole'] = int(BLACKHOLE)
    new_config['SABnzbd']['blackholedir'] = BLACKHOLEDIR
    new_config['SABnzbd']['usenet_retention'] = USENET_RETENTION

    new_config['NZBMatrix'] = {}
    new_config['NZBMatrix']['nzbmatrix'] = int(NZBMATRIX)
    new_config['NZBMatrix']['nzbmatrix_user'] = NZBMATRIX_USER
    new_config['NZBMatrix']['nzbmatrix_api'] = NZBMATRIX_API

    new_config['Newznab'] = {}
    new_config['Newznab']['newznab'] = int(NEWZNAB)
    new_config['Newznab']['newznab_host'] = NEWZNAB_HOST
    new_config['Newznab']['newznab_api'] = NEWZNAB_API

    new_config['NZBsorg'] = {}
    new_config['NZBsorg']['nzbsorg'] = int(NZBSORG)
    new_config['NZBsorg']['nzbsorg_uid'] = NZBSORG_UID
    new_config['NZBsorg']['nzbsorg_hash'] = NZBSORG_HASH
    
    new_config['Newzbin'] = {}
    new_config['Newzbin']['newzbin'] = int(NEWZBIN)
    new_config['Newzbin']['newzbin_uid'] = NEWZBIN_UID
    new_config['Newzbin']['newzbin_pass'] = NEWZBIN_PASS

    new_config.write()
示例#6
0
def config_write():
    new_config = ConfigObj()
    new_config.filename = CONFIGFILE

    new_config['General'] = {}
    new_config['General']['http_port'] = HTTP_PORT
    new_config['General']['http_host'] = HTTP_HOST
    new_config['General']['http_user'] = HTTP_USER
    new_config['General']['http_pass'] = HTTP_PASS
    new_config['General']['http_root'] = HTTP_ROOT
    new_config['General']['http_look'] = HTTP_LOOK
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    new_config['General']['logdir'] = LOGDIR

    new_config['General']['imp_onlyisbn'] = int(IMP_ONLYISBN)
    new_config['General']['imp_preflang'] = IMP_PREFLANG

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['sab_host'] = SAB_HOST
    new_config['SABnzbd']['sab_port'] = SAB_PORT
    new_config['SABnzbd']['sab_user'] = SAB_USER
    new_config['SABnzbd']['sab_pass'] = SAB_PASS
    new_config['SABnzbd']['sab_api'] = SAB_API
    new_config['SABnzbd']['sab_cat'] = SAB_CAT
    new_config['SABnzbd']['sab_dir'] = SAB_DIR
    new_config['SABnzbd']['blackhole'] = int(BLACKHOLE)
    new_config['SABnzbd']['blackholedir'] = BLACKHOLEDIR
    new_config['SABnzbd']['usenet_retention'] = USENET_RETENTION

    new_config['NZBMatrix'] = {}
    new_config['NZBMatrix']['nzbmatrix'] = int(NZBMATRIX)
    new_config['NZBMatrix']['nzbmatrix_user'] = NZBMATRIX_USER
    new_config['NZBMatrix']['nzbmatrix_api'] = NZBMATRIX_API

    new_config['Newznab'] = {}
    new_config['Newznab']['newznab'] = int(NEWZNAB)
    new_config['Newznab']['newznab_host'] = NEWZNAB_HOST
    new_config['Newznab']['newznab_api'] = NEWZNAB_API

    new_config['NZBsorg'] = {}
    new_config['NZBsorg']['nzbsorg'] = int(NZBSORG)
    new_config['NZBsorg']['nzbsorg_uid'] = NZBSORG_UID
    new_config['NZBsorg']['nzbsorg_hash'] = NZBSORG_HASH

    new_config['Newzbin'] = {}
    new_config['Newzbin']['newzbin'] = int(NEWZBIN)
    new_config['Newzbin']['newzbin_uid'] = NEWZBIN_UID
    new_config['Newzbin']['newzbin_pass'] = NEWZBIN_PASS

    new_config.write()
示例#7
0
文件: Config.py 项目: avjui/Homepy
	def Write(self):

		new_config = ConfigObj()
		new_config.filename = core.CONFIG_FILE

		new_config['General'] = {}
		new_config['General']['http_port'] = core.HTTP_PORT
		new_config['General']['http_host'] = core.HTTP_HOST
		new_config['General']['http_username'] = core.HTTP_USERNAME
		new_config['General']['http_password'] = core.HTTP_PASSWORD

		new_config['Syssetting'] = {}
		new_config['Syssetting']['web_interface'] = core.WEB_INTERFACE
		new_config['Syssetting']['rooms'] = core.ROOMS
		new_config['Syssetting']['debug_log'] = core.DEBUG_LOG
		new_config['Syssetting']['root'] = core.HTTP_ROOT
		new_config.write()
示例#8
0
def save_config():

    new_config = ConfigObj()
    new_config.filename = CONFIG_FILE

    new_config['General'] = {}
    new_config['General']['log_dir'] = LOG_DIR
    new_config['General']['web_port'] = WEB_PORT
    new_config['General']['web_ipv6'] = int(WEB_IPV6)
    new_config['General']['web_log'] = int(WEB_LOG)
    new_config['General']['web_root'] = WEB_ROOT
    new_config['General']['web_username'] = WEB_USERNAME
    new_config['General']['web_password'] = WEB_PASSWORD
    new_config['General']['enable_https'] = int(ENABLE_HTTPS)
    new_config['General']['https_cert'] = HTTPS_CERT
    new_config['General']['https_key'] = HTTPS_KEY
    new_config['General']['git_path'] = GIT_PATH

    new_config.write()
示例#9
0
def save_config():

    new_config = ConfigObj()
    new_config.filename = CONFIG_FILE

    new_config['General'] = {}
    new_config['General']['psql'] = psql
    new_config['General']['accesslog'] = accesslog
    new_config['General']['moviedir'] = moviedir
    new_config['General']['seriesdir'] = seriesdir
    new_config['General']['try_guessing'] = int(try_guessing)
    new_config['General']['delete_logs'] = int(delete_logs)
    new_config['General']['scrobble_series'] = int(scrobble_series)
    new_config['General']['use_database'] = int(use_database)
    new_config['General']['scrobble_movies'] = int(scrobble_movies)
    new_config['General']['clean_uncomplete_only'] = int(clean_uncomplete_only)


    new_config['Advanced'] = {}
    new_config['Advanced']['logtoconsole'] = int(logtoconsole)
    new_config['Advanced']['debugmode'] = int(debugmode)
    new_config['Advanced']['min_progress'] = min_progress
    new_config['Advanced']['interval'] = interval

    new_config['Trakt'] = {}
    new_config['Trakt']['trakt_pass'] = trakt_pass
    new_config['Trakt']['trakt_user'] = trakt_user
    #new_config['Trakt']['trakt_key'] = trakt_key

    new_config['Boxcar'] = {}
    new_config['Boxcar']['use_boxcar'] = int(use_boxcar)
    new_config['Boxcar']['boxcar_username'] = boxcar_username

    new_config['Postprocessing'] = {}
    new_config['Postprocessing']['move_watched_movies'] = int(move_watched_movies)
    new_config['Postprocessing']['move_watched_series'] = int(move_watched_series)
    new_config['Postprocessing']['move_movies_to_dir'] = move_movies_to_dir
    new_config['Postprocessing']['move_series_to_dir'] = move_series_to_dir
    new_config['Postprocessing']['update_synoindex'] = int(update_synoindex)
    new_config['Postprocessing']['delete_from_index'] = int(delete_from_index)

    new_config.write()
示例#10
0
 def saveConfig(self):
     """
     This will write out the configuration file to the system. It will be called
     when the application is done with everything else to ensure any settings
     that are updated while running are preserved for the next run. Also the
     user could go and modify this file between runs if they so desired.
     """
     configFile = ConfigObj()
     configFile.filename = self.config
     #General stuff
     configFile['GENERAL'] = {}
     configFile['GENERAL']['log_dir'] = self.log_dir
     configFile['GENERAL']['data_dir'] = self.data_dir
     #User Specific
     configFile['USER_SETTINGS'] = {}
     configFile['USER_SETTINGS']['picture_root'] = self.picture_root
     configFile['SCHEDULING'] = {}
     configFile['SCHEDULING']['start_time'] = self.start_time
     configFile['SCHEDULING']['scan_interval'] = self.scan_interval
     configFile.write()
示例#11
0
def config_write():

    logger.info('Writing Config')
    new_config = ConfigObj()
    
    new_config.filename = CONFIG_FILE

    new_config['General'] = {}
    new_config['General']['http_port'] = HTTP_PORT
    new_config['General']['http_username'] = HTTP_USERNAME
    new_config['General']['http_password'] = HTTP_PASSWORD
    new_config['General']['site_username'] = USERNAME
    new_config['General']['site_password'] = PASSWORD
    new_config['General']['dldir'] = ROOTDIR
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    new_config['General']['makecbz'] = int(CBZ_Compress)



	#Write Config
    new_config.write()
示例#12
0
def config_write():
    new_config = ConfigObj()
    new_config.filename = CONFIGFILE

    new_config['General'] = {}
    new_config['General']['server_name'] = SERVER_NAME
    new_config['General']['http_port'] = HTTP_PORT
    new_config['General']['http_host'] = HTTP_HOST
    new_config['General']['http_user'] = HTTP_USER
    new_config['General']['http_pass'] = HTTP_PASS
    new_config['General']['http_root'] = HTTP_ROOT
    new_config['General']['http_look'] = HTTP_LOOK
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    new_config['General']['logdir'] = LOGDIR

    new_config['XBMC'] = {}
    new_config['XBMC']['xbmc_version'] = XBMC_VERSION
    new_config['XBMC']['xbmc_host'] = XBMC_HOST
    new_config['XBMC']['xbmc_port'] = XBMC_PORT
    new_config['XBMC']['xbmc_user'] = XBMC_USER
    new_config['XBMC']['xbmc_password'] = XBMC_PASSWORD
    new_config['XBMC']['xbmc_thumb_path'] = XBMC_THUMB_PATH

    new_config.write()
示例#13
0
文件: settings.py 项目: hjone72/mylar
    def __init__(self):

        self.settings_file = ""
        self.folder = ""
        self.setDefaultValues()

        #self.config = configparser.RawConfigParser()
        self.folder = ComicTaggerSettings.getSettingsFolder()

        if not os.path.exists(self.folder):
            os.makedirs(self.folder)

        self.settings_file = os.path.join(self.folder, "settings.ini")
        self.CFG = ConfigObj(self.settings_file, encoding='utf-8')

        # if config file doesn't exist, write one out
        if not os.path.exists(self.settings_file):
            self.save()
        else:
            self.load()

        # take a crack at finding rar exes, if not set already
        if self.rar_exe_path == "":
            if platform.system() == "Windows":
                # look in some likely places for windows machine
                if os.path.exists("C:\Program Files\WinRAR\Rar.exe"):
                    self.rar_exe_path = "C:\Program Files\WinRAR\Rar.exe"
                elif os.path.exists("C:\Program Files (x86)\WinRAR\Rar.exe"):
                    self.rar_exe_path = "C:\Program Files (x86)\WinRAR\Rar.exe"
            else:
                # see if it's in the path of unix user
                if utils.which("rar") is not None:
                    self.rar_exe_path = utils.which("rar")
            if self.rar_exe_path != "":
                self.save()

        if self.unrar_exe_path == "":
            if platform.system() != "Windows":
                # see if it's in the path of unix user
                if utils.which("unrar") is not None:
                    self.unrar_exe_path = utils.which("unrar")
            if self.unrar_exe_path != "":
                self.save()

        # make sure unrar/rar program is now in the path for the UnRAR class to use
        utils.addtopath(os.path.dirname(self.unrar_exe_path))
        utils.addtopath(os.path.dirname(self.rar_exe_path))
示例#14
0
    def __init__(self,
                 setup_cfg,
                 setup_spec,
                 test_cfg,
                 test_spec,
                 test_handlers,
                 user_setup_cfg='',
                 user_test_cfg='',
                 logger=None):

        self.logger = logger or logging.getLogger(__name__)

        for cfg in [setup_cfg, setup_spec, test_cfg, test_spec]:
            self._config_check(cfg)

        self.setupobj = ConfigObj(setup_cfg, configspec=setup_spec)
        self._validate(self.setupobj)

        if os.path.exists(user_setup_cfg):
            userobj = ConfigObj(user_setup_cfg, configspec=setup_spec)
            self._validate(userobj)
            self.setupobj.merge(userobj)

        self.testobj = ConfigObj(test_cfg, configspec=test_spec)
        self._validate(self.testobj)

        if os.path.exists(user_test_cfg):
            userobj = ConfigObj(user_test_cfg, configspec=test_spec)
            self._validate(userobj)
            self.testobj.merge(userobj)

        self.logger.debug(self.setupobj)
        self.logger.debug(self.testobj)

        host_keys = self.setupobj['test']['preffered-host-terminal'].split(':')
        remote_keys = self.setupobj['test']['preffered-remote-terminal'].split(
            ':')

        self.host_params = self.setupobj[host_keys[0]][host_keys[1]][
            host_keys[2]]
        self.remote_params = self.setupobj[remote_keys[0]][remote_keys[1]][
            remote_keys[2]]

        self.host = self._create_terminal(self.host_params)
        self.remote = self._create_terminal(self.remote_params)

        self.test_handlers = test_handlers
示例#15
0
class TestManager(object):
    def _validate(self, obj):
        validator = Validator()
        results = obj.validate(validator)
        if results != True:
            for (section_list, key, _) in flatten_errors(obj, results):
                if key is not None:
                    raise Exception(
                        'The "%s" key in the section "%s" failed validation' %
                        (key, ', '.join(section_list)))
                else:
                    raise Exception('The following section was missing:%s ' %
                                    ', '.join(section_list))

    def _key_check(self, configobj, *keys):
        obj = configobj
        for key in keys:
            if key not in obj.keys():
                return False
            else:
                obj = configobj[key]

        return True

    def _config_check(self, cfg):
        if not os.path.exists(cfg):
            raise IOError("File %s does not exists" % cfg)

    @EntryExit
    def _create_terminal(self, terminal):
        self.logger.debug(format_h1("Create %s terminal" % terminal['type']))
        if terminal['type'] == 'serial':
            return SerialTerminal(port=terminal['name'],
                                  baud=terminal['baudrate'],
                                  parity=terminal['parity'],
                                  stopbits=terminal['stopbit'],
                                  bytesize=terminal['bytesize'],
                                  hfc=terminal['hfc'],
                                  sfc=terminal['sfc'],
                                  timeout=terminal['timeout'])
        elif terminal['type'] == 'usb-adb':
            return AdbTerminal()
        else:
            return ShellTerminal()

    @EntryExit
    def _setup_remote(self):
        self.logger.debug(format_h1("Setup remote"))
        self.remote.send_command(self.remote_params['login_cmd'])
        self.remote.send_command(self.remote_params['setup_cmd'])

    @EntryExit
    def _reset_remote(self):
        self.logger.debug(format_h1("Reset remote"))
        self.remote.send_command(self.remote_params['reset_cmd'])
        self.remote.send_command(self.remote_params['exit_cmd'])

    def __init__(self,
                 setup_cfg,
                 setup_spec,
                 test_cfg,
                 test_spec,
                 test_handlers,
                 user_setup_cfg='',
                 user_test_cfg='',
                 logger=None):

        self.logger = logger or logging.getLogger(__name__)

        for cfg in [setup_cfg, setup_spec, test_cfg, test_spec]:
            self._config_check(cfg)

        self.setupobj = ConfigObj(setup_cfg, configspec=setup_spec)
        self._validate(self.setupobj)

        if os.path.exists(user_setup_cfg):
            userobj = ConfigObj(user_setup_cfg, configspec=setup_spec)
            self._validate(userobj)
            self.setupobj.merge(userobj)

        self.testobj = ConfigObj(test_cfg, configspec=test_spec)
        self._validate(self.testobj)

        if os.path.exists(user_test_cfg):
            userobj = ConfigObj(user_test_cfg, configspec=test_spec)
            self._validate(userobj)
            self.testobj.merge(userobj)

        self.logger.debug(self.setupobj)
        self.logger.debug(self.testobj)

        host_keys = self.setupobj['test']['preffered-host-terminal'].split(':')
        remote_keys = self.setupobj['test']['preffered-remote-terminal'].split(
            ':')

        self.host_params = self.setupobj[host_keys[0]][host_keys[1]][
            host_keys[2]]
        self.remote_params = self.setupobj[remote_keys[0]][remote_keys[1]][
            remote_keys[2]]

        self.host = self._create_terminal(self.host_params)
        self.remote = self._create_terminal(self.remote_params)

        self.test_handlers = test_handlers

    def _print_test_details(self, test):
        self.logger.debug(format_h1(" Test Details "))
        self.logger.debug("Name: %s" % test['name'])
        self.logger.debug("Type: %s" % test['type'])
        self.logger.debug("Handler: %s" % test['handler'])
        self.logger.debug("Local Cmd Timeout: %s" % test['local_cmd_timeout'])
        self.logger.debug("Local Cmd: %s" % test['local_cmd'])
        self.logger.debug("Remote Cmd Timeout: %s" %
                          test['remote_cmd_timeout'])
        self.logger.debug("Remote Cmd: %s" % test['remote_cmd'])
        self.logger.debug("Remote Cmd Expected Results: %s" %
                          test['remote_expected_result'])
        self.logger.debug(format_h1())

    @EntryExit
    def exec_tests(self, index=-1):
        self._setup_remote()
        if index == -1:
            for id, params in self.testobj.iteritems():
                env = self.setupobj['remote']['env']
                for handler in params['handler']:
                    self.logger.info(
                        format_h1("Executing Test ID:%s Handler:%s()" %
                                  (str(id), str(handler))))
                    output, status = getattr(self.test_handlers, handler)(
                        self.host, self.remote, id,
                        dict(params.items() + env.items()))
        elif index >= 0:
            count = -1
            for id, params in self.testobj.iteritems():
                count = count + 1
                if count == index:
                    env = self.setupobj['remote']['env']
                    for handler in params['handler']:
                        self.logger.info(
                            format_h1("Executing Test ID:%s Handler:%s()" %
                                      (str(id), str(handler))))
                        output, status = getattr(self.test_handlers, handler)(
                            self.host, self.remote, id,
                            dict(params.items() + env.items()))
        self._reset_remote()
示例#16
0
    try:
        funzip = xbmc.translatePath(pPylib + '/multiarch/unzip.' + parch)
        xbmcvfs.copy(funzip, punzip)
        os.chmod(punzip, 0755)
        xbmc.log('AUDO: Copied unzip for ' + parch, level=xbmc.LOGDEBUG)
    except Exception, e:
        xbmc.log('AUDO: Error Copying unzip for ' + parch, level=xbmc.LOGERROR)
        xbmc.log(str(e), level=xbmc.LOGERROR)

os.environ['PYTHONPATH'] = str(os.environ.get('PYTHONPATH')) + ':' + pPylib

# 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'
示例#17
0
def config_write():

    new_config = ConfigObj()
    new_config.filename = CONFIG_FILE

    new_config['General'] = {}
    new_config['General']['config_version'] = CONFIG_VERSION
    new_config['General']['http_port'] = HTTP_PORT
    new_config['General']['http_host'] = HTTP_HOST
    new_config['General']['http_username'] = HTTP_USERNAME
    new_config['General']['http_password'] = HTTP_PASSWORD
    new_config['General']['http_root'] = HTTP_ROOT
    new_config['General']['http_proxy'] = int(HTTP_PROXY)
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    new_config['General']['api_enabled'] = int(API_ENABLED)
    new_config['General']['api_key'] = API_KEY
    new_config['General']['log_dir'] = LOG_DIR
    new_config['General']['git_path'] = GIT_PATH
    
    new_config['General']['check_github'] = int(CHECK_GITHUB)
    new_config['General']['check_github_on_startup'] = int(CHECK_GITHUB_ON_STARTUP)
    new_config['General']['check_github_interval'] = CHECK_GITHUB_INTERVAL

    new_config['General']['music_dir'] = MUSIC_DIR
    new_config['General']['destination_dir'] = DESTINATION_DIR
    new_config['General']['lossless_destination_dir'] = LOSSLESS_DESTINATION_DIR
    new_config['General']['preferred_quality'] = PREFERRED_QUALITY
    new_config['General']['preferred_bitrate'] = PREFERRED_BITRATE
    new_config['General']['preferred_bitrate_high_buffer'] = PREFERRED_BITRATE_HIGH_BUFFER
    new_config['General']['preferred_bitrate_low_buffer'] = PREFERRED_BITRATE_LOW_BUFFER
    new_config['General']['detect_bitrate'] = int(DETECT_BITRATE)
    new_config['General']['auto_add_artists'] = int(ADD_ARTISTS)
    new_config['General']['correct_metadata'] = int(CORRECT_METADATA)
    new_config['General']['move_files'] = int(MOVE_FILES)
    new_config['General']['rename_files'] = int(RENAME_FILES)
    new_config['General']['folder_format'] = FOLDER_FORMAT
    new_config['General']['file_format'] = FILE_FORMAT
    new_config['General']['cleanup_files'] = int(CLEANUP_FILES)
    new_config['General']['add_album_art'] = int(ADD_ALBUM_ART)
    new_config['General']['embed_album_art'] = int(EMBED_ALBUM_ART)
    new_config['General']['embed_lyrics'] = int(EMBED_LYRICS)
    new_config['General']['download_dir'] = DOWNLOAD_DIR
    new_config['General']['blackhole'] = int(BLACKHOLE)
    new_config['General']['blackhole_dir'] = BLACKHOLE_DIR
    new_config['General']['usenet_retention'] = USENET_RETENTION
    new_config['General']['include_extras'] = int(INCLUDE_EXTRAS)
    new_config['General']['extras'] = EXTRAS
    new_config['General']['autowant_upcoming'] = int(AUTOWANT_UPCOMING)
    new_config['General']['autowant_all'] = int(AUTOWANT_ALL)
    
    new_config['General']['numberofseeders'] = NUMBEROFSEEDERS
    new_config['General']['torrentblackhole_dir'] = TORRENTBLACKHOLE_DIR
    new_config['General']['isohunt'] = int(ISOHUNT)
    new_config['General']['kat'] = int(KAT)
    new_config['General']['mininova'] = int(MININOVA)
    new_config['General']['download_torrent_dir'] = DOWNLOAD_TORRENT_DIR

    new_config['Waffles'] = {}
    new_config['Waffles']['waffles'] = int(WAFFLES)
    new_config['Waffles']['waffles_uid'] = WAFFLES_UID
    new_config['Waffles']['waffles_passkey'] = WAFFLES_PASSKEY

    new_config['General']['search_interval'] = SEARCH_INTERVAL
    new_config['General']['libraryscan_interval'] = LIBRARYSCAN_INTERVAL
    new_config['General']['download_scan_interval'] = DOWNLOAD_SCAN_INTERVAL

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['sab_host'] = SAB_HOST
    new_config['SABnzbd']['sab_username'] = SAB_USERNAME
    new_config['SABnzbd']['sab_password'] = SAB_PASSWORD
    new_config['SABnzbd']['sab_apikey'] = SAB_APIKEY
    new_config['SABnzbd']['sab_category'] = SAB_CATEGORY

    new_config['NZBMatrix'] = {}
    new_config['NZBMatrix']['nzbmatrix'] = int(NZBMATRIX)
    new_config['NZBMatrix']['nzbmatrix_username'] = NZBMATRIX_USERNAME
    new_config['NZBMatrix']['nzbmatrix_apikey'] = NZBMATRIX_APIKEY

    new_config['Newznab'] = {}
    new_config['Newznab']['newznab'] = int(NEWZNAB)
    new_config['Newznab']['newznab_host'] = NEWZNAB_HOST
    new_config['Newznab']['newznab_apikey'] = NEWZNAB_APIKEY
    new_config['Newznab']['newznab_enabled'] = int(NEWZNAB_ENABLED)
    # Need to unpack the extra newznabs for saving in config.ini
    flattened_newznabs = []
    for newznab in EXTRA_NEWZNABS:
        for item in newznab:
            flattened_newznabs.append(item)
    
    new_config['Newznab']['extra_newznabs'] = flattened_newznabs

    new_config['NZBsorg'] = {}
    new_config['NZBsorg']['nzbsorg'] = int(NZBSORG)
    new_config['NZBsorg']['nzbsorg_uid'] = NZBSORG_UID
    new_config['NZBsorg']['nzbsorg_hash'] = NZBSORG_HASH
    
    new_config['Newzbin'] = {}
    new_config['Newzbin']['newzbin'] = int(NEWZBIN)
    new_config['Newzbin']['newzbin_uid'] = NEWZBIN_UID
    new_config['Newzbin']['newzbin_password'] = NEWZBIN_PASSWORD
    
    new_config['Prowl'] = {}
    new_config['Prowl']['prowl_enabled'] = int(PROWL_ENABLED)
    new_config['Prowl']['prowl_keys'] = PROWL_KEYS
    new_config['Prowl']['prowl_onsnatch'] = int(PROWL_ONSNATCH)
    new_config['Prowl']['prowl_priority'] = int(PROWL_PRIORITY)
    
    new_config['XBMC'] = {}
    new_config['XBMC']['xbmc_enabled'] = int(XBMC_ENABLED)
    new_config['XBMC']['xbmc_host'] = XBMC_HOST
    new_config['XBMC']['xbmc_username'] = XBMC_USERNAME
    new_config['XBMC']['xbmc_password'] = XBMC_PASSWORD
    new_config['XBMC']['xbmc_update'] = int(XBMC_UPDATE)
    new_config['XBMC']['xbmc_notify'] = int(XBMC_NOTIFY)
    
    new_config['NMA'] = {}
    new_config['NMA']['nma_enabled'] = int(NMA_ENABLED)
    new_config['NMA']['nma_apikey'] = NMA_APIKEY
    new_config['NMA']['nma_priority'] = NMA_PRIORITY

    new_config['Synoindex'] = {}
    new_config['Synoindex']['synoindex_enabled'] = int(SYNOINDEX_ENABLED)
    
    new_config['General']['lastfm_username'] = LASTFM_USERNAME
    new_config['General']['interface'] = INTERFACE
    new_config['General']['folder_permissions'] = FOLDER_PERMISSIONS

    new_config['General']['music_encoder'] = int(MUSIC_ENCODER)
    new_config['General']['encoder'] = ENCODER
    new_config['General']['bitrate'] = int(BITRATE)
    new_config['General']['samplingfrequency'] = int(SAMPLINGFREQUENCY)
    new_config['General']['encoderfolder'] = ENCODERFOLDER
    new_config['General']['advancedencoder'] = ADVANCEDENCODER
    new_config['General']['encoderoutputformat'] = ENCODEROUTPUTFORMAT
    new_config['General']['encoderquality'] = ENCODERQUALITY
    new_config['General']['encodervbrcbr'] = ENCODERVBRCBR
    new_config['General']['encoderlossless'] = int(ENCODERLOSSLESS)
    new_config['General']['delete_lossless_files'] = int(DELETE_LOSSLESS_FILES)
    
    new_config['General']['mirror'] = MIRROR
    new_config['General']['customhost'] = CUSTOMHOST
    new_config['General']['customport'] = CUSTOMPORT
    new_config['General']['customsleep'] = CUSTOMSLEEP
    new_config['General']['hpuser'] = HPUSER
    new_config['General']['hppass'] = HPPASS
    
    new_config['Advanced'] = {}
    new_config['Advanced']['album_completion_pct'] = ALBUM_COMPLETION_PCT
    
    new_config.write()
示例#18
0
def config_write():
    new_config = ConfigObj()
    new_config.filename = CONFIGFILE

    new_config['General'] = {}
    new_config['General']['http_port'] = HTTP_PORT
    new_config['General']['http_host'] = HTTP_HOST
    new_config['General']['http_user'] = HTTP_USER
    new_config['General']['http_pass'] = HTTP_PASS
    new_config['General']['http_root'] = HTTP_ROOT
    new_config['General']['http_look'] = HTTP_LOOK
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    new_config['General']['proxy_host'] = PROXY_HOST
    new_config['General']['proxy_type'] = PROXY_TYPE
    new_config['General']['logdir'] = LOGDIR
    new_config['General']['loglevel'] = int(LOGLEVEL)

    new_config['General']['match_ratio'] = MATCH_RATIO

    new_config['General']['imp_onlyisbn'] = int(IMP_ONLYISBN)
    new_config['General']['imp_preflang'] = IMP_PREFLANG
    new_config['General']['imp_autoadd'] = IMP_AUTOADD

    new_config['General']['ebook_type'] = EBOOK_TYPE

    new_config['Git'] = {}
    new_config['Git']['git_user'] = GIT_USER
    new_config['Git']['git_repo'] = GIT_REPO
    new_config['Git']['git_branch'] = GIT_BRANCH
    new_config['Git']['install_type'] = INSTALL_TYPE
    new_config['Git']['current_version'] = CURRENT_VERSION
    new_config['Git']['latest_version'] = LATEST_VERSION
    new_config['Git']['commits_behind'] = COMMITS_BEHIND

    new_config['USENET'] = {}
    new_config['USENET']['nzb_downloader_sabnzbd'] = NZB_DOWNLOADER_SABNZBD
    new_config['USENET']['nzb_downloader_blackhole'] = NZB_DOWNLOADER_BLACKHOLE
    new_config['USENET']['nzb_blackholedir'] = NZB_BLACKHOLEDIR
    new_config['USENET']['usenet_retention'] = USENET_RETENTION

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['sab_host'] = SAB_HOST
    new_config['SABnzbd']['sab_port'] = SAB_PORT
    new_config['SABnzbd']['sab_subdir'] = SAB_SUBDIR
    new_config['SABnzbd']['sab_user'] = SAB_USER
    new_config['SABnzbd']['sab_pass'] = SAB_PASS
    new_config['SABnzbd']['sab_api'] = SAB_API
    new_config['SABnzbd']['sab_cat'] = SAB_CAT

    new_config['General']['destination_dir'] = DESTINATION_DIR
    new_config['General']['destination_copy'] = int(DESTINATION_COPY)
    new_config['General']['download_dir'] = DOWNLOAD_DIR

    new_config['DLMethod'] = {}
    new_config['DLMethod']['use_tor'] = int(USE_TOR)
    new_config['DLMethod']['use_nzb'] = int(USE_NZB)

    new_config['API'] = {}
    new_config['API']['book_api'] = BOOK_API
    new_config['API']['gr_api'] = GR_API
    new_config['API']['gb_api'] = GB_API

    new_config['NZBMatrix'] = {}
    new_config['NZBMatrix']['nzbmatrix'] = int(NZBMATRIX)
    new_config['NZBMatrix']['nzbmatrix_user'] = NZBMATRIX_USER
    new_config['NZBMatrix']['nzbmatrix_api'] = NZBMATRIX_API

    new_config['Newznab'] = {}
    new_config['Newznab']['newznab'] = int(NEWZNAB)
    new_config['Newznab']['newznab_host'] = NEWZNAB_HOST
    new_config['Newznab']['newznab_api'] = NEWZNAB_API

    new_config['Newznab2'] = {}
    new_config['Newznab2']['newznab2'] = int(NEWZNAB2)
    new_config['Newznab2']['newznab_host2'] = NEWZNAB_HOST2
    new_config['Newznab2']['newznab_api2'] = NEWZNAB_API2

    new_config['Newzbin'] = {}
    new_config['Newzbin']['newzbin'] = int(NEWZBIN)
    new_config['Newzbin']['newzbin_uid'] = NEWZBIN_UID
    new_config['Newzbin']['newzbin_pass'] = NEWZBIN_PASS

    new_config['TORRENT'] = {}
    new_config['TORRENT'][
        'tor_downloader_blackhole'] = TOR_DOWNLOADER_BLACKHOLE
    new_config['TORRENT']['tor_downloader_utorrent'] = TOR_DOWNLOADER_UTORRENT
    new_config['TORRENT']['numberofseeders'] = NUMBEROFSEEDERS
    new_config['TORRENT']['torrent_dir'] = TORRENT_DIR

    new_config['UTORRENT'] = {}
    new_config['UTORRENT']['utorrent_host'] = UTORRENT_HOST
    new_config['UTORRENT']['utorrent_user'] = UTORRENT_USER
    new_config['UTORRENT']['utorrent_pass'] = UTORRENT_PASS
    new_config['UTORRENT']['utorrent_label'] = UTORRENT_LABEL

    new_config['KAT'] = {}
    new_config['KAT']['kat'] = int(KAT)

    new_config['UsenetCrawler'] = {}
    new_config['UsenetCrawler']['usenetcrawler'] = int(USENETCRAWLER)
    new_config['UsenetCrawler']['usenetcrawler_host'] = USENETCRAWLER_HOST
    new_config['UsenetCrawler']['usenetcrawler_api'] = USENETCRAWLER_API

    new_config['SearchScan'] = {}
    new_config['SearchScan']['search_interval'] = SEARCH_INTERVAL
    new_config['SearchScan']['scan_interval'] = SCAN_INTERVAL
    new_config['SearchScan']['versioncheck_interval'] = VERSIONCHECK_INTERVAL

    new_config['LibraryScan'] = {}
    new_config['LibraryScan']['full_scan'] = FULL_SCAN
    new_config['LibraryScan']['notfound_status'] = NOTFOUND_STATUS
    new_config['LibraryScan']['add_author'] = ADD_AUTHOR

    new_config['PostProcess'] = {}
    new_config['PostProcess']['ebook_dest_folder'] = EBOOK_DEST_FOLDER
    new_config['PostProcess']['ebook_dest_file'] = EBOOK_DEST_FILE
    new_config['PostProcess']['mag_dest_folder'] = MAG_DEST_FOLDER
    new_config['PostProcess']['mag_dest_file'] = MAG_DEST_FILE

    new_config['Twitter'] = {}
    new_config['Twitter']['use_twitter'] = int(USE_TWITTER)
    new_config['Twitter']['twitter_notify_onsnatch'] = int(
        TWITTER_NOTIFY_ONSNATCH)
    new_config['Twitter']['twitter_notify_ondownload'] = int(
        TWITTER_NOTIFY_ONDOWNLOAD)
    new_config['Twitter']['twitter_username'] = TWITTER_USERNAME
    new_config['Twitter']['twitter_password'] = TWITTER_PASSWORD
    new_config['Twitter']['twitter_prefix'] = TWITTER_PREFIX

    new_config['Boxcar'] = {}
    new_config['Boxcar']['use_boxcar'] = int(USE_BOXCAR)
    new_config['Boxcar']['boxcar_notify_onsnatch'] = int(
        BOXCAR_NOTIFY_ONSNATCH)
    new_config['Boxcar']['boxcar_notify_ondownload'] = int(
        BOXCAR_NOTIFY_ONDOWNLOAD)
    new_config['Boxcar']['boxcar_token'] = BOXCAR_TOKEN

    new_config['Pushbullet'] = {}
    new_config['Pushbullet']['use_pushbullet'] = int(USE_PUSHBULLET)
    new_config['Pushbullet']['pushbullet_notify_onsnatch'] = int(
        PUSHBULLET_NOTIFY_ONSNATCH)
    new_config['Pushbullet']['pushbullet_notify_ondownload'] = int(
        PUSHBULLET_NOTIFY_ONDOWNLOAD)
    new_config['Pushbullet']['pushbullet_token'] = PUSHBULLET_TOKEN
    new_config['Pushbullet']['pushbullet_deviceid'] = PUSHBULLET_DEVICEID

    new_config['NMA'] = {}
    new_config['NMA']['nma_enabled'] = int(NMA_ENABLED)
    new_config['NMA']['nma_apikey'] = NMA_APIKEY
    new_config['NMA']['nma_priority'] = NMA_PRIORITY
    new_config['NMA']['nma_onsnatch'] = int(NMA_ONSNATCH)

    new_config.write()
示例#19
0
def config_write():
    logger.debug(u'Opening config file: %s' % CONFIGFILE)
    new_config = ConfigObj()
    new_config.filename = CONFIGFILE

    logger.debug(u'Writing settings.')
    new_config['General'] = {}
    new_config['General']['http_port'] = HTTP_PORT
    new_config['General']['http_host'] = HTTP_HOST
    new_config['General']['http_user'] = HTTP_USER
    new_config['General']['http_pass'] = HTTP_PASS
    new_config['General']['http_root'] = HTTP_ROOT
    new_config['General']['http_look'] = HTTP_LOOK
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    new_config['General']['logdir'] = LOGDIR
    new_config['General']['git_path'] = GIT_PATH
    new_config['General']['git_user'] = GIT_USER
    new_config['General']['git_project'] = GIT_PROJECT
    new_config['General']['git_branch'] = GIT_BRANCH
    
    new_config['General']['check_update'] = int(CHECK_UPDATE)
    new_config['General']['check_update_interval'] = CHECK_UPDATE_INTERVAL
    
    new_config['General']['imp_onlyisbn'] = int(IMP_ONLYISBN)
    new_config['General']['imp_preflang'] = IMP_PREFLANG
    new_config['General']['ebook_type'] = EBOOK_TYPE

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['sab_host'] = SAB_HOST
    new_config['SABnzbd']['sab_port'] = SAB_PORT
    new_config['SABnzbd']['sab_user'] = SAB_USER
    new_config['SABnzbd']['sab_pass'] = SAB_PASS
    new_config['SABnzbd']['sab_api'] = SAB_API
    new_config['SABnzbd']['sab_cat'] = SAB_CAT

    new_config['General']['destination_dir'] = DESTINATION_DIR
    new_config['General']['destination_copy'] = int(DESTINATION_COPY)
    new_config['General']['download_dir'] = DOWNLOAD_DIR
    new_config['General']['blackhole'] = int(BLACKHOLE)
    new_config['General']['blackholedir'] = BLACKHOLEDIR
    new_config['General']['usenet_retention'] = USENET_RETENTION
    new_config['General']['gr_api'] = GR_API

    new_config['NZBMatrix'] = {}
    new_config['NZBMatrix']['nzbmatrix'] = int(NZBMATRIX)
    new_config['NZBMatrix']['nzbmatrix_user'] = NZBMATRIX_USER
    new_config['NZBMatrix']['nzbmatrix_api'] = NZBMATRIX_API

    new_config['Newznab'] = {}
    new_config['Newznab']['newznab'] = int(NEWZNAB)
    new_config['Newznab']['newznab_host'] = NEWZNAB_HOST
    new_config['Newznab']['newznab_api'] = NEWZNAB_API

    new_config['Newznab2'] = {}
    new_config['Newznab2']['newznab2'] = int(NEWZNAB2)
    new_config['Newznab2']['newznab_host2'] = NEWZNAB_HOST2
    new_config['Newznab2']['newznab_api2'] = NEWZNAB_API2

    new_config['Newzbin'] = {}
    new_config['Newzbin']['newzbin'] = int(NEWZBIN)
    new_config['Newzbin']['newzbin_uid'] = NEWZBIN_UID
    new_config['Newzbin']['newzbin_pass'] = NEWZBIN_PASS

    logger.debug(u'Closing file.')
    new_config.write()
示例#20
0
def config_write():
    new_config = ConfigObj()
    new_config.filename = CONFIGFILE

    new_config['General'] = {}
    new_config['General']['http_port'] = HTTP_PORT
    new_config['General']['http_host'] = HTTP_HOST
    new_config['General']['http_user'] = HTTP_USER
    new_config['General']['http_pass'] = HTTP_PASS
    new_config['General']['http_root'] = HTTP_ROOT
    new_config['General']['http_look'] = HTTP_LOOK
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    new_config['General']['logdir'] = LOGDIR

    new_config['General']['imp_onlyisbn'] = int(IMP_ONLYISBN)
    new_config['General']['imp_preflang'] = IMP_PREFLANG

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['sab_host'] = SAB_HOST
    new_config['SABnzbd']['sab_port'] = SAB_PORT
    new_config['SABnzbd']['sab_user'] = SAB_USER
    new_config['SABnzbd']['sab_pass'] = SAB_PASS
    new_config['SABnzbd']['sab_api'] = SAB_API
    new_config['SABnzbd']['sab_cat'] = SAB_CAT

    new_config['General']['destination_dir'] = DESTINATION_DIR
    new_config['General']['destination_copy'] = int(DESTINATION_COPY)
    new_config['General']['download_dir'] = DOWNLOAD_DIR
    new_config['General']['blackhole'] = int(BLACKHOLE)
    new_config['General']['blackholedir'] = BLACKHOLEDIR
    new_config['General']['usenet_retention'] = USENET_RETENTION

    new_config['NZBMatrix'] = {}
    new_config['NZBMatrix']['nzbmatrix'] = int(NZBMATRIX)
    new_config['NZBMatrix']['nzbmatrix_user'] = NZBMATRIX_USER
    new_config['NZBMatrix']['nzbmatrix_api'] = NZBMATRIX_API

    new_config['Newznab'] = {}
    new_config['Newznab']['newznab'] = int(NEWZNAB)
    new_config['Newznab']['newznab_host'] = NEWZNAB_HOST
    new_config['Newznab']['newznab_api'] = NEWZNAB_API

    new_config['Newzbin'] = {}
    new_config['Newzbin']['newzbin'] = int(NEWZBIN)
    new_config['Newzbin']['newzbin_uid'] = NEWZBIN_UID
    new_config['Newzbin']['newzbin_pass'] = NEWZBIN_PASS

    new_config['SearchScan'] = {}
    new_config['SearchScan']['search_interval'] = SEARCH_INTERVAL
    new_config['SearchScan']['scan_interval'] = SCAN_INTERVAL

    new_config['PostProcess'] = {}
    new_config['PostProcess']['ebook_dest_folder'] = EBOOK_DEST_FOLDER
    new_config['PostProcess']['ebook_dest_file'] = EBOOK_DEST_FILE
    new_config['PostProcess']['mag_dest_folder'] = MAG_DEST_FOLDER
    new_config['PostProcess']['mag_dest_file'] = MAG_DEST_FILE

    new_config['Twitter'] = {}
    new_config['Twitter']['use_twitter'] = int(USE_TWITTER)
    new_config['Twitter']['twitter_notify_onsnatch'] = int(TWITTER_NOTIFY_ONSNATCH)
    new_config['Twitter']['twitter_notify_ondownload'] = int(TWITTER_NOTIFY_ONDOWNLOAD)
    new_config['Twitter']['twitter_username'] = TWITTER_USERNAME
    new_config['Twitter']['twitter_password'] = TWITTER_PASSWORD
    new_config['Twitter']['twitter_prefix'] = TWITTER_PREFIX

    new_config.write()
示例#21
0
def config_write():

    new_config = ConfigObj()
    new_config.filename = CONFIG_FILE

    new_config['General'] = {}
    new_config['General']['config_version'] = CONFIG_VERSION
    new_config['General']['http_port'] = HTTP_PORT
    new_config['General']['http_host'] = HTTP_HOST
    new_config['General']['http_username'] = HTTP_USERNAME
    new_config['General']['http_password'] = HTTP_PASSWORD
    new_config['General']['http_root'] = HTTP_ROOT
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    new_config['General']['api_enabled'] = int(API_ENABLED)
    new_config['General']['api_key'] = API_KEY
    new_config['General']['log_dir'] = LOG_DIR
    new_config['General']['git_path'] = GIT_PATH

    new_config['General']['check_github'] = int(CHECK_GITHUB)
    new_config['General']['check_github_on_startup'] = int(
        CHECK_GITHUB_ON_STARTUP)
    new_config['General']['check_github_interval'] = CHECK_GITHUB_INTERVAL

    new_config['General']['music_dir'] = MUSIC_DIR
    new_config['General']['destination_dir'] = DESTINATION_DIR
    new_config['General']['preferred_quality'] = PREFERRED_QUALITY
    new_config['General']['preferred_bitrate'] = PREFERRED_BITRATE
    new_config['General']['detect_bitrate'] = int(DETECT_BITRATE)
    new_config['General']['auto_add_artists'] = int(ADD_ARTISTS)
    new_config['General']['correct_metadata'] = int(CORRECT_METADATA)
    new_config['General']['move_files'] = int(MOVE_FILES)
    new_config['General']['rename_files'] = int(RENAME_FILES)
    new_config['General']['folder_format'] = FOLDER_FORMAT
    new_config['General']['file_format'] = FILE_FORMAT
    new_config['General']['cleanup_files'] = int(CLEANUP_FILES)
    new_config['General']['add_album_art'] = int(ADD_ALBUM_ART)
    new_config['General']['embed_album_art'] = int(EMBED_ALBUM_ART)
    new_config['General']['embed_lyrics'] = int(EMBED_LYRICS)
    new_config['General']['download_dir'] = DOWNLOAD_DIR
    new_config['General']['blackhole'] = int(BLACKHOLE)
    new_config['General']['blackhole_dir'] = BLACKHOLE_DIR
    new_config['General']['usenet_retention'] = USENET_RETENTION
    new_config['General']['include_extras'] = int(INCLUDE_EXTRAS)
    new_config['General']['autowant_upcoming'] = int(AUTOWANT_UPCOMING)
    new_config['General']['autowant_all'] = int(AUTOWANT_ALL)

    new_config['General']['numberofseeders'] = NUMBEROFSEEDERS
    new_config['General']['torrentblackhole_dir'] = TORRENTBLACKHOLE_DIR
    new_config['General']['isohunt'] = int(ISOHUNT)
    new_config['General']['kat'] = int(KAT)
    new_config['General']['mininova'] = int(MININOVA)
    new_config['General']['download_torrent_dir'] = DOWNLOAD_TORRENT_DIR

    new_config['General']['search_interval'] = SEARCH_INTERVAL
    new_config['General']['libraryscan_interval'] = LIBRARYSCAN_INTERVAL
    new_config['General']['download_scan_interval'] = DOWNLOAD_SCAN_INTERVAL

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['sab_host'] = SAB_HOST
    new_config['SABnzbd']['sab_username'] = SAB_USERNAME
    new_config['SABnzbd']['sab_password'] = SAB_PASSWORD
    new_config['SABnzbd']['sab_apikey'] = SAB_APIKEY
    new_config['SABnzbd']['sab_category'] = SAB_CATEGORY

    new_config['NZBMatrix'] = {}
    new_config['NZBMatrix']['nzbmatrix'] = int(NZBMATRIX)
    new_config['NZBMatrix']['nzbmatrix_username'] = NZBMATRIX_USERNAME
    new_config['NZBMatrix']['nzbmatrix_apikey'] = NZBMATRIX_APIKEY

    new_config['Newznab'] = {}
    new_config['Newznab']['newznab'] = int(NEWZNAB)
    new_config['Newznab']['newznab_host'] = NEWZNAB_HOST
    new_config['Newznab']['newznab_apikey'] = NEWZNAB_APIKEY

    new_config['NZBsorg'] = {}
    new_config['NZBsorg']['nzbsorg'] = int(NZBSORG)
    new_config['NZBsorg']['nzbsorg_uid'] = NZBSORG_UID
    new_config['NZBsorg']['nzbsorg_hash'] = NZBSORG_HASH

    new_config['Newzbin'] = {}
    new_config['Newzbin']['newzbin'] = int(NEWZBIN)
    new_config['Newzbin']['newzbin_uid'] = NEWZBIN_UID
    new_config['Newzbin']['newzbin_password'] = NEWZBIN_PASSWORD

    new_config['Prowl'] = {}
    new_config['Prowl']['prowl_enabled'] = int(PROWL_ENABLED)
    new_config['Prowl']['prowl_keys'] = PROWL_KEYS
    new_config['Prowl']['prowl_onsnatch'] = int(PROWL_ONSNATCH)
    new_config['Prowl']['prowl_priority'] = int(PROWL_PRIORITY)

    new_config['XBMC'] = {}
    new_config['XBMC']['xbmc_enabled'] = int(XBMC_ENABLED)
    new_config['XBMC']['xbmc_host'] = XBMC_HOST
    new_config['XBMC']['xbmc_username'] = XBMC_USERNAME
    new_config['XBMC']['xbmc_password'] = XBMC_PASSWORD
    new_config['XBMC']['xbmc_update'] = int(XBMC_UPDATE)
    new_config['XBMC']['xbmc_notify'] = int(XBMC_NOTIFY)

    new_config['NMA'] = {}
    new_config['NMA']['nma_enabled'] = int(NMA_ENABLED)
    new_config['NMA']['nma_apikey'] = NMA_APIKEY
    new_config['NMA']['nma_priority'] = NMA_PRIORITY

    new_config['General']['lastfm_username'] = LASTFM_USERNAME
    new_config['General']['interface'] = INTERFACE
    new_config['General']['folder_permissions'] = FOLDER_PERMISSIONS

    new_config['General']['music_encoder'] = int(MUSIC_ENCODER)
    new_config['General']['encoder'] = ENCODER
    new_config['General']['bitrate'] = int(BITRATE)
    new_config['General']['samplingfrequency'] = int(SAMPLINGFREQUENCY)
    new_config['General']['encoderfolder'] = ENCODERFOLDER
    new_config['General']['advancedencoder'] = ADVANCEDENCODER
    new_config['General']['encoderoutputformat'] = ENCODEROUTPUTFORMAT
    new_config['General']['encoderquality'] = ENCODERQUALITY
    new_config['General']['encodervbrcbr'] = ENCODERVBRCBR
    new_config['General']['encoderlossless'] = ENCODERLOSSLESS

    new_config['General']['mirror'] = MIRROR
    new_config['General']['customhost'] = CUSTOMHOST
    new_config['General']['customport'] = CUSTOMPORT
    new_config['General']['customsleep'] = CUSTOMSLEEP
    new_config['General']['hpuser'] = HPUSER
    new_config['General']['hppass'] = HPPASS

    new_config.write()
示例#22
0
    def start(self):
        # do some preliminary stuff
        sickbeard.MY_FULLNAME = os.path.normpath(os.path.abspath(__file__))
        sickbeard.MY_NAME = os.path.basename(sickbeard.MY_FULLNAME)
        sickbeard.PROG_DIR = os.path.dirname(sickbeard.MY_FULLNAME)
        sickbeard.DATA_DIR = sickbeard.PROG_DIR
        sickbeard.MY_ARGS = sys.argv[1:]
        sickbeard.SYS_ENCODING = None

        try:
            locale.setlocale(locale.LC_ALL, '')
        except (locale.Error, IOError):
            pass
        try:
            sickbeard.SYS_ENCODING = locale.getpreferredencoding()
        except (locale.Error, IOError):
            pass

        # For OSes that are poorly configured I'll just randomly force UTF-8
        if not sickbeard.SYS_ENCODING or sickbeard.SYS_ENCODING in (
                'ANSI_X3.4-1968', 'US-ASCII', 'ASCII'):
            sickbeard.SYS_ENCODING = 'UTF-8'

        if not hasattr(sys, 'setdefaultencoding'):
            moves.reload_module(sys)

        try:
            # pylint: disable=E1101
            # On non-unicode builds this raises an AttributeError, if encoding type is not valid it throws a LookupError
            sys.setdefaultencoding(sickbeard.SYS_ENCODING)
        except (StandardError, Exception):
            print(
                'Sorry, you MUST add the SickGear folder to the PYTHONPATH environment variable'
            )
            print(
                'or find another way to force Python to use %s for string encoding.'
                % sickbeard.SYS_ENCODING)
            sys.exit(1)

        # Need console logging for sickgear.py and SickBeard-console.exe
        self.console_logging = (not hasattr(
            sys, 'frozen')) or (sickbeard.MY_NAME.lower().find('-console') > 0)

        # Rename the main thread
        threading.currentThread().name = 'MAIN'

        try:
            opts, args = getopt.getopt(sys.argv[1:], 'hfqdsp::', [
                'help', 'forceupdate', 'quiet', 'nolaunch', 'daemon',
                'systemd', 'pidfile=', 'port=', 'datadir=', 'config=',
                'noresize'
            ])  # @UnusedVariable
        except getopt.GetoptError:
            sys.exit(self.help_message())

        for o, a in opts:
            # Prints help message
            if o in ('-h', '--help'):
                sys.exit(self.help_message())

            # For now we'll just silence the logging
            if o in ('-q', '--quiet'):
                self.console_logging = False

            # Should we update (from indexer) all shows in the DB right away?
            if o in ('-f', '--forceupdate'):
                self.force_update = True

            # Suppress launching web browser
            # Needed for OSes without default browser assigned
            # Prevent duplicate browser window when restarting in the app
            if o in ('--nolaunch', ):
                self.no_launch = True

            # Override default/configured port
            if o in ('-p', '--port'):
                try:
                    self.forced_port = int(a)
                except ValueError:
                    sys.exit('Port: %s is not a number. Exiting.' % a)

            # Run as a double forked daemon
            if o in ('-d', '--daemon'):
                self.run_as_daemon = True
                # When running as daemon disable console_logging and don't start browser
                self.console_logging = False
                self.no_launch = True

                if 'win32' == sys.platform:
                    self.run_as_daemon = False

            # Run as a systemd service
            if o in ('-s', '--systemd') and 'win32' != sys.platform:
                self.run_as_systemd = True
                self.run_as_daemon = False
                self.console_logging = False
                self.no_launch = True

            # Write a pidfile if requested
            if o in ('--pidfile', ):
                self.create_pid = True
                self.pid_file = str(a)

                # If the pidfile already exists, sickbeard may still be running, so exit
                if os.path.exists(self.pid_file):
                    sys.exit('PID file: %s already exists. Exiting.' %
                             self.pid_file)

            # Specify folder to load the config file from
            if o in ('--config', ):
                sickbeard.CONFIG_FILE = os.path.abspath(a)

            # Specify folder to use as the data dir
            if o in ('--datadir', ):
                sickbeard.DATA_DIR = os.path.abspath(a)

            # Prevent resizing of the banner/posters even if PIL is installed
            if o in ('--noresize', ):
                sickbeard.NO_RESIZE = True

        # The pidfile is only useful in daemon mode, make sure we can write the file properly
        if self.create_pid:
            if self.run_as_daemon:
                pid_dir = os.path.dirname(self.pid_file)
                if not os.access(pid_dir, os.F_OK):
                    sys.exit(u"PID dir: %s doesn't exist. Exiting." % pid_dir)
                if not os.access(pid_dir, os.W_OK):
                    sys.exit(
                        u'PID dir: %s must be writable (write permissions). Exiting.'
                        % pid_dir)

            else:
                if self.console_logging:
                    print(
                        u'Not running in daemon mode. PID file creation disabled'
                    )

                self.create_pid = False

        # If they don't specify a config file then put it in the data dir
        if not sickbeard.CONFIG_FILE:
            sickbeard.CONFIG_FILE = os.path.join(sickbeard.DATA_DIR,
                                                 'config.ini')

        # Make sure that we can create the data dir
        if not os.access(sickbeard.DATA_DIR, os.F_OK):
            try:
                os.makedirs(sickbeard.DATA_DIR, 0o744)
            except os.error:
                sys.exit(u'Unable to create data directory: %s Exiting.' %
                         sickbeard.DATA_DIR)

        # Make sure we can write to the data dir
        if not os.access(sickbeard.DATA_DIR, os.W_OK):
            sys.exit(
                u'Data directory: %s must be writable (write permissions). Exiting.'
                % sickbeard.DATA_DIR)

        # Make sure we can write to the config file
        if not os.access(sickbeard.CONFIG_FILE, os.W_OK):
            if os.path.isfile(sickbeard.CONFIG_FILE):
                sys.exit(
                    u'Config file: %s must be writeable (write permissions). Exiting.'
                    % sickbeard.CONFIG_FILE)
            elif not os.access(os.path.dirname(sickbeard.CONFIG_FILE),
                               os.W_OK):
                sys.exit(
                    u'Config file directory: %s must be writeable (write permissions). Exiting'
                    % os.path.dirname(sickbeard.CONFIG_FILE))
        os.chdir(sickbeard.DATA_DIR)

        if self.console_logging:
            print(u'Starting up SickGear from %s' % sickbeard.CONFIG_FILE)

        # Load the config and publish it to the sickbeard package
        if not os.path.isfile(sickbeard.CONFIG_FILE):
            print(u'Unable to find "%s", all settings will be default!' %
                  sickbeard.CONFIG_FILE)

        sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)
        try:
            stack_size = int(sickbeard.CFG['General']['stack_size'])
        except (StandardError, Exception):
            stack_size = None

        if stack_size:
            try:
                threading.stack_size(stack_size)
            except (StandardError, Exception) as er:
                print('Stack Size %s not set: %s' % (stack_size, er.message))

        if self.run_as_daemon:
            self.daemonize()

        # Get PID
        sickbeard.PID = os.getpid()

        # Initialize the config
        sickbeard.initialize(console_logging=self.console_logging)

        if self.forced_port:
            logger.log(u'Forcing web server to port %s' % self.forced_port)
            self.start_port = self.forced_port
        else:
            self.start_port = sickbeard.WEB_PORT

        if sickbeard.WEB_LOG:
            self.log_dir = sickbeard.LOG_DIR
        else:
            self.log_dir = None

        # sickbeard.WEB_HOST is available as a configuration value in various
        # places but is not configurable. It is supported here for historic reasons.
        if sickbeard.WEB_HOST and sickbeard.WEB_HOST != '0.0.0.0':
            self.webhost = sickbeard.WEB_HOST
        else:
            self.webhost = (('0.0.0.0', '::')[sickbeard.WEB_IPV6],
                            '')[sickbeard.WEB_IPV64]

        # web server options
        self.web_options = dict(
            host=self.webhost,
            port=int(self.start_port),
            web_root=sickbeard.WEB_ROOT,
            data_root=os.path.join(sickbeard.PROG_DIR, 'gui',
                                   sickbeard.GUI_NAME),
            log_dir=self.log_dir,
            username=sickbeard.WEB_USERNAME,
            password=sickbeard.WEB_PASSWORD,
            handle_reverse_proxy=sickbeard.HANDLE_REVERSE_PROXY,
            enable_https=False,
            https_cert=None,
            https_key=None,
        )
        if sickbeard.ENABLE_HTTPS:
            self.web_options.update(
                dict(enable_https=sickbeard.ENABLE_HTTPS,
                     https_cert=os.path.join(sickbeard.PROG_DIR,
                                             sickbeard.HTTPS_CERT),
                     https_key=os.path.join(sickbeard.PROG_DIR,
                                            sickbeard.HTTPS_KEY)))

        # start web server
        try:
            # used to check if existing SG instances have been started
            sickbeard.helpers.wait_for_free_port(
                sickbeard.WEB_IPV6 and '::1' or self.web_options['host'],
                self.web_options['port'])

            self.webserver = WebServer(self.web_options)
            self.webserver.start()
            sickbeard.started = True
        except (StandardError, Exception):
            logger.log(
                u'Unable to start web server, is something else running on port %d?'
                % self.start_port, logger.ERROR)
            if self.run_as_systemd:
                self.exit(0)
            if sickbeard.LAUNCH_BROWSER and not self.no_launch:
                logger.log(u'Launching browser and exiting', logger.ERROR)
                sickbeard.launch_browser(self.start_port)
            self.exit(1)

        # Launch browser
        if sickbeard.LAUNCH_BROWSER and not self.no_launch:
            sickbeard.launch_browser(self.start_port)

        # check all db versions
        for d, min_v, max_v, base_v, mo in [
            ('failed.db', sickbeard.failed_db.MIN_DB_VERSION,
             sickbeard.failed_db.MAX_DB_VERSION,
             sickbeard.failed_db.TEST_BASE_VERSION, 'FailedDb'),
            ('cache.db', sickbeard.cache_db.MIN_DB_VERSION,
             sickbeard.cache_db.MAX_DB_VERSION,
             sickbeard.cache_db.TEST_BASE_VERSION, 'CacheDb'),
            ('sickbeard.db', sickbeard.mainDB.MIN_DB_VERSION,
             sickbeard.mainDB.MAX_DB_VERSION,
             sickbeard.mainDB.TEST_BASE_VERSION, 'MainDb')
        ]:
            cur_db_version = db.DBConnection(d).checkDBVersion()

            # handling of standalone TEST db versions
            load_msg = 'Downgrading %s to production version' % d
            if cur_db_version >= 100000 and cur_db_version != max_v:
                sickbeard.classes.loading_msg.set_msg_progress(
                    load_msg, 'Rollback')
                print(
                    'Your [%s] database version (%s) is a test db version and doesn\'t match SickGear required '
                    'version (%s), downgrading to production db' %
                    (d, cur_db_version, max_v))
                self.execute_rollback(mo, max_v, load_msg)
                cur_db_version = db.DBConnection(d).checkDBVersion()
                if cur_db_version >= 100000:
                    print(u'Rollback to production failed.')
                    sys.exit(
                        u'If you have used other forks, your database may be unusable due to their changes'
                    )
                if 100000 <= max_v and None is not base_v:
                    max_v = base_v  # set max_v to the needed base production db for test_db
                print(u'Rollback to production of [%s] successful.' % d)
                sickbeard.classes.loading_msg.set_msg_progress(
                    load_msg, 'Finished')

            # handling of production db versions
            if 0 < cur_db_version < 100000:
                if cur_db_version < min_v:
                    print(
                        u'Your [%s] database version (%s) is too old to migrate from with this version of SickGear'
                        % (d, cur_db_version))
                    sys.exit(u'Upgrade using a previous version of SG first,' +
                             u' or start with no database file to begin fresh')
                if cur_db_version > max_v:
                    sickbeard.classes.loading_msg.set_msg_progress(
                        load_msg, 'Rollback')
                    print(
                        u'Your [%s] database version (%s) has been incremented past'
                        u' what this version of SickGear supports. Trying to rollback now. Please wait...'
                        % (d, cur_db_version))
                    self.execute_rollback(mo, max_v, load_msg)
                    if db.DBConnection(d).checkDBVersion() > max_v:
                        print(u'Rollback failed.')
                        sys.exit(
                            u'If you have used other forks, your database may be unusable due to their changes'
                        )
                    print(u'Rollback of [%s] successful.' % d)
                    sickbeard.classes.loading_msg.set_msg_progress(
                        load_msg, 'Finished')

        # free memory
        global rollback_loaded
        rollback_loaded = None
        sickbeard.classes.loading_msg.message = 'Init SickGear'

        # Initialize the threads and other stuff
        sickbeard.initialize(console_logging=self.console_logging)

        # Check if we need to perform a restore first
        restore_dir = os.path.join(sickbeard.DATA_DIR, 'restore')
        if os.path.exists(restore_dir):
            sickbeard.classes.loading_msg.message = 'Restoring files'
            if self.restore(restore_dir, sickbeard.DATA_DIR):
                logger.log(u'Restore successful...')
            else:
                logger.log_error_and_exit(u'Restore FAILED!')

        # Build from the DB to start with
        sickbeard.classes.loading_msg.message = 'Loading shows from db'
        self.load_shows_from_db()

        # Fire up all our threads
        sickbeard.classes.loading_msg.message = 'Starting threads'
        sickbeard.start()

        # Build internal name cache
        sickbeard.classes.loading_msg.message = 'Build name cache'
        name_cache.buildNameCache()

        # refresh network timezones
        sickbeard.classes.loading_msg.message = 'Checking network timezones'
        network_timezones.update_network_dict()

        # load all ids from xem
        sickbeard.classes.loading_msg.message = 'Loading xem data'
        startup_background_tasks = threading.Thread(
            name='FETCH-XEMDATA',
            target=sickbeard.scene_exceptions.get_xem_ids)
        startup_background_tasks.start()

        sickbeard.classes.loading_msg.message = 'Checking history'
        # check history snatched_proper update
        if not db.DBConnection().has_flag('history_snatch_proper'):
            # noinspection PyUnresolvedReferences
            history_snatched_proper_task = threading.Thread(
                name='UPGRADE-HISTORY-ACTION',
                target=sickbeard.history.history_snatched_proper_fix)
            history_snatched_proper_task.start()

        if sickbeard.USE_FAILED_DOWNLOADS:
            failed_history.remove_old_history()

        # Start an update if we're supposed to
        if self.force_update or sickbeard.UPDATE_SHOWS_ON_START:
            sickbeard.classes.loading_msg.message = 'Starting a forced show update'
            sickbeard.showUpdateScheduler.action.run(
                force=True)  # @UndefinedVariable

        sickbeard.classes.loading_msg.message = 'Switching to default web server'
        time.sleep(2)
        self.webserver.switch_handlers()

        # # Launch browser
        # if sickbeard.LAUNCH_BROWSER and not self.no_launch:
        #     sickbeard.launch_browser(self.start_port)

        # main loop
        while True:
            time.sleep(1)
示例#23
0
 def setUp(self):
     sickbeard.CONFIG_FILE = "../config.ini"
     sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)
     sickbeard.initialize(consoleLogging=False)
示例#24
0
文件: settings.py 项目: hjone72/mylar
    def save(self):
        new_config = ConfigObj()
        new_config.filename = self.settings_file

        new_config.encoding = 'UTF8'
        new_config['settings'] = {}
        new_config['settings'][
            'check_for_new_version'] = self.check_for_new_version
        new_config['settings']['rar_exe_path'] = self.rar_exe_path
        new_config['settings']['unrar_exe_path'] = self.unrar_exe_path
        new_config['settings']['send_usage_stats'] = self.send_usage_stats

        new_config.write()
        new_config['auto'] = {}
        new_config['auto']['install_id'] = self.install_id
        new_config['auto'][
            'last_selected_load_data_style'] = self.last_selected_load_data_style
        new_config['auto'][
            'last_selected_save_data_style'] = self.last_selected_save_data_style
        new_config['auto']['last_opened_folder'] = self.last_opened_folder
        new_config['auto'][
            'last_main_window_width'] = self.last_main_window_width
        new_config['auto'][
            'last_main_window_height'] = self.last_main_window_height
        new_config['auto']['last_main_window_x'] = self.last_main_window_x
        new_config['auto']['last_main_window_y'] = self.last_main_window_y
        new_config['auto']['last_form_side_width'] = self.last_form_side_width
        new_config['auto']['last_list_side_width'] = self.last_list_side_width
        new_config['auto'][
            'last_filelist_sorted_column'] = self.last_filelist_sorted_column
        new_config['auto'][
            'last_filelist_sorted_order'] = self.last_filelist_sorted_order

        new_config['identifier'] = {}
        new_config['identifier'][
            'id_length_delta_thresh'] = self.id_length_delta_thresh
        new_config['identifier'][
            'id_publisher_blacklist'] = self.id_publisher_blacklist

        new_config['dialogflags'] = {}
        new_config['dialogflags'][
            'ask_about_cbi_in_rar'] = self.ask_about_cbi_in_rar
        new_config['dialogflags']['show_disclaimer'] = self.show_disclaimer
        new_config['dialogflags'][
            'dont_notify_about_this_version'] = self.dont_notify_about_this_version
        new_config['dialogflags'][
            'ask_about_usage_stats'] = self.ask_about_usage_stats
        new_config['dialogflags'][
            'show_no_unrar_warning'] = self.show_no_unrar_warning

        new_config['filenameparser'] = {}
        new_config['filenameparser']['parse_scan_info'] = self.parse_scan_info

        new_config['comicvine'] = {}
        new_config['comicvine'][
            'use_series_start_as_volume'] = self.use_series_start_as_volume
        new_config['comicvine'][
            'clear_form_before_populating_from_cv'] = self.clear_form_before_populating_from_cv
        new_config['comicvine']['remove_html_tables'] = self.remove_html_tables
        new_config['comicvine']['cv_api_key'] = self.cv_api_key

        new_config['cbl_transform'] = {}
        new_config['cbl_transform'][
            'assume_lone_credit_is_primary'] = self.assume_lone_credit_is_primary
        new_config['cbl_transform'][
            'copy_characters_to_tags'] = self.copy_characters_to_tags
        new_config['cbl_transform'][
            'copy_teams_to_tags'] = self.copy_teams_to_tags
        new_config['cbl_transform'][
            'copy_locations_to_tags'] = self.copy_locations_to_tags
        new_config['cbl_transform'][
            'copy_storyarcs_to_tags'] = self.copy_storyarcs_to_tags
        new_config['cbl_transform'][
            'copy_notes_to_comments'] = self.copy_notes_to_comments
        new_config['cbl_transform'][
            'copy_weblink_to_comments'] = self.copy_weblink_to_comments
        new_config['cbl_transform'][
            'apply_cbl_transform_on_cv_import'] = self.apply_cbl_transform_on_cv_import
        new_config['cbl_transform'][
            'apply_cbl_transform_on_bulk_operation'] = self.apply_cbl_transform_on_bulk_operation

        new_config['rename'] = {}
        new_config['rename']['rename_template'] = self.rename_template
        new_config['rename'][
            'rename_issue_number_padding'] = self.rename_issue_number_padding
        new_config['rename'][
            'rename_use_smart_string_cleanup'] = self.rename_use_smart_string_cleanup
        new_config['rename'][
            'rename_extension_based_on_archive'] = self.rename_extension_based_on_archive

        new_config['autotag'] = {}
        new_config['autotag'][
            'save_on_low_confidence'] = self.save_on_low_confidence
        new_config['autotag'][
            'dont_use_year_when_identifying'] = self.dont_use_year_when_identifying
        new_config['autotag'][
            'assume_1_if_no_issue_num'] = self.assume_1_if_no_issue_num
        new_config['autotag'][
            'ignore_leading_numbers_in_filename'] = self.ignore_leading_numbers_in_filename
        new_config['autotag'][
            'remove_archive_after_successful_match'] = self.remove_archive_after_successful_match
        new_config['autotag'][
            'wait_and_retry_on_rate_limit'] = self.wait_and_retry_on_rate_limit
示例#25
0
    try:
        funrar                        = xbmc.translatePath(pPylib + '/multiarch/unrar.' + parch)
        xbmcvfs.copy(funrar, punrar)
        os.chmod(punrar, 0755)
        xbmc.log('SickPotatoHead: Copied unrar for ' + parch, level=xbmc.LOGDEBUG)
    except Exception, e:
        xbmc.log('SickPotatoHead: Error Copying unrar for ' + parch, level=xbmc.LOGERROR)
        xbmc.log(str(e), level=xbmc.LOGERROR)

os.environ['PYTHONPATH'] = str(os.environ.get('PYTHONPATH')) + ':' + pPylib

# SickBeard start
try:
    # write SickBeard settings
    # ------------------------
    sickBeardConfig = ConfigObj(pSickBeardSettings, create_empty=True)
    defaultConfig = ConfigObj()
    defaultConfig['General'] = {}
    defaultConfig['General']['launch_browser']      = '0'
    defaultConfig['General']['version_notify']      = '0'
    defaultConfig['General']['web_port']            = '8082'
    defaultConfig['General']['web_host']            = host
    defaultConfig['General']['web_username']        = user
    defaultConfig['General']['web_password']        = pwd
    defaultConfig['General']['cache_dir']           = __addonhome__ + 'sbcache'
    defaultConfig['General']['log_dir']             = __addonhome__ + 'logs'
    defaultConfig['XBMC'] = {}
    defaultConfig['XBMC']['use_xbmc']               = '1'
    defaultConfig['XBMC']['xbmc_host']              = 'localhost:' + xbmcPort
    defaultConfig['XBMC']['xbmc_username']          = xbmcUser
    defaultConfig['XBMC']['xbmc_password']          = xbmcPwd
示例#26
0
def main():
    """
    TV for me
    """

    # do some preliminary stuff
    sickbeard.MY_FULLNAME = os.path.normpath(os.path.abspath(__file__))
    sickbeard.MY_NAME = os.path.basename(sickbeard.MY_FULLNAME)
    sickbeard.PROG_DIR = os.path.dirname(sickbeard.MY_FULLNAME)
    sickbeard.DATA_DIR = sickbeard.PROG_DIR
    sickbeard.MY_ARGS = sys.argv[1:]
    sickbeard.DAEMON = False
    sickbeard.CREATEPID = False

    sickbeard.SYS_ENCODING = None

    try:
        locale.setlocale(locale.LC_ALL, "")
        sickbeard.SYS_ENCODING = locale.getpreferredencoding()
    except (locale.Error, IOError):
        pass

    # For OSes that are poorly configured I'll just randomly force UTF-8
    if not sickbeard.SYS_ENCODING or sickbeard.SYS_ENCODING in (
            'ANSI_X3.4-1968', 'US-ASCII', 'ASCII'):
        sickbeard.SYS_ENCODING = 'UTF-8'

    if not hasattr(sys, "setdefaultencoding"):
        reload(sys)

    try:
        # pylint: disable=E1101
        # On non-unicode builds this will raise an AttributeError, if encoding type is not valid it throws a LookupError
        sys.setdefaultencoding(sickbeard.SYS_ENCODING)
    except:
        sys.exit(
            "Sorry, you MUST add the Sick Beard folder to the PYTHONPATH environment variable\n"
            + "or find another way to force Python to use " +
            sickbeard.SYS_ENCODING + " for string encoding.")

    # Need console logging for SickBeard.py and SickBeard-console.exe
    consoleLogging = (not hasattr(
        sys, "frozen")) or (sickbeard.MY_NAME.lower().find('-console') > 0)

    # Rename the main thread
    threading.currentThread().name = "MAIN"

    try:
        opts, args = getopt.getopt(sys.argv[1:], "hfqda:p::", [
            'help', 'forceupdate', 'quiet', 'nolaunch', 'daemon', 'pidfile=',
            'addr=', 'port=', 'datadir=', 'config=', 'noresize'
        ])  # @UnusedVariable
    except getopt.GetoptError:
        sys.exit(help_message())

    forceUpdate = False
    forcedHost = None
    forcedPort = None
    noLaunch = False

    for o, a in opts:

        # Prints help message
        if o in ('-h', '--help'):
            sys.exit(help_message())

        # Should we update (from tvdb) all shows in the DB right away?
        if o in ('-f', '--forceupdate'):
            forceUpdate = True

        # Disables logging to console
        if o in ('-q', '--quiet'):
            consoleLogging = False

        # Suppress launching web browser
        # Needed for OSes without default browser assigned
        # Prevent duplicate browser window when restarting in the app
        if o in ('--nolaunch', ):
            noLaunch = True

        # Run as a double forked daemon
        if o in ('-d', '--daemon'):
            sickbeard.DAEMON = True
            # When running as daemon disable consoleLogging and don't start browser
            consoleLogging = False
            noLaunch = True

            if sys.platform == 'win32':
                sickbeard.DAEMON = False

        # Write a pidfile if requested
        if o in ('--pidfile', ):
            sickbeard.CREATEPID = True
            sickbeard.PIDFILE = str(a)

            # If the pidfile already exists, sickbeard may still be running, so exit
            if os.path.exists(sickbeard.PIDFILE):
                sys.exit("PID file: " + sickbeard.PIDFILE +
                         " already exists. Exiting.")

        # Override default/configured port
        if o in ('-p', '--port'):
            try:
                forcedPort = int(a)
            except ValueError:
                sys.exit("Port: " + str(a) + " is not a number. Exiting.")

        # Override default/configured host
        if o in ('-a', '--addr'):
            try:
                forcedHost = str(a)
            except ValueError:
                sys.exit("Host: " + str(a) + " is not a string. Exiting.")

        # Specify folder to use as data dir (storing database, configfile, cache, logfiles)
        if o in ('--datadir', ):
            sickbeard.DATA_DIR = os.path.abspath(a)

        # Specify filename to load the config information from
        if o in ('--config', ):
            sickbeard.CONFIG_FILE = os.path.abspath(a)

        # Prevent resizing of the banner/posters even if PIL is installed
        if o in ('--noresize', ):
            sickbeard.NO_RESIZE = True

    # The pidfile is only useful in daemon mode, make sure we can write the file properly
    if sickbeard.CREATEPID:
        if sickbeard.DAEMON:
            pid_dir = os.path.dirname(sickbeard.PIDFILE)
            if not os.access(pid_dir, os.F_OK):
                sys.exit("PID dir: " + pid_dir + " doesn't exist. Exiting.")
            if not os.access(pid_dir, os.W_OK):
                sys.exit("PID dir: " + pid_dir +
                         " must be writable (write permissions). Exiting.")

        else:
            if consoleLogging:
                sys.stdout.write(
                    "Not running in daemon mode. PID file creation disabled.\n"
                )

            sickbeard.CREATEPID = False

    # If they don't specify a config file then put it in the data dir
    if not sickbeard.CONFIG_FILE:
        sickbeard.CONFIG_FILE = os.path.join(sickbeard.DATA_DIR, "config.ini")

    # Make sure that we can create the data dir
    if not os.access(sickbeard.DATA_DIR, os.F_OK):
        try:
            os.makedirs(sickbeard.DATA_DIR, 0744)
        except os.error:
            sys.exit("Unable to create data directory: " + sickbeard.DATA_DIR +
                     " Exiting.")

    # Make sure we can write to the data dir
    if not os.access(sickbeard.DATA_DIR, os.W_OK):
        sys.exit("Data directory: " + sickbeard.DATA_DIR +
                 " must be writable (write permissions). Exiting.")

    # Make sure we can write to the config file
    if not os.access(sickbeard.CONFIG_FILE, os.W_OK):
        if os.path.isfile(sickbeard.CONFIG_FILE):
            sys.exit("Config file: " + sickbeard.CONFIG_FILE +
                     " must be writeable (write permissions). Exiting.")
        elif not os.access(os.path.dirname(sickbeard.CONFIG_FILE), os.W_OK):
            sys.exit("Config file directory: " +
                     os.path.dirname(sickbeard.CONFIG_FILE) +
                     " must be writeable (write permissions). Exiting")

    os.chdir(sickbeard.DATA_DIR)

    if consoleLogging:
        sys.stdout.write("Starting up Sick Beard " + SICKBEARD_VERSION + "\n")
        if not os.path.isfile(sickbeard.CONFIG_FILE):
            sys.stdout.write("Unable to find '" + sickbeard.CONFIG_FILE +
                             "' , all settings will be default!" + "\n")

    # Load the config and publish it to the sickbeard package
    sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)

    # Initialize the config and our threads
    sickbeard.initialize(consoleLogging=consoleLogging)

    sickbeard.showList = []

    if sickbeard.DAEMON:
        daemonize()

    # Use this PID for everything
    sickbeard.PID = os.getpid()

    if forcedPort:
        logger.log(u"Forcing web server to port " + str(forcedPort))
        startPort = forcedPort
    else:
        startPort = sickbeard.WEB_PORT

    if sickbeard.WEB_LOG:
        log_dir = sickbeard.LOG_DIR
    else:
        log_dir = None

    # sickbeard.WEB_HOST is available as a configuration value in various
    # places but is not configurable. It is supported here for historic reasons.
    if sickbeard.WEB_HOST and sickbeard.WEB_HOST != '0.0.0.0':
        webhost = sickbeard.WEB_HOST
    else:
        if sickbeard.WEB_IPV6:
            webhost = '::'
        else:
            webhost = '127.0.0.1'

    if forcedHost:
        logger.log(u"Forcing web server to address " + str(forcedHost))
        webhost = forcedHost

    try:
        initWebServer({
            'port': startPort,
            'host': webhost,
            'data_root': os.path.join(sickbeard.PROG_DIR, 'data'),
            'web_root': sickbeard.WEB_ROOT,
            'log_dir': log_dir,
            'username': sickbeard.WEB_USERNAME,
            'password': sickbeard.WEB_PASSWORD,
            'enable_https': sickbeard.ENABLE_HTTPS,
            'https_cert': sickbeard.HTTPS_CERT,
            'https_key': sickbeard.HTTPS_KEY,
        })
    except IOError:
        logger.log(
            u"Unable to start web server, is something else running on port: "
            + str(startPort), logger.ERROR)
        if sickbeard.LAUNCH_BROWSER and not sickbeard.DAEMON:
            logger.log(u"Launching browser and exiting", logger.ERROR)
            sickbeard.launchBrowser(webhost, startPort)
        sys.exit(
            "Unable to start web server, is something else running on port: " +
            str(startPort))

    # Build from the DB to start with
    logger.log(u"Loading initial show list")
    loadShowsFromDB()

    # Fire up all our threads
    sickbeard.start()

    # Launch browser if we're supposed to
    if sickbeard.LAUNCH_BROWSER and not noLaunch and not sickbeard.DAEMON:
        sickbeard.launchBrowser(webhost, startPort)

    # Start an update if we're supposed to
    if forceUpdate:
        sickbeard.showUpdateScheduler.action.run(
            force=True)  # @UndefinedVariable

    # Stay alive while my threads do the work
    while (True):

        if sickbeard.invoked_command:
            sickbeard.invoked_command()
            sickbeard.invoked_command = None

        time.sleep(1)

    return
示例#27
0
def config_write():
    new_config = ConfigObj()
    new_config.filename = CONFIGFILE

    new_config['General'] = {}
    new_config['General']['http_port'] = HTTP_PORT
    new_config['General']['http_host'] = HTTP_HOST
    new_config['General']['http_user'] = HTTP_USER
    new_config['General']['http_pass'] = HTTP_PASS
    new_config['General']['http_root'] = HTTP_ROOT
    new_config['General']['http_look'] = HTTP_LOOK
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    new_config['General']['proxy_host'] = PROXY_HOST
    new_config['General']['proxy_type'] = PROXY_TYPE
    new_config['General']['logdir'] = LOGDIR
    new_config['General']['loglevel'] = int(LOGLEVEL)

    new_config['General']['match_ratio'] = int(MATCH_RATIO)

    new_config['General']['imp_onlyisbn'] = int(IMP_ONLYISBN)
    new_config['General']['imp_singlebook'] = int(IMP_SINGLEBOOK)
    new_config['General']['imp_preflang'] = IMP_PREFLANG
    new_config['General']['imp_monthlang'] = IMP_MONTHLANG
    new_config['General']['imp_autoadd'] = IMP_AUTOADD

    new_config['General']['ebook_type'] = EBOOK_TYPE

    new_config['Git'] = {}
    new_config['Git']['git_user'] = GIT_USER
    new_config['Git']['git_repo'] = GIT_REPO
    new_config['Git']['git_branch'] = GIT_BRANCH
    new_config['Git']['install_type'] = INSTALL_TYPE
    new_config['Git']['current_version'] = CURRENT_VERSION
    new_config['Git']['latest_version'] = LATEST_VERSION
    new_config['Git']['commits_behind'] = COMMITS_BEHIND

    new_config['USENET'] = {}
    new_config['USENET']['nzb_downloader_sabnzbd'] = int(NZB_DOWNLOADER_SABNZBD)
    new_config['USENET']['nzb_downloader_nzbget'] = int(NZB_DOWNLOADER_NZBGET)
    new_config['USENET']['nzb_downloader_blackhole'] = int(NZB_DOWNLOADER_BLACKHOLE)
    new_config['USENET']['nzb_blackholedir'] = NZB_BLACKHOLEDIR
    new_config['USENET']['usenet_retention'] = USENET_RETENTION

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['sab_host'] = SAB_HOST
    new_config['SABnzbd']['sab_port'] = SAB_PORT
    new_config['SABnzbd']['sab_subdir'] = SAB_SUBDIR
    new_config['SABnzbd']['sab_user'] = SAB_USER
    new_config['SABnzbd']['sab_pass'] = SAB_PASS
    new_config['SABnzbd']['sab_api'] = SAB_API
    new_config['SABnzbd']['sab_cat'] = SAB_CAT

    new_config['NZBGet'] = {}
    new_config['NZBGet']['nzbget_host'] = NZBGET_HOST
    new_config['NZBGet']['nzbget_user'] = NZBGET_USER
    new_config['NZBGet']['nzbget_pass'] = NZBGET_PASS
    new_config['NZBGet']['nzbget_cat'] = NZBGET_CATEGORY
    new_config['NZBGet']['nzbget_priority'] = NZBGET_PRIORITY

    new_config['General']['destination_dir'] = DESTINATION_DIR
    new_config['General']['destination_copy'] = int(DESTINATION_COPY)
    new_config['General']['download_dir'] = DOWNLOAD_DIR

    new_config['DLMethod'] = {}
    new_config['DLMethod']['use_tor'] = int(USE_TOR)
    new_config['DLMethod']['use_nzb'] = int(USE_NZB)

    new_config['API'] = {}
    new_config['API']['book_api'] = BOOK_API
    new_config['API']['gr_api'] = GR_API
    new_config['API']['gb_api'] = GB_API

    new_config['NZBMatrix'] = {}
    new_config['NZBMatrix']['nzbmatrix'] = int(NZBMATRIX)
    new_config['NZBMatrix']['nzbmatrix_user'] = NZBMATRIX_USER
    new_config['NZBMatrix']['nzbmatrix_api'] = NZBMATRIX_API

    new_config['Newznab0'] = {}
    new_config['Newznab0']['newznab0'] = int(NEWZNAB0)
    new_config['Newznab0']['newznab_host0'] = NEWZNAB_HOST0
    new_config['Newznab0']['newznab_api0'] = NEWZNAB_API0

    new_config['Newznab1'] = {}
    new_config['Newznab1']['newznab1'] = int(NEWZNAB1)
    new_config['Newznab1']['newznab_host1'] = NEWZNAB_HOST1
    new_config['Newznab1']['newznab_api1'] = NEWZNAB_API1

    new_config['Newznab2'] = {}
    new_config['Newznab2']['newznab2'] = int(NEWZNAB2)
    new_config['Newznab2']['newznab_host2'] = NEWZNAB_HOST2
    new_config['Newznab2']['newznab_api2'] = NEWZNAB_API2

    new_config['Newznab3'] = {}
    new_config['Newznab3']['newznab3'] = int(NEWZNAB3)
    new_config['Newznab3']['newznab_host3'] = NEWZNAB_HOST3
    new_config['Newznab3']['newznab_api3'] = NEWZNAB_API3

    new_config['Newznab4'] = {}
    new_config['Newznab4']['newznab4'] = int(NEWZNAB4)
    new_config['Newznab4']['newznab_host4'] = NEWZNAB_HOST4
    new_config['Newznab4']['newznab_api4'] = NEWZNAB_API4

    new_config['Torznab0'] = {}
    new_config['Torznab0']['torznab0'] = int(TORZNAB0)
    new_config['Torznab0']['torznab_host0'] = TORZNAB_HOST0
    new_config['Torznab0']['torznab_api0'] = TORZNAB_API0

    new_config['Torznab1'] = {}
    new_config['Torznab1']['torznab1'] = int(TORZNAB1)
    new_config['Torznab1']['torznab_host1'] = TORZNAB_HOST1
    new_config['Torznab1']['torznab_api1'] = TORZNAB_API1

    new_config['Torznab2'] = {}
    new_config['Torznab2']['torznab2'] = int(TORZNAB2)
    new_config['Torznab2']['torznab_host2'] = TORZNAB_HOST2
    new_config['Torznab2']['torznab_api2'] = TORZNAB_API2

    new_config['Torznab3'] = {}
    new_config['Torznab3']['torznab3'] = int(TORZNAB3)
    new_config['Torznab3']['torznab_host3'] = TORZNAB_HOST3
    new_config['Torznab3']['torznab_api3'] = TORZNAB_API3

    new_config['Torznab4'] = {}
    new_config['Torznab4']['torznab4'] = int(TORZNAB4)
    new_config['Torznab4']['torznab_host4'] = TORZNAB_HOST4
    new_config['Torznab4']['torznab_api4'] = TORZNAB_API4

    new_config['Newzbin'] = {}
    new_config['Newzbin']['newzbin'] = int(NEWZBIN)
    new_config['Newzbin']['newzbin_uid'] = NEWZBIN_UID
    new_config['Newzbin']['newzbin_pass'] = NEWZBIN_PASS

    new_config['TORRENT'] = {}
    new_config['TORRENT']['tor_downloader_blackhole'] = int(TOR_DOWNLOADER_BLACKHOLE)
    new_config['TORRENT']['tor_downloader_utorrent'] = int(TOR_DOWNLOADER_UTORRENT)
    new_config['TORRENT']['tor_downloader_transmission'] = int(TOR_DOWNLOADER_TRANSMISSION)
    new_config['TORRENT']['tor_downloader_deluge'] = int(TOR_DOWNLOADER_DELUGE)
    new_config['TORRENT']['numberofseeders'] = int(NUMBEROFSEEDERS)
    new_config['TORRENT']['torrent_dir'] = TORRENT_DIR

    new_config['UTORRENT'] = {}
    new_config['UTORRENT']['utorrent_host'] = UTORRENT_HOST
    new_config['UTORRENT']['utorrent_user'] = UTORRENT_USER
    new_config['UTORRENT']['utorrent_pass'] = UTORRENT_PASS
    new_config['UTORRENT']['utorrent_label'] = UTORRENT_LABEL

    new_config['TRANSMISSION'] = {}
    new_config['TRANSMISSION']['transmission_host'] = TRANSMISSION_HOST
    new_config['TRANSMISSION']['transmission_user'] = TRANSMISSION_USER
    new_config['TRANSMISSION']['transmission_pass'] = TRANSMISSION_PASS

    new_config['DELUGE'] = {}
    new_config['DELUGE']['deluge_host'] = DELUGE_HOST
    new_config['DELUGE']['deluge_port'] = DELUGE_PORT
    new_config['DELUGE']['deluge_user'] = DELUGE_USER
    new_config['DELUGE']['deluge_pass'] = DELUGE_PASS

    new_config['KAT'] = {}
    new_config['KAT']['kat'] = int(KAT)
    new_config['KAT']['kat_host'] = KAT_HOST

    new_config['SearchScan'] = {}
    new_config['SearchScan']['search_interval'] = int(SEARCH_INTERVAL)
    new_config['SearchScan']['scan_interval'] = int(SCAN_INTERVAL)
    new_config['SearchScan']['versioncheck_interval'] = int(VERSIONCHECK_INTERVAL)

    new_config['LibraryScan'] = {}
    new_config['LibraryScan']['full_scan'] = int(FULL_SCAN)
    new_config['LibraryScan']['add_author'] = int(ADD_AUTHOR)
    new_config['LibraryScan']['notfound_status'] = NOTFOUND_STATUS
    new_config['LibraryScan']['newbook_status'] = NEWBOOK_STATUS

    new_config['PostProcess'] = {}
    new_config['PostProcess']['ebook_dest_folder'] = EBOOK_DEST_FOLDER
    new_config['PostProcess']['ebook_dest_file'] = EBOOK_DEST_FILE
    new_config['PostProcess']['mag_dest_folder'] = MAG_DEST_FOLDER
    new_config['PostProcess']['mag_dest_file'] = MAG_DEST_FILE
    new_config['PostProcess']['mag_relative'] = int(MAG_RELATIVE)

    new_config['Twitter'] = {}
    new_config['Twitter']['use_twitter'] = int(USE_TWITTER)
    new_config['Twitter']['twitter_notify_onsnatch'] = int(TWITTER_NOTIFY_ONSNATCH)
    new_config['Twitter']['twitter_notify_ondownload'] = int(TWITTER_NOTIFY_ONDOWNLOAD)
    new_config['Twitter']['twitter_username'] = TWITTER_USERNAME
    new_config['Twitter']['twitter_password'] = TWITTER_PASSWORD
    new_config['Twitter']['twitter_prefix'] = TWITTER_PREFIX

    new_config['Boxcar'] = {}
    new_config['Boxcar']['use_boxcar'] = int(USE_BOXCAR)
    new_config['Boxcar']['boxcar_notify_onsnatch'] = int(BOXCAR_NOTIFY_ONSNATCH)
    new_config['Boxcar']['boxcar_notify_ondownload'] = int(BOXCAR_NOTIFY_ONDOWNLOAD)
    new_config['Boxcar']['boxcar_token'] = BOXCAR_TOKEN

    new_config['Pushbullet'] = {}
    new_config['Pushbullet']['use_pushbullet'] = int(USE_PUSHBULLET)
    new_config['Pushbullet']['pushbullet_notify_onsnatch'] = int(PUSHBULLET_NOTIFY_ONSNATCH)
    new_config['Pushbullet']['pushbullet_notify_ondownload'] = int(PUSHBULLET_NOTIFY_ONDOWNLOAD)
    new_config['Pushbullet']['pushbullet_token'] = PUSHBULLET_TOKEN
    new_config['Pushbullet']['pushbullet_deviceid'] = PUSHBULLET_DEVICEID

    new_config['Pushover'] = {}
    new_config['Pushover']['use_pushover'] = int(USE_PUSHOVER)
    new_config['Pushover']['pushover_onsnatch'] = int(PUSHOVER_ONSNATCH)
    new_config['Pushover']['pushover_ondownload'] = int(PUSHOVER_ONDOWNLOAD)
    new_config['Pushover']['pushover_priority'] = int(PUSHOVER_PRIORITY)
    new_config['Pushover']['pushover_keys'] = PUSHOVER_KEYS
    new_config['Pushover']['pushover_apitoken'] = PUSHOVER_APITOKEN

    new_config['AndroidPN'] = {}
    new_config['AndroidPN']['use_androidpn'] = int(USE_ANDROIDPN)
    new_config['AndroidPN']['androidpn_notify_onsnatch'] = int(ANDROIDPN_NOTIFY_ONSNATCH)
    new_config['AndroidPN']['androidpn_notify_ondownload'] = int(ANDROIDPN_NOTIFY_ONDOWNLOAD)
    new_config['AndroidPN']['androidpn_url'] = ANDROIDPN_URL
    new_config['AndroidPN']['androidpn_username'] = ANDROIDPN_USERNAME
    new_config['AndroidPN']['androidpn_broadcast'] = ANDROIDPN_BROADCAST

    new_config['NMA'] = {}
    new_config['NMA']['nma_enabled'] = int(NMA_ENABLED)
    new_config['NMA']['nma_apikey'] = NMA_APIKEY
    new_config['NMA']['nma_priority'] = NMA_PRIORITY
    new_config['NMA']['nma_onsnatch'] = int(NMA_ONSNATCH)

    new_config.write()
示例#28
0
def config_write():
    new_config = ConfigObj()
    new_config.filename = CONFIG_FILE

    new_config['General'] = {}
    new_config['General']['config_version'] = CONFIG_VERSION
    new_config['General']['http_port'] = HTTP_PORT
    new_config['General']['http_host'] = HTTP_HOST
    new_config['General']['http_username'] = HTTP_USERNAME
    new_config['General']['http_password'] = HTTP_PASSWORD
    new_config['General']['http_root'] = HTTP_ROOT
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    new_config['General']['log_dir'] = LOG_DIR
    new_config['General']['git_path'] = GIT_PATH
    
    new_config['General']['check_github'] = int(CHECK_GITHUB)
    new_config['General']['check_github_on_startup'] = int(CHECK_GITHUB_ON_STARTUP)
    new_config['General']['check_github_interval'] = CHECK_GITHUB_INTERVAL

    new_config['General']['destination_dir'] = DESTINATION_DIR
    new_config['General']['usenet_retention'] = USENET_RETENTION

    new_config['General']['search_interval'] = SEARCH_INTERVAL
    new_config['General']['libraryscan_interval'] = LIBRARYSCAN_INTERVAL
    new_config['General']['download_scan_interval'] = DOWNLOAD_SCAN_INTERVAL
    new_config['General']['interface'] = INTERFACE
    new_config['General']['autowant_all'] = AUTOWANT_ALL
    new_config['General']['autowant_upcoming'] = AUTOWANT_UPCOMING
    new_config['General']['preferred_quality'] = PREFERRED_QUALITY
    new_config['General']['correct_metadata'] = int(CORRECT_METADATA)
    new_config['General']['move_files'] = int(MOVE_FILES)
    new_config['General']['rename_files'] = int(RENAME_FILES)
    new_config['General']['folder_format'] = FOLDER_FORMAT
    new_config['General']['file_format'] = FILE_FORMAT
    new_config['General']['blackhole'] = int(BLACKHOLE)
    new_config['General']['blackhole_dir'] = BLACKHOLE_DIR

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['sab_host'] = SAB_HOST
    new_config['SABnzbd']['sab_username'] = SAB_USERNAME
    new_config['SABnzbd']['sab_password'] = SAB_PASSWORD
    new_config['SABnzbd']['sab_apikey'] = SAB_APIKEY
    new_config['SABnzbd']['sab_category'] = SAB_CATEGORY

    new_config['NZBsu'] = {}
    new_config['NZBsu']['nzbsu'] = int(NZBSU)
    new_config['NZBsu']['nzbsu_apikey'] = NZBSU_APIKEY

    new_config['DOGnzb'] = {}
    new_config['DOGnzb']['dognzb'] = int(DOGNZB)
    new_config['DOGnzb']['dognzb_apikey'] = DOGNZB_APIKEY

    new_config['Experimental'] = {}
    new_config['Experimental']['experimental'] = int(EXPERIMENTAL)

    new_config['Raw'] = {}
    new_config['Raw']['raw'] = int(RAW)
    new_config['Raw']['raw_provider'] = RAW_PROVIDER
    new_config['Raw']['raw_username'] = RAW_USERNAME
    new_config['Raw']['raw_password'] = RAW_PASSWORD
    new_config['Raw']['raw_groups'] = RAW_GROUPS

    new_config.write()
示例#29
0
    #    try:
    #        os.makedirs(mylar.DATA_DIR)
    #    except OSError:
    #        raise SystemExit('Could not create data directory: ' + mylar.DATA_DIR + '. Exiting....')

    filechecker.validateAndCreateDirectory(mylar.DATA_DIR, True)

    # Make sure the DATA_DIR is writeable
    if not os.access(mylar.DATA_DIR, os.W_OK):
        raise SystemExit('Cannot write to the data directory: ' +
                         mylar.DATA_DIR + '. Exiting...')

    # Put the database in the DATA_DIR
    mylar.DB_FILE = os.path.join(mylar.DATA_DIR, 'mylar.db')

    mylar.CFG = ConfigObj(mylar.CONFIG_FILE, encoding='utf-8')

    # Rename the main thread
    threading.currentThread().name = "MAIN"

    # Read config & start logging
    mylar.initialize()

    if mylar.DAEMON:
        mylar.daemonize()

    # Force the http port if neccessary
    if args.port:
        http_port = args.port
        logger.info('Starting Mylar on foced port: %i' % http_port)
    else:
示例#30
0
def main():

    # Fixed paths to mylar
    if hasattr(sys, 'frozen'):
        mylar.FULL_PATH = os.path.abspath(sys.executable)
    else:
        mylar.FULL_PATH = os.path.abspath(__file__)

    mylar.PROG_DIR = os.path.dirname(mylar.FULL_PATH)
    mylar.ARGS = sys.argv[1:]

    # From sickbeard
    mylar.SYS_ENCODING = None

    try:
        locale.setlocale(locale.LC_ALL, "")
        mylar.SYS_ENCODING = locale.getpreferredencoding()
    except (locale.Error, IOError):
        pass

    # for OSes that are poorly configured I'll just force UTF-8
    if not mylar.SYS_ENCODING or mylar.SYS_ENCODING in ('ANSI_X3.4-1968',
                                                        'US-ASCII', 'ASCII'):
        mylar.SYS_ENCODING = 'UTF-8'

    # Set up and gather command line arguments
    parser = argparse.ArgumentParser(
        description='Comic Book add-on for SABnzbd+')

    parser.add_argument('-v',
                        '--verbose',
                        action='store_true',
                        help='Increase console logging verbosity')
    parser.add_argument('-q',
                        '--quiet',
                        action='store_true',
                        help='Turn off console logging')
    parser.add_argument('-d',
                        '--daemon',
                        action='store_true',
                        help='Run as a daemon')
    parser.add_argument('-p',
                        '--port',
                        type=int,
                        help='Force mylar to run on a specified port')
    parser.add_argument(
        '--datadir', help='Specify a directory where to store your data files')
    parser.add_argument('--config', help='Specify a config file to use')
    parser.add_argument('--nolaunch',
                        action='store_true',
                        help='Prevent browser from launching on startup')
    parser.add_argument(
        '--pidfile',
        help='Create a pid file (only relevant when running as a daemon)')

    args = parser.parse_args()

    if args.verbose:
        mylar.VERBOSE = 2
    elif args.quiet:
        mylar.VERBOSE = 0

    if args.daemon:
        mylar.DAEMON = True
        mylar.VERBOSE = 0
        if args.pidfile:
            mylar.PIDFILE = args.pidfile

    if args.datadir:
        mylar.DATA_DIR = args.datadir
    else:
        mylar.DATA_DIR = mylar.PROG_DIR

    if args.config:
        mylar.CONFIG_FILE = args.config
    else:
        mylar.CONFIG_FILE = os.path.join(mylar.DATA_DIR, 'config.ini')

    # Try to create the DATA_DIR if it doesn't exist
    #if not os.path.exists(mylar.DATA_DIR):
    #    try:
    #        os.makedirs(mylar.DATA_DIR)
    #    except OSError:
    #        raise SystemExit('Could not create data directory: ' + mylar.DATA_DIR + '. Exiting....')

    filechecker.validateAndCreateDirectory(mylar.DATA_DIR, True)

    # Make sure the DATA_DIR is writeable
    if not os.access(mylar.DATA_DIR, os.W_OK):
        raise SystemExit('Cannot write to the data directory: ' +
                         mylar.DATA_DIR + '. Exiting...')

    # Put the database in the DATA_DIR
    mylar.DB_FILE = os.path.join(mylar.DATA_DIR, 'mylar.db')

    mylar.CFG = ConfigObj(mylar.CONFIG_FILE, encoding='utf-8')

    # Read config & start logging
    mylar.initialize()

    if mylar.DAEMON:
        mylar.daemonize()

    # Force the http port if neccessary
    if args.port:
        http_port = args.port
        logger.info('Starting Mylar on foced port: %i' % http_port)
    else:
        http_port = int(mylar.HTTP_PORT)

    # Try to start the server.
    webstart.initialize({
        'http_port': http_port,
        'http_host': mylar.HTTP_HOST,
        'http_root': mylar.HTTP_ROOT,
        'http_username': mylar.HTTP_USERNAME,
        'http_password': mylar.HTTP_PASSWORD,
    })

    logger.info('Starting Mylar on port: %i' % http_port)

    if mylar.LAUNCH_BROWSER and not args.nolaunch:
        mylar.launch_browser(mylar.HTTP_HOST, http_port, mylar.HTTP_ROOT)

    # Start the background threads
    mylar.start()

    while True:
        if not mylar.SIGNAL:
            time.sleep(1)
        else:
            logger.info('Received signal: ' + mylar.SIGNAL)
            if mylar.SIGNAL == 'shutdown':
                mylar.shutdown()
            elif mylar.SIGNAL == 'restart':
                mylar.shutdown(restart=True)
            else:
                mylar.shutdown(restart=True, update=True)

            mylar.SIGNAL = None

    return
示例#31
0
    if not os.path.exists(headphones.DATA_DIR):
        try:
            os.makedirs(headphones.DATA_DIR)
        except OSError:
            raise SystemExit('Could not create data directory: ' +
                             headphones.DATA_DIR + '. Exiting....')

    # Make sure the DATA_DIR is writeable
    if not os.access(headphones.DATA_DIR, os.W_OK):
        raise SystemExit('Cannot write to the data directory: ' +
                         headphones.DATA_DIR + '. Exiting...')

    # Put the database in the DATA_DIR
    headphones.DB_FILE = os.path.join(headphones.DATA_DIR, 'headphones.db')

    headphones.CFG = ConfigObj(headphones.CONFIG_FILE, encoding='utf-8')

    # Read config & start logging
    headphones.initialize()

    if headphones.DAEMON:
        if sys.platform == "win32":
            print "Daemonize not supported under Windows, starting normally"
        else:
            headphones.daemonize()

    #configure the connection to the musicbrainz database
    headphones.mb.startmb()

    # Force the http port if neccessary
    if args.port:
示例#32
0
def save_config():

    new_config = ConfigObj()
    new_config.filename = sickbeard.CONFIG_FILE

    new_config['General'] = {}
    new_config['General']['log_dir'] = LOG_DIR
    new_config['General']['web_port'] = WEB_PORT
    new_config['General']['web_host'] = WEB_HOST
    new_config['General']['web_ipv6'] = WEB_IPV6
    new_config['General']['web_log'] = int(WEB_LOG)
    new_config['General']['web_root'] = WEB_ROOT
    new_config['General']['web_username'] = WEB_USERNAME
    new_config['General']['web_password'] = WEB_PASSWORD
    new_config['General']['nzb_method'] = NZB_METHOD
    new_config['General']['usenet_retention'] = int(USENET_RETENTION)
    new_config['General']['search_frequency'] = int(SEARCH_FREQUENCY)
    new_config['General']['backlog_search_frequency'] = int(BACKLOG_SEARCH_FREQUENCY)
    new_config['General']['use_nzb'] = int(USE_NZB)
    new_config['General']['download_propers'] = int(DOWNLOAD_PROPERS)
    new_config['General']['quality_default'] = int(QUALITY_DEFAULT)
    new_config['General']['season_folders_format'] = SEASON_FOLDERS_FORMAT
    new_config['General']['season_folders_default'] = int(SEASON_FOLDERS_DEFAULT)
    new_config['General']['provider_order'] = ' '.join([x.getID() for x in providers.sortedProviderList()])
    new_config['General']['version_notify'] = int(VERSION_NOTIFY)
    new_config['General']['naming_ep_name'] = int(NAMING_EP_NAME)
    new_config['General']['naming_show_name'] = int(NAMING_SHOW_NAME)
    new_config['General']['naming_ep_type'] = int(NAMING_EP_TYPE)
    new_config['General']['naming_multi_ep_type'] = int(NAMING_MULTI_EP_TYPE)
    new_config['General']['naming_sep_type'] = int(NAMING_SEP_TYPE)
    new_config['General']['naming_use_periods'] = int(NAMING_USE_PERIODS)
    new_config['General']['naming_quality'] = int(NAMING_QUALITY)
    new_config['General']['naming_dates'] = int(NAMING_DATES)
    new_config['General']['use_torrent'] = int(USE_TORRENT)
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    new_config['General']['metadata_type'] = METADATA_TYPE
    new_config['General']['metadata_show'] = int(METADATA_SHOW)
    new_config['General']['metadata_episode'] = int(METADATA_EPISODE)
    new_config['General']['art_poster'] = int(ART_POSTER)
    new_config['General']['art_fanart'] = int(ART_FANART)
    new_config['General']['art_thumbnails'] = int(ART_THUMBNAILS)
    new_config['General']['art_season_thumbnails'] = int(ART_SEASON_THUMBNAILS)
    new_config['General']['cache_dir'] = CACHE_DIR
    new_config['General']['tv_download_dir'] = TV_DOWNLOAD_DIR
    new_config['General']['keep_processed_dir'] = int(KEEP_PROCESSED_DIR)
    new_config['General']['process_automatically'] = int(PROCESS_AUTOMATICALLY)
    new_config['General']['rename_episodes'] = int(RENAME_EPISODES)
    
    new_config['General']['extra_scripts'] = '|'.join(EXTRA_SCRIPTS)
    new_config['General']['git_path'] = GIT_PATH

    new_config['Blackhole'] = {}
    new_config['Blackhole']['nzb_dir'] = NZB_DIR
    new_config['Blackhole']['torrent_dir'] = TORRENT_DIR

    new_config['TVBinz'] = {}
    new_config['TVBinz']['tvbinz'] = int(TVBINZ)
    new_config['TVBinz']['tvbinz_uid'] = TVBINZ_UID
    new_config['TVBinz']['tvbinz_hash'] = TVBINZ_HASH
    new_config['TVBinz']['tvbinz_auth'] = TVBINZ_AUTH

    new_config['NZBs'] = {}
    new_config['NZBs']['nzbs'] = int(NZBS)
    new_config['NZBs']['nzbs_uid'] = NZBS_UID
    new_config['NZBs']['nzbs_hash'] = NZBS_HASH

    new_config['NZBsRUS'] = {}
    new_config['NZBsRUS']['nzbsrus'] = int(NZBSRUS)
    new_config['NZBsRUS']['nzbsrus_uid'] = NZBSRUS_UID
    new_config['NZBsRUS']['nzbsrus_hash'] = NZBSRUS_HASH

    new_config['NZBMatrix'] = {}
    new_config['NZBMatrix']['nzbmatrix'] = int(NZBMATRIX)
    new_config['NZBMatrix']['nzbmatrix_username'] = NZBMATRIX_USERNAME
    new_config['NZBMatrix']['nzbmatrix_apikey'] = NZBMATRIX_APIKEY

    new_config['Newzbin'] = {}
    new_config['Newzbin']['newzbin'] = int(NEWZBIN)
    new_config['Newzbin']['newzbin_username'] = NEWZBIN_USERNAME
    new_config['Newzbin']['newzbin_password'] = NEWZBIN_PASSWORD

    new_config['Bin-Req'] = {}
    new_config['Bin-Req']['binreq'] = int(BINREQ)

    new_config['Womble'] = {}
    new_config['Womble']['womble'] = int(WOMBLE)

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['sab_username'] = SAB_USERNAME
    new_config['SABnzbd']['sab_password'] = SAB_PASSWORD
    new_config['SABnzbd']['sab_apikey'] = SAB_APIKEY
    new_config['SABnzbd']['sab_category'] = SAB_CATEGORY
    new_config['SABnzbd']['sab_host'] = SAB_HOST

    new_config['XBMC'] = {}
    new_config['XBMC']['xbmc_notify_onsnatch'] = int(XBMC_NOTIFY_ONSNATCH)
    new_config['XBMC']['xbmc_notify_ondownload'] = int(XBMC_NOTIFY_ONDOWNLOAD)
    new_config['XBMC']['xbmc_update_library'] = int(XBMC_UPDATE_LIBRARY)
    new_config['XBMC']['xbmc_update_full'] = int(XBMC_UPDATE_FULL)
    new_config['XBMC']['xbmc_host'] = XBMC_HOST
    new_config['XBMC']['xbmc_username'] = XBMC_USERNAME
    new_config['XBMC']['xbmc_password'] = XBMC_PASSWORD

    new_config['Growl'] = {}
    new_config['Growl']['use_growl'] = int(USE_GROWL)
    new_config['Growl']['growl_host'] = GROWL_HOST
    new_config['Growl']['growl_password'] = GROWL_PASSWORD

    new_config['Twitter'] = {}
    new_config['Twitter']['use_twitter'] = int(USE_TWITTER)
    new_config['Twitter']['twitter_username'] = TWITTER_USERNAME
    new_config['Twitter']['twitter_password'] = TWITTER_PASSWORD
    new_config['Twitter']['twitter_prefix'] = TWITTER_PREFIX

    new_config['Jabber'] = {}
    new_config['Jabber']['use_jabber'] = int(USE_JABBER)
    new_config['Jabber']['jabber_username'] = JABBER_USERNAME
    new_config['Jabber']['jabber_password'] = JABBER_PASSWORD
    new_config['Jabber']['jabber_server'] = JABBER_SERVER
    new_config['Jabber']['jabber_port'] = JABBER_PORT
    new_config['Jabber']['jabber_recipient'] = JABBER_RECIPIENT

    new_config['Newznab'] = {}
    new_config['Newznab']['newznab_data'] = '!!!'.join([x.configStr() for x in newznabProviderList])

    new_config.write()
示例#33
0
def main():
	#DIFFEREMT
    # rename this thread
    threading.currentThread().name = "MAIN"
    # Set paths
    if hasattr(sys, 'frozen'):
        lazylibrarian.FULL_PATH = os.path.abspath(sys.executable)
    else:
        lazylibrarian.FULL_PATH = os.path.abspath(__file__)

    lazylibrarian.PROG_DIR = os.path.dirname(lazylibrarian.FULL_PATH)
    lazylibrarian.ARGS = sys.argv[1:]

    lazylibrarian.SYS_ENCODING = None

    try:
        locale.setlocale(locale.LC_ALL, "")
        lazylibrarian.SYS_ENCODING = locale.getpreferredencoding()
    except (locale.Error, IOError):
        pass

    # for OSes that are poorly configured I'll just force UTF-8
    if not lazylibrarian.SYS_ENCODING or lazylibrarian.SYS_ENCODING in ('ANSI_X3.4-1968', 'US-ASCII', 'ASCII'):
        lazylibrarian.SYS_ENCODING = 'UTF-8'

	#check the version when the application starts
    from lazylibrarian import versioncheck
    lazylibrarian.CURRENT_VERSION = versioncheck.getVersion()
    LATEST_VERSION = versioncheck.checkGithub()

    # Set arguments
    from optparse import OptionParser

    p = OptionParser()
    p.add_option('-d', '--daemon', action = "store_true",
                 dest = 'daemon', help = "Run the server as a daemon")
    p.add_option('-q', '--quiet', action = "store_true",
                 dest = 'quiet', help = "Don't log to console")
    p.add_option('--debug', action="store_true",
                 dest = 'debug', help = "Show debuglog messages")
    p.add_option('--nolaunch', action = "store_true",
                 dest = 'nolaunch', help="Don't start browser")
    p.add_option('--port',
                 dest = 'port', default = None,
                 help = "Force webinterface to listen on this port")
    p.add_option('--datadir',
                 dest = 'datadir', default = None,
                 help = "Path to the data directory")
    p.add_option('--config',
                 dest = 'config', default = None,
                 help = "Path to config.ini file")
    p.add_option('-p', '--pidfile',
                 dest = 'pidfile', default = None,
                 help = "Store the process id in the given file")

    options, args = p.parse_args()

    if options.debug:
        lazylibrarian.LOGLEVEL = 2

    if options.quiet:
        lazylibrarian.LOGLEVEL = 0

    if options.daemon:
        if not sys.platform == 'win32':
            lazylibrarian.DAEMON = True
            lazylibrarian.LOGLEVEL = 0
            lazylibrarian.daemonize()
        else:
            print "Daemonize not supported under Windows, starting normally"

    if options.nolaunch:
        lazylibrarian.LAUNCH_BROWSER = False

    if options.datadir:
        lazylibrarian.DATADIR = str(options.datadir)
    else:
        lazylibrarian.DATADIR = lazylibrarian.PROG_DIR

    if options.config:
        lazylibrarian.CONFIGFILE = str(options.config)
    else:
        lazylibrarian.CONFIGFILE = os.path.join(lazylibrarian.DATADIR, "config.ini")

    if options.pidfile:
        if lazylibrarian.DAEMON:
            lazylibrarian.PIDFILE = str(options.pidfile)

    # create and check (optional) paths
    if not os.path.exists(lazylibrarian.DATADIR):
        try:
            os.makedirs(lazylibrarian.DATADIR)
        except OSError:
            raise SystemExit('Could not create data directory: ' + lazylibrarian.DATADIR + '. Exit ...')

    if not os.access(lazylibrarian.DATADIR, os.W_OK):
        raise SystemExit('Cannot write to the data directory: ' + lazylibrarian.DATADIR + '. Exit ...')

    # create database and config
    lazylibrarian.DBFILE = os.path.join(lazylibrarian.DATADIR, 'lazylibrarian.db')
    lazylibrarian.CFG = ConfigObj(lazylibrarian.CONFIGFILE, encoding='utf-8')

    lazylibrarian.initialize()

    if options.port:
        HTTP_PORT = int(options.port)
        logger.info('Starting LazyLibrarian on forced port: %s' % HTTP_PORT)
    else:
        HTTP_PORT = int(lazylibrarian.HTTP_PORT)
        logger.info('Starting LazyLibrarian on port: %s' % lazylibrarian.HTTP_PORT)

    if lazylibrarian.DAEMON:
        lazylibrarian.daemonize()

    # Try to start the server. 
    webStart.initialize({
                    'http_port': HTTP_PORT,
                    'http_host': lazylibrarian.HTTP_HOST,
                    'http_root': lazylibrarian.HTTP_ROOT,
                    'http_user': lazylibrarian.HTTP_USER,
                    'http_pass': lazylibrarian.HTTP_PASS,
            })

    if lazylibrarian.LAUNCH_BROWSER and not options.nolaunch:
        lazylibrarian.launch_browser(lazylibrarian.HTTP_HOST, lazylibrarian.HTTP_PORT, lazylibrarian.HTTP_ROOT)

    lazylibrarian.start()

    while True:
        if not lazylibrarian.SIGNAL:

            try:
                time.sleep(1)
            except KeyboardInterrupt:
                lazylibrarian.shutdown()
        else:
            if lazylibrarian.SIGNAL == 'shutdown':
                lazylibrarian.shutdown()
            elif lazylibrarian.SIGNAL == 'restart':
                lazylibrarian.shutdown(restart=True)
            else:
                lazylibrarian.shutdown(restart=True, update=True)
            lazylibrarian.SIGNAL = None
    return
            xbmc.log(str(e), level=xbmc.LOGERROR)

        xbmcvfs.File(xbmc.translatePath(ppylib + '/arch.' + parch),
                     'w').close()

    os.environ['PYTHONPATH'] = str(os.environ.get('PYTHONPATH')) + ':' + ppylib
    os.environ['LD_LIBRARY_PATH'] = str(
        os.environ.get('LD_LIBRARY_PATH')) + ':' + ppylib
    os.environ['PYTHONPATH'] = str(os.environ.get('PYTHONPATH')) + ':' + (
        xbmc.translatePath(__addonpath__ + '/bin'))

    # SickBeard start
    try:
        # write SickBeard settings
        # ------------------------
        sickbeardconfig = ConfigObj(psickbeardsettings, create_empty=True)
        defaultconfig = ConfigObj()
        defaultconfig['General'] = {}
        defaultconfig['General']['launch_browser'] = '0'
        defaultconfig['General']['version_notify'] = '0'
        defaultconfig['General']['web_port'] = '8082'
        defaultconfig['General']['web_host'] = host
        defaultconfig['General']['web_username'] = user
        defaultconfig['General']['web_password'] = pwd
        defaultconfig['General']['cache_dir'] = __addonhome__ + 'sbcache'
        defaultconfig['General']['log_dir'] = __addonhome__ + 'logs'
        defaultconfig['XBMC'] = {}
        defaultconfig['XBMC']['use_xbmc'] = '1'
        defaultconfig['XBMC']['xbmc_host'] = 'localhost:' + xbmcport
        defaultconfig['XBMC']['xbmc_username'] = xbmcuser
        defaultconfig['XBMC']['xbmc_password'] = xbmcpwd
示例#35
0
def config_write():

    new_config = ConfigObj()
    new_config.filename = CONFIG_FILE

    new_config["General"] = {}
    new_config["General"]["http_port"] = HTTP_PORT
    new_config["General"]["http_host"] = HTTP_HOST
    new_config["General"]["http_username"] = HTTP_USERNAME
    new_config["General"]["http_password"] = HTTP_PASSWORD
    new_config["General"]["http_root"] = HTTP_ROOT
    new_config["General"]["launch_browser"] = int(LAUNCH_BROWSER)
    new_config["General"]["log_dir"] = LOG_DIR
    new_config["General"]["git_path"] = GIT_PATH

    new_config["General"]["music_dir"] = MUSIC_DIR
    new_config["General"]["destination_dir"] = DESTINATION_DIR
    new_config["General"]["preferred_quality"] = PREFERRED_QUALITY
    new_config["General"]["preferred_bitrate"] = PREFERRED_BITRATE
    new_config["General"]["detect_bitrate"] = int(DETECT_BITRATE)
    new_config["General"]["auto_add_artists"] = int(ADD_ARTISTS)
    new_config["General"]["correct_metadata"] = int(CORRECT_METADATA)
    new_config["General"]["move_files"] = int(MOVE_FILES)
    new_config["General"]["rename_files"] = int(RENAME_FILES)
    new_config["General"]["folder_format"] = FOLDER_FORMAT
    new_config["General"]["file_format"] = FILE_FORMAT
    new_config["General"]["cleanup_files"] = int(CLEANUP_FILES)
    new_config["General"]["add_album_art"] = int(ADD_ALBUM_ART)
    new_config["General"]["embed_album_art"] = int(EMBED_ALBUM_ART)
    new_config["General"]["embed_lyrics"] = int(EMBED_LYRICS)
    new_config["General"]["download_dir"] = DOWNLOAD_DIR
    new_config["General"]["blackhole"] = int(BLACKHOLE)
    new_config["General"]["blackhole_dir"] = BLACKHOLE_DIR
    new_config["General"]["usenet_retention"] = USENET_RETENTION
    new_config["General"]["include_extras"] = int(INCLUDE_EXTRAS)

    new_config["General"]["nzb_search_interval"] = NZB_SEARCH_INTERVAL
    new_config["General"]["libraryscan_interval"] = LIBRARYSCAN_INTERVAL
    new_config["General"]["download_scan_interval"] = DOWNLOAD_SCAN_INTERVAL

    new_config["SABnzbd"] = {}
    new_config["SABnzbd"]["sab_host"] = SAB_HOST
    new_config["SABnzbd"]["sab_username"] = SAB_USERNAME
    new_config["SABnzbd"]["sab_password"] = SAB_PASSWORD
    new_config["SABnzbd"]["sab_apikey"] = SAB_APIKEY
    new_config["SABnzbd"]["sab_category"] = SAB_CATEGORY

    new_config["NZBMatrix"] = {}
    new_config["NZBMatrix"]["nzbmatrix"] = int(NZBMATRIX)
    new_config["NZBMatrix"]["nzbmatrix_username"] = NZBMATRIX_USERNAME
    new_config["NZBMatrix"]["nzbmatrix_apikey"] = NZBMATRIX_APIKEY

    new_config["Newznab"] = {}
    new_config["Newznab"]["newznab"] = int(NEWZNAB)
    new_config["Newznab"]["newznab_host"] = NEWZNAB_HOST
    new_config["Newznab"]["newznab_apikey"] = NEWZNAB_APIKEY

    new_config["NZBsorg"] = {}
    new_config["NZBsorg"]["nzbsorg"] = int(NZBSORG)
    new_config["NZBsorg"]["nzbsorg_uid"] = NZBSORG_UID
    new_config["NZBsorg"]["nzbsorg_hash"] = NZBSORG_HASH

    new_config["Newzbin"] = {}
    new_config["Newzbin"]["newzbin"] = int(NEWZBIN)
    new_config["Newzbin"]["newzbin_uid"] = NEWZBIN_UID
    new_config["Newzbin"]["newzbin_password"] = NEWZBIN_PASSWORD

    new_config["General"]["lastfm_username"] = LASTFM_USERNAME
    new_config["General"]["interface"] = INTERFACE
    new_config["General"]["folder_permissions"] = FOLDER_PERMISSIONS

    new_config["General"]["encode"] = int(ENCODE)
    new_config["General"]["encoder"] = ENCODER
    new_config["General"]["bitrate"] = int(BITRATE)
    new_config["General"]["samplingfrequency"] = int(SAMPLINGFREQUENCY)
    new_config["General"]["encoderfolder"] = ENCODERFOLDER
    new_config["General"]["advancedencoder"] = ADVANCEDENCODER
    new_config["General"]["encoderoutputformat"] = ENCODEROUTPUTFORMAT
    new_config["General"]["encoderquality"] = ENCODERQUALITY
    new_config["General"]["encodervbrcbr"] = ENCODERVBRCBR

    new_config.write()
示例#36
0
def config_write():

    new_config = ConfigObj()
    new_config.filename = CONFIG_FILE

    new_config["General"] = {}
    new_config["General"]["config_version"] = CONFIG_VERSION
    new_config["General"]["http_port"] = HTTP_PORT
    new_config["General"]["http_host"] = HTTP_HOST
    new_config["General"]["http_username"] = HTTP_USERNAME
    new_config["General"]["http_password"] = HTTP_PASSWORD
    new_config["General"]["http_root"] = HTTP_ROOT
    new_config["General"]["http_proxy"] = int(HTTP_PROXY)
    new_config["General"]["launch_browser"] = int(LAUNCH_BROWSER)
    new_config["General"]["api_enabled"] = int(API_ENABLED)
    new_config["General"]["api_key"] = API_KEY
    new_config["General"]["log_dir"] = LOG_DIR
    new_config["General"]["git_path"] = GIT_PATH

    new_config["General"]["check_github"] = int(CHECK_GITHUB)
    new_config["General"]["check_github_on_startup"] = int(CHECK_GITHUB_ON_STARTUP)
    new_config["General"]["check_github_interval"] = CHECK_GITHUB_INTERVAL

    new_config["General"]["music_dir"] = MUSIC_DIR
    new_config["General"]["destination_dir"] = DESTINATION_DIR
    new_config["General"]["lossless_destination_dir"] = LOSSLESS_DESTINATION_DIR
    new_config["General"]["preferred_quality"] = PREFERRED_QUALITY
    new_config["General"]["preferred_bitrate"] = PREFERRED_BITRATE
    new_config["General"]["preferred_bitrate_high_buffer"] = PREFERRED_BITRATE_HIGH_BUFFER
    new_config["General"]["preferred_bitrate_low_buffer"] = PREFERRED_BITRATE_LOW_BUFFER
    new_config["General"]["detect_bitrate"] = int(DETECT_BITRATE)
    new_config["General"]["auto_add_artists"] = int(ADD_ARTISTS)
    new_config["General"]["correct_metadata"] = int(CORRECT_METADATA)
    new_config["General"]["move_files"] = int(MOVE_FILES)
    new_config["General"]["rename_files"] = int(RENAME_FILES)
    new_config["General"]["folder_format"] = FOLDER_FORMAT
    new_config["General"]["file_format"] = FILE_FORMAT
    new_config["General"]["cleanup_files"] = int(CLEANUP_FILES)
    new_config["General"]["add_album_art"] = int(ADD_ALBUM_ART)
    new_config["General"]["embed_album_art"] = int(EMBED_ALBUM_ART)
    new_config["General"]["embed_lyrics"] = int(EMBED_LYRICS)
    new_config["General"]["download_dir"] = DOWNLOAD_DIR
    new_config["General"]["blackhole"] = int(BLACKHOLE)
    new_config["General"]["blackhole_dir"] = BLACKHOLE_DIR
    new_config["General"]["usenet_retention"] = USENET_RETENTION
    new_config["General"]["include_extras"] = int(INCLUDE_EXTRAS)
    new_config["General"]["extras"] = EXTRAS
    new_config["General"]["autowant_upcoming"] = int(AUTOWANT_UPCOMING)
    new_config["General"]["autowant_all"] = int(AUTOWANT_ALL)

    new_config["General"]["numberofseeders"] = NUMBEROFSEEDERS
    new_config["General"]["torrentblackhole_dir"] = TORRENTBLACKHOLE_DIR
    new_config["General"]["isohunt"] = int(ISOHUNT)
    new_config["General"]["kat"] = int(KAT)
    new_config["General"]["mininova"] = int(MININOVA)
    new_config["General"]["download_torrent_dir"] = DOWNLOAD_TORRENT_DIR

    new_config["Waffles"] = {}
    new_config["Waffles"]["waffles"] = int(WAFFLES)
    new_config["Waffles"]["waffles_uid"] = WAFFLES_UID
    new_config["Waffles"]["waffles_passkey"] = WAFFLES_PASSKEY

    new_config["What.cd"] = {}
    new_config["What.cd"]["whatcd"] = int(WHATCD)
    new_config["What.cd"]["whatcd_username"] = WHATCD_USERNAME
    new_config["What.cd"]["whatcd_password"] = WHATCD_PASSWORD

    new_config["General"]["search_interval"] = SEARCH_INTERVAL
    new_config["General"]["libraryscan_interval"] = LIBRARYSCAN_INTERVAL
    new_config["General"]["download_scan_interval"] = DOWNLOAD_SCAN_INTERVAL

    new_config["SABnzbd"] = {}
    new_config["SABnzbd"]["sab_host"] = SAB_HOST
    new_config["SABnzbd"]["sab_username"] = SAB_USERNAME
    new_config["SABnzbd"]["sab_password"] = SAB_PASSWORD
    new_config["SABnzbd"]["sab_apikey"] = SAB_APIKEY
    new_config["SABnzbd"]["sab_category"] = SAB_CATEGORY

    new_config["NZBMatrix"] = {}
    new_config["NZBMatrix"]["nzbmatrix"] = int(NZBMATRIX)
    new_config["NZBMatrix"]["nzbmatrix_username"] = NZBMATRIX_USERNAME
    new_config["NZBMatrix"]["nzbmatrix_apikey"] = NZBMATRIX_APIKEY

    new_config["Newznab"] = {}
    new_config["Newznab"]["newznab"] = int(NEWZNAB)
    new_config["Newznab"]["newznab_host"] = NEWZNAB_HOST
    new_config["Newznab"]["newznab_apikey"] = NEWZNAB_APIKEY
    new_config["Newznab"]["newznab_enabled"] = int(NEWZNAB_ENABLED)
    # Need to unpack the extra newznabs for saving in config.ini
    flattened_newznabs = []
    for newznab in EXTRA_NEWZNABS:
        for item in newznab:
            flattened_newznabs.append(item)

    new_config["Newznab"]["extra_newznabs"] = flattened_newznabs

    new_config["NZBsorg"] = {}
    new_config["NZBsorg"]["nzbsorg"] = int(NZBSORG)
    new_config["NZBsorg"]["nzbsorg_uid"] = NZBSORG_UID
    new_config["NZBsorg"]["nzbsorg_hash"] = NZBSORG_HASH

    new_config["Newzbin"] = {}
    new_config["Newzbin"]["newzbin"] = int(NEWZBIN)
    new_config["Newzbin"]["newzbin_uid"] = NEWZBIN_UID
    new_config["Newzbin"]["newzbin_password"] = NEWZBIN_PASSWORD

    new_config["Prowl"] = {}
    new_config["Prowl"]["prowl_enabled"] = int(PROWL_ENABLED)
    new_config["Prowl"]["prowl_keys"] = PROWL_KEYS
    new_config["Prowl"]["prowl_onsnatch"] = int(PROWL_ONSNATCH)
    new_config["Prowl"]["prowl_priority"] = int(PROWL_PRIORITY)

    new_config["XBMC"] = {}
    new_config["XBMC"]["xbmc_enabled"] = int(XBMC_ENABLED)
    new_config["XBMC"]["xbmc_host"] = XBMC_HOST
    new_config["XBMC"]["xbmc_username"] = XBMC_USERNAME
    new_config["XBMC"]["xbmc_password"] = XBMC_PASSWORD
    new_config["XBMC"]["xbmc_update"] = int(XBMC_UPDATE)
    new_config["XBMC"]["xbmc_notify"] = int(XBMC_NOTIFY)

    new_config["NMA"] = {}
    new_config["NMA"]["nma_enabled"] = int(NMA_ENABLED)
    new_config["NMA"]["nma_apikey"] = NMA_APIKEY
    new_config["NMA"]["nma_priority"] = NMA_PRIORITY
    new_config["NMA"]["nma_onsnatch"] = int(PROWL_ONSNATCH)

    new_config["Synoindex"] = {}
    new_config["Synoindex"]["synoindex_enabled"] = int(SYNOINDEX_ENABLED)

    new_config["General"]["lastfm_username"] = LASTFM_USERNAME
    new_config["General"]["interface"] = INTERFACE
    new_config["General"]["folder_permissions"] = FOLDER_PERMISSIONS

    new_config["General"]["music_encoder"] = int(MUSIC_ENCODER)
    new_config["General"]["encoder"] = ENCODER
    new_config["General"]["bitrate"] = int(BITRATE)
    new_config["General"]["samplingfrequency"] = int(SAMPLINGFREQUENCY)
    new_config["General"]["encoderfolder"] = ENCODERFOLDER
    new_config["General"]["advancedencoder"] = ADVANCEDENCODER
    new_config["General"]["encoderoutputformat"] = ENCODEROUTPUTFORMAT
    new_config["General"]["encoderquality"] = ENCODERQUALITY
    new_config["General"]["encodervbrcbr"] = ENCODERVBRCBR
    new_config["General"]["encoderlossless"] = int(ENCODERLOSSLESS)
    new_config["General"]["delete_lossless_files"] = int(DELETE_LOSSLESS_FILES)

    new_config["General"]["mirror"] = MIRROR
    new_config["General"]["customhost"] = CUSTOMHOST
    new_config["General"]["customport"] = CUSTOMPORT
    new_config["General"]["customsleep"] = CUSTOMSLEEP
    new_config["General"]["hpuser"] = HPUSER
    new_config["General"]["hppass"] = HPPASS

    new_config["Advanced"] = {}
    new_config["Advanced"]["album_completion_pct"] = ALBUM_COMPLETION_PCT
    new_config["Advanced"]["cache_sizemb"] = CACHE_SIZEMB

    new_config.write()
示例#37
0
def save_config():

    new_config = ConfigObj()
    new_config.filename = sickbeard.CONFIG_FILE

    new_config['General'] = {}
    new_config['General']['log_dir'] = LOG_DIR
    new_config['General']['web_port'] = WEB_PORT
    new_config['General']['web_host'] = WEB_HOST
    new_config['General']['web_ipv6'] = WEB_IPV6
    new_config['General']['web_log'] = int(WEB_LOG)
    new_config['General']['web_root'] = WEB_ROOT
    new_config['General']['web_username'] = WEB_USERNAME
    new_config['General']['web_password'] = WEB_PASSWORD
    new_config['General']['use_nzbs'] = int(USE_NZBS)
    new_config['General']['use_torrents'] = int(USE_TORRENTS)
    new_config['General']['nzb_method'] = NZB_METHOD
    new_config['General']['usenet_retention'] = int(USENET_RETENTION)
    new_config['General']['search_frequency'] = int(SEARCH_FREQUENCY)
    new_config['General']['download_propers'] = int(DOWNLOAD_PROPERS)
    new_config['General']['quality_default'] = int(QUALITY_DEFAULT)
    new_config['General']['status_default'] = int(STATUS_DEFAULT)
    new_config['General']['season_folders_format'] = SEASON_FOLDERS_FORMAT
    new_config['General']['season_folders_default'] = int(
        SEASON_FOLDERS_DEFAULT)
    new_config['General']['provider_order'] = ' '.join(
        [x.getID() for x in providers.sortedProviderList()])
    new_config['General']['version_notify'] = int(VERSION_NOTIFY)
    new_config['General']['naming_ep_name'] = int(NAMING_EP_NAME)
    new_config['General']['naming_show_name'] = int(NAMING_SHOW_NAME)
    new_config['General']['naming_ep_type'] = int(NAMING_EP_TYPE)
    new_config['General']['naming_multi_ep_type'] = int(NAMING_MULTI_EP_TYPE)
    new_config['General']['naming_sep_type'] = int(NAMING_SEP_TYPE)
    new_config['General']['naming_use_periods'] = int(NAMING_USE_PERIODS)
    new_config['General']['naming_quality'] = int(NAMING_QUALITY)
    new_config['General']['naming_dates'] = int(NAMING_DATES)
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)

    new_config['General']['use_banner'] = int(USE_BANNER)
    new_config['General']['use_listview'] = int(USE_LISTVIEW)
    new_config['General']['metadata_xbmc'] = metadata_provider_dict[
        'XBMC'].get_config()
    new_config['General']['metadata_mediabrowser'] = metadata_provider_dict[
        'MediaBrowser'].get_config()
    new_config['General']['metadata_ps3'] = metadata_provider_dict[
        'Sony PS3'].get_config()
    new_config['General']['metadata_wdtv'] = metadata_provider_dict[
        'WDTV'].get_config()

    new_config['General']['cache_dir'] = CACHE_DIR if CACHE_DIR else 'cache'
    new_config['General']['root_dirs'] = ROOT_DIRS if ROOT_DIRS else ''
    new_config['General']['tv_download_dir'] = TV_DOWNLOAD_DIR
    new_config['General']['keep_processed_dir'] = int(KEEP_PROCESSED_DIR)
    new_config['General']['move_associated_files'] = int(MOVE_ASSOCIATED_FILES)
    new_config['General']['process_automatically'] = int(PROCESS_AUTOMATICALLY)
    new_config['General']['rename_episodes'] = int(RENAME_EPISODES)

    new_config['General']['extra_scripts'] = '|'.join(EXTRA_SCRIPTS)
    new_config['General']['git_path'] = GIT_PATH

    new_config['Blackhole'] = {}
    new_config['Blackhole']['nzb_dir'] = NZB_DIR
    new_config['Blackhole']['torrent_dir'] = TORRENT_DIR

    new_config['EZRSS'] = {}
    new_config['EZRSS']['ezrss'] = int(EZRSS)

    new_config['TVTORRENTS'] = {}
    new_config['TVTORRENTS']['tvtorrents'] = int(TVTORRENTS)
    new_config['TVTORRENTS']['tvtorrents_digest'] = TVTORRENTS_DIGEST
    new_config['TVTORRENTS']['tvtorrents_hash'] = TVTORRENTS_HASH

    new_config['TVBinz'] = {}
    new_config['TVBinz']['tvbinz'] = int(TVBINZ)
    new_config['TVBinz']['tvbinz_uid'] = TVBINZ_UID
    new_config['TVBinz']['tvbinz_hash'] = TVBINZ_HASH
    new_config['TVBinz']['tvbinz_auth'] = TVBINZ_AUTH

    new_config['NZBs'] = {}
    new_config['NZBs']['nzbs'] = int(NZBS)
    new_config['NZBs']['nzbs_uid'] = NZBS_UID
    new_config['NZBs']['nzbs_hash'] = NZBS_HASH

    new_config['NZBsRUS'] = {}
    new_config['NZBsRUS']['nzbsrus'] = int(NZBSRUS)
    new_config['NZBsRUS']['nzbsrus_uid'] = NZBSRUS_UID
    new_config['NZBsRUS']['nzbsrus_hash'] = NZBSRUS_HASH

    new_config['NZBMatrix'] = {}
    new_config['NZBMatrix']['nzbmatrix'] = int(NZBMATRIX)
    new_config['NZBMatrix']['nzbmatrix_username'] = NZBMATRIX_USERNAME
    new_config['NZBMatrix']['nzbmatrix_apikey'] = NZBMATRIX_APIKEY

    new_config['Newzbin'] = {}
    new_config['Newzbin']['newzbin'] = int(NEWZBIN)
    new_config['Newzbin']['newzbin_username'] = NEWZBIN_USERNAME
    new_config['Newzbin']['newzbin_password'] = NEWZBIN_PASSWORD

    new_config['Womble'] = {}
    new_config['Womble']['womble'] = int(WOMBLE)

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['sab_username'] = SAB_USERNAME
    new_config['SABnzbd']['sab_password'] = SAB_PASSWORD
    new_config['SABnzbd']['sab_apikey'] = SAB_APIKEY
    new_config['SABnzbd']['sab_category'] = SAB_CATEGORY
    new_config['SABnzbd']['sab_host'] = SAB_HOST

    new_config['NZBget'] = {}
    new_config['NZBget']['nzbget_password'] = NZBGET_PASSWORD
    new_config['NZBget']['nzbget_category'] = NZBGET_CATEGORY
    new_config['NZBget']['nzbget_host'] = NZBGET_HOST

    new_config['XBMC'] = {}
    new_config['XBMC']['use_xbmc'] = int(USE_XBMC)
    new_config['XBMC']['xbmc_notify_onsnatch'] = int(XBMC_NOTIFY_ONSNATCH)
    new_config['XBMC']['xbmc_notify_ondownload'] = int(XBMC_NOTIFY_ONDOWNLOAD)
    new_config['XBMC']['xbmc_update_library'] = int(XBMC_UPDATE_LIBRARY)
    new_config['XBMC']['xbmc_update_full'] = int(XBMC_UPDATE_FULL)
    new_config['XBMC']['xbmc_host'] = XBMC_HOST
    new_config['XBMC']['xbmc_username'] = XBMC_USERNAME
    new_config['XBMC']['xbmc_password'] = XBMC_PASSWORD

    new_config['Plex'] = {}
    new_config['Plex']['use_plex'] = int(USE_PLEX)
    new_config['Plex']['plex_notify_onsnatch'] = int(PLEX_NOTIFY_ONSNATCH)
    new_config['Plex']['plex_notify_ondownload'] = int(PLEX_NOTIFY_ONDOWNLOAD)
    new_config['Plex']['plex_update_library'] = int(PLEX_UPDATE_LIBRARY)
    new_config['Plex']['plex_server_host'] = PLEX_SERVER_HOST
    new_config['Plex']['plex_host'] = PLEX_HOST
    new_config['Plex']['plex_username'] = PLEX_USERNAME
    new_config['Plex']['plex_password'] = PLEX_PASSWORD

    new_config['Growl'] = {}
    new_config['Growl']['use_growl'] = int(USE_GROWL)
    new_config['Growl']['growl_notify_onsnatch'] = int(GROWL_NOTIFY_ONSNATCH)
    new_config['Growl']['growl_notify_ondownload'] = int(
        GROWL_NOTIFY_ONDOWNLOAD)
    new_config['Growl']['growl_host'] = GROWL_HOST
    new_config['Growl']['growl_password'] = GROWL_PASSWORD

    new_config['Prowl'] = {}
    new_config['Prowl']['use_prowl'] = int(USE_PROWL)
    new_config['Prowl']['prowl_notify_onsnatch'] = int(PROWL_NOTIFY_ONSNATCH)
    new_config['Prowl']['prowl_notify_ondownload'] = int(
        PROWL_NOTIFY_ONDOWNLOAD)
    new_config['Prowl']['prowl_api'] = PROWL_API
    new_config['Prowl']['prowl_priority'] = PROWL_PRIORITY

    new_config['Twitter'] = {}
    new_config['Twitter']['use_twitter'] = int(USE_TWITTER)
    new_config['Twitter']['twitter_notify_onsnatch'] = int(
        TWITTER_NOTIFY_ONSNATCH)
    new_config['Twitter']['twitter_notify_ondownload'] = int(
        TWITTER_NOTIFY_ONDOWNLOAD)
    new_config['Twitter']['twitter_username'] = TWITTER_USERNAME
    new_config['Twitter']['twitter_password'] = TWITTER_PASSWORD
    new_config['Twitter']['twitter_prefix'] = TWITTER_PREFIX

    new_config['Notifo'] = {}
    new_config['Notifo']['use_notifo'] = int(USE_NOTIFO)
    new_config['Notifo']['notifo_notify_onsnatch'] = int(
        NOTIFO_NOTIFY_ONSNATCH)
    new_config['Notifo']['notifo_notify_ondownload'] = int(
        NOTIFO_NOTIFY_ONDOWNLOAD)
    new_config['Notifo']['notifo_username'] = NOTIFO_USERNAME
    new_config['Notifo']['notifo_apisecret'] = NOTIFO_APISECRET

    new_config['Libnotify'] = {}
    new_config['Libnotify']['use_libnotify'] = int(USE_LIBNOTIFY)
    new_config['Libnotify']['libnotify_notify_onsnatch'] = int(
        LIBNOTIFY_NOTIFY_ONSNATCH)
    new_config['Libnotify']['libnotify_notify_ondownload'] = int(
        LIBNOTIFY_NOTIFY_ONDOWNLOAD)

    new_config['NMJ'] = {}
    new_config['NMJ']['use_nmj'] = int(USE_NMJ)
    new_config['NMJ']['nmj_host'] = NMJ_HOST
    new_config['NMJ']['nmj_database'] = NMJ_DATABASE
    new_config['NMJ']['nmj_mount'] = NMJ_MOUNT

    new_config['Newznab'] = {}
    new_config['Newznab']['newznab_data'] = '!!!'.join(
        [x.configStr() for x in newznabProviderList])

    new_config['GUI'] = {}
    new_config['GUI']['coming_eps_layout'] = COMING_EPS_LAYOUT
    new_config['GUI']['coming_eps_display_paused'] = int(
        COMING_EPS_DISPLAY_PAUSED)
    new_config['GUI']['coming_eps_sort'] = COMING_EPS_SORT

    new_config.write()
示例#38
0
    def start(self):
        # do some preliminary stuff
        sickbeard.MY_FULLNAME = os.path.normpath(os.path.abspath(__file__))
        sickbeard.MY_NAME = os.path.basename(sickbeard.MY_FULLNAME)
        sickbeard.PROG_DIR = os.path.dirname(sickbeard.MY_FULLNAME)
        sickbeard.DATA_DIR = sickbeard.PROG_DIR
        sickbeard.MY_ARGS = sys.argv[1:]
        sickbeard.SYS_ENCODING = None

        try:
            locale.setlocale(locale.LC_ALL, '')
        except (locale.Error, IOError):
            pass
        try:
            sickbeard.SYS_ENCODING = locale.getpreferredencoding()
        except (locale.Error, IOError):
            pass

        # For OSes that are poorly configured I'll just randomly force UTF-8
        if not sickbeard.SYS_ENCODING or sickbeard.SYS_ENCODING in (
                'ANSI_X3.4-1968', 'US-ASCII', 'ASCII'):
            sickbeard.SYS_ENCODING = 'UTF-8'

        if not hasattr(sys, 'setdefaultencoding'):
            moves.reload_module(sys)

        try:
            # pylint: disable=E1101
            # On non-unicode builds this will raise an AttributeError, if encoding type is not valid it throws a LookupError
            sys.setdefaultencoding(sickbeard.SYS_ENCODING)
        except:
            print(
                'Sorry, you MUST add the SickGear folder to the PYTHONPATH environment variable'
            )
            print(
                'or find another way to force Python to use %s for string encoding.'
                % sickbeard.SYS_ENCODING)
            sys.exit(1)

        # Need console logging for SickBeard.py and SickBeard-console.exe
        self.consoleLogging = (not hasattr(
            sys, 'frozen')) or (sickbeard.MY_NAME.lower().find('-console') > 0)

        # Rename the main thread
        threading.currentThread().name = 'MAIN'

        try:
            opts, args = getopt.getopt(sys.argv[1:], 'hfqdp::', [
                'help', 'forceupdate', 'quiet', 'nolaunch', 'daemon',
                'pidfile=', 'port=', 'datadir=', 'config=', 'noresize'
            ])  # @UnusedVariable
        except getopt.GetoptError:
            sys.exit(self.help_message())

        for o, a in opts:
            # Prints help message
            if o in ('-h', '--help'):
                sys.exit(self.help_message())

            # For now we'll just silence the logging
            if o in ('-q', '--quiet'):
                self.consoleLogging = False

            # Should we update (from indexer) all shows in the DB right away?
            if o in ('-f', '--forceupdate'):
                self.forceUpdate = True

            # Suppress launching web browser
            # Needed for OSes without default browser assigned
            # Prevent duplicate browser window when restarting in the app
            if o in ('--nolaunch', ):
                self.noLaunch = True

            # Override default/configured port
            if o in ('-p', '--port'):
                try:
                    self.forcedPort = int(a)
                except ValueError:
                    sys.exit('Port: %s is not a number. Exiting.' % a)

            # Run as a double forked daemon
            if o in ('-d', '--daemon'):
                self.runAsDaemon = True
                # When running as daemon disable consoleLogging and don't start browser
                self.consoleLogging = False
                self.noLaunch = True

                if sys.platform == 'win32':
                    self.runAsDaemon = False

            # Write a pidfile if requested
            if o in ('--pidfile', ):
                self.CREATEPID = True
                self.PIDFILE = str(a)

                # If the pidfile already exists, sickbeard may still be running, so exit
                if os.path.exists(self.PIDFILE):
                    sys.exit('PID file: %s already exists. Exiting.' %
                             self.PIDFILE)

            # Specify folder to load the config file from
            if o in ('--config', ):
                sickbeard.CONFIG_FILE = os.path.abspath(a)

            # Specify folder to use as the data dir
            if o in ('--datadir', ):
                sickbeard.DATA_DIR = os.path.abspath(a)

            # Prevent resizing of the banner/posters even if PIL is installed
            if o in ('--noresize', ):
                sickbeard.NO_RESIZE = True

        # The pidfile is only useful in daemon mode, make sure we can write the file properly
        if self.CREATEPID:
            if self.runAsDaemon:
                pid_dir = os.path.dirname(self.PIDFILE)
                if not os.access(pid_dir, os.F_OK):
                    sys.exit(u"PID dir: %s doesn't exist. Exiting." % pid_dir)
                if not os.access(pid_dir, os.W_OK):
                    sys.exit(
                        u'PID dir: %s must be writable (write permissions). Exiting.'
                        % pid_dir)

            else:
                if self.consoleLogging:
                    print(
                        u'Not running in daemon mode. PID file creation disabled'
                    )

                self.CREATEPID = False

        # If they don't specify a config file then put it in the data dir
        if not sickbeard.CONFIG_FILE:
            sickbeard.CONFIG_FILE = os.path.join(sickbeard.DATA_DIR,
                                                 'config.ini')

        # Make sure that we can create the data dir
        if not os.access(sickbeard.DATA_DIR, os.F_OK):
            try:
                os.makedirs(sickbeard.DATA_DIR, 0o744)
            except os.error:
                sys.exit(u'Unable to create data directory: %s Exiting.' %
                         sickbeard.DATA_DIR)

        # Make sure we can write to the data dir
        if not os.access(sickbeard.DATA_DIR, os.W_OK):
            sys.exit(
                u'Data directory: %s must be writable (write permissions). Exiting.'
                % sickbeard.DATA_DIR)

        # Make sure we can write to the config file
        if not os.access(sickbeard.CONFIG_FILE, os.W_OK):
            if os.path.isfile(sickbeard.CONFIG_FILE):
                sys.exit(
                    u'Config file: %s must be writeable (write permissions). Exiting.'
                    % sickbeard.CONFIG_FILE)
            elif not os.access(os.path.dirname(sickbeard.CONFIG_FILE),
                               os.W_OK):
                sys.exit(
                    u'Config file directory: %s must be writeable (write permissions). Exiting'
                    % os.path.dirname(sickbeard.CONFIG_FILE))
        os.chdir(sickbeard.DATA_DIR)

        if self.consoleLogging:
            print(u'Starting up SickGear from %s' % sickbeard.CONFIG_FILE)

        # Load the config and publish it to the sickbeard package
        if not os.path.isfile(sickbeard.CONFIG_FILE):
            print(u'Unable to find "%s", all settings will be default!' %
                  sickbeard.CONFIG_FILE)

        sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)

        # check all db versions
        for d, min_v, max_v, mo in [
            ('failed.db', sickbeard.failed_db.MIN_DB_VERSION,
             sickbeard.failed_db.MAX_DB_VERSION, 'FailedDb'),
            ('cache.db', sickbeard.cache_db.MIN_DB_VERSION,
             sickbeard.cache_db.MAX_DB_VERSION, 'CacheDb'),
            ('sickbeard.db', sickbeard.mainDB.MIN_DB_VERSION,
             sickbeard.mainDB.MAX_DB_VERSION, 'MainDb')
        ]:
            cur_db_version = db.DBConnection(d).checkDBVersion()

            if cur_db_version > 0:
                if cur_db_version < min_v:
                    print(
                        u'Your [%s] database version (%s) is too old to migrate from with this version of SickGear'
                        % (d, cur_db_version))
                    sys.exit(u'Upgrade using a previous version of SG first,' +
                             u' or start with no database file to begin fresh')
                if cur_db_version > max_v:
                    print(
                        u'Your [%s] database version (%s) has been incremented past'
                        u' what this version of SickGear supports. Trying to rollback now. Please wait...'
                        % (d, cur_db_version))
                    try:
                        rollback_loaded = db.get_rollback_module()
                        if None is not rollback_loaded:
                            rollback_loaded.__dict__[mo]().run(max_v)
                        else:
                            print(
                                u'ERROR: Could not download Rollback Module.')
                    except (StandardError, Exception):
                        pass
                    if db.DBConnection(d).checkDBVersion() > max_v:
                        print(u'Rollback failed.')
                        sys.exit(
                            u'If you have used other forks, your database may be unusable due to their changes'
                        )
                    print(u'Rollback of [%s] successful.' % d)

        # Initialize the config and our threads
        sickbeard.initialize(consoleLogging=self.consoleLogging)

        if self.runAsDaemon:
            self.daemonize()

        # Get PID
        sickbeard.PID = os.getpid()

        if self.forcedPort:
            logger.log(u'Forcing web server to port %s' % self.forcedPort)
            self.startPort = self.forcedPort
        else:
            self.startPort = sickbeard.WEB_PORT

        if sickbeard.WEB_LOG:
            self.log_dir = sickbeard.LOG_DIR
        else:
            self.log_dir = None

        # sickbeard.WEB_HOST is available as a configuration value in various
        # places but is not configurable. It is supported here for historic reasons.
        if sickbeard.WEB_HOST and sickbeard.WEB_HOST != '0.0.0.0':
            self.webhost = sickbeard.WEB_HOST
        else:
            if sickbeard.WEB_IPV6:
                self.webhost = '::'
            else:
                self.webhost = '0.0.0.0'

        # web server options
        self.web_options = {
            'port':
            int(self.startPort),
            'host':
            self.webhost,
            'data_root':
            os.path.join(sickbeard.PROG_DIR, 'gui', sickbeard.GUI_NAME),
            'web_root':
            sickbeard.WEB_ROOT,
            'log_dir':
            self.log_dir,
            'username':
            sickbeard.WEB_USERNAME,
            'password':
            sickbeard.WEB_PASSWORD,
            'enable_https':
            sickbeard.ENABLE_HTTPS,
            'handle_reverse_proxy':
            sickbeard.HANDLE_REVERSE_PROXY,
            'https_cert':
            os.path.join(sickbeard.PROG_DIR, sickbeard.HTTPS_CERT),
            'https_key':
            os.path.join(sickbeard.PROG_DIR, sickbeard.HTTPS_KEY),
        }

        # start web server
        try:
            # used to check if existing SG instances have been started
            sickbeard.helpers.wait_for_free_port(self.web_options['host'],
                                                 self.web_options['port'])

            self.webserver = WebServer(self.web_options)
            self.webserver.start()
        except Exception:
            logger.log(
                u'Unable to start web server, is something else running on port %d?'
                % self.startPort, logger.ERROR)
            if sickbeard.LAUNCH_BROWSER and not self.runAsDaemon:
                logger.log(u'Launching browser and exiting', logger.ERROR)
                sickbeard.launch_browser(self.startPort)
            os._exit(1)

        # Check if we need to perform a restore first
        restoreDir = os.path.join(sickbeard.DATA_DIR, 'restore')
        if os.path.exists(restoreDir):
            if self.restore(restoreDir, sickbeard.DATA_DIR):
                logger.log(u'Restore successful...')
            else:
                logger.log_error_and_exit(u'Restore FAILED!')

        # Build from the DB to start with
        self.loadShowsFromDB()

        # Fire up all our threads
        sickbeard.start()

        # Build internal name cache
        name_cache.buildNameCache()

        # refresh network timezones
        network_timezones.update_network_dict()

        # load all ids from xem
        startup_background_tasks = threading.Thread(
            name='FETCH-XEMDATA',
            target=sickbeard.scene_exceptions.get_xem_ids)
        startup_background_tasks.start()

        # sure, why not?
        if sickbeard.USE_FAILED_DOWNLOADS:
            failed_history.trimHistory()

        # Start an update if we're supposed to
        if self.forceUpdate or sickbeard.UPDATE_SHOWS_ON_START:
            sickbeard.showUpdateScheduler.action.run(
                force=True)  # @UndefinedVariable

        # Launch browser
        if sickbeard.LAUNCH_BROWSER and not (self.noLaunch
                                             or self.runAsDaemon):
            sickbeard.launch_browser(self.startPort)

        # main loop
        while True:
            time.sleep(1)
示例#39
0
def save_config():

    new_config = ConfigObj()
    new_config.filename = CONFIG_FILE

    new_config["General"] = {}
    new_config["General"]["log_dir"] = LOG_DIR
    new_config["General"]["web_port"] = WEB_PORT
    new_config["General"]["web_host"] = WEB_HOST
    new_config["General"]["web_ipv6"] = int(WEB_IPV6)
    new_config["General"]["web_log"] = int(WEB_LOG)
    new_config["General"]["web_root"] = WEB_ROOT
    new_config["General"]["web_username"] = WEB_USERNAME
    new_config["General"]["web_password"] = WEB_PASSWORD
    new_config["General"]["use_api"] = int(USE_API)
    new_config["General"]["api_key"] = API_KEY
    new_config["General"]["use_nzbs"] = int(USE_NZBS)
    new_config["General"]["use_torrents"] = int(USE_TORRENTS)
    new_config["General"]["nzb_method"] = NZB_METHOD
    new_config["General"]["usenet_retention"] = int(USENET_RETENTION)
    new_config["General"]["search_frequency"] = int(SEARCH_FREQUENCY)
    new_config["General"]["download_propers"] = int(DOWNLOAD_PROPERS)
    new_config["General"]["quality_default"] = int(QUALITY_DEFAULT)
    new_config["General"]["status_default"] = int(STATUS_DEFAULT)
    new_config["General"]["season_folders_format"] = SEASON_FOLDERS_FORMAT
    new_config["General"]["season_folders_default"] = int(SEASON_FOLDERS_DEFAULT)
    new_config["General"]["provider_order"] = " ".join([x.getID() for x in providers.sortedProviderList()])
    new_config["General"]["version_notify"] = int(VERSION_NOTIFY)
    new_config["General"]["naming_ep_name"] = int(NAMING_EP_NAME)
    new_config["General"]["naming_show_name"] = int(NAMING_SHOW_NAME)
    new_config["General"]["naming_ep_type"] = int(NAMING_EP_TYPE)
    new_config["General"]["naming_multi_ep_type"] = int(NAMING_MULTI_EP_TYPE)
    new_config["General"]["naming_sep_type"] = int(NAMING_SEP_TYPE)
    new_config["General"]["naming_use_periods"] = int(NAMING_USE_PERIODS)
    new_config["General"]["naming_quality"] = int(NAMING_QUALITY)
    new_config["General"]["naming_dates"] = int(NAMING_DATES)
    new_config["General"]["launch_browser"] = int(LAUNCH_BROWSER)

    new_config["General"]["use_banner"] = int(USE_BANNER)
    new_config["General"]["use_listview"] = int(USE_LISTVIEW)
    new_config["General"]["metadata_xbmc"] = metadata_provider_dict["XBMC"].get_config()
    new_config["General"]["metadata_mediabrowser"] = metadata_provider_dict["MediaBrowser"].get_config()
    new_config["General"]["metadata_ps3"] = metadata_provider_dict["Sony PS3"].get_config()
    new_config["General"]["metadata_wdtv"] = metadata_provider_dict["WDTV"].get_config()
    new_config["General"]["metadata_tivo"] = metadata_provider_dict["TIVO"].get_config()

    new_config["General"]["cache_dir"] = ACTUAL_CACHE_DIR if ACTUAL_CACHE_DIR else "cache"
    new_config["General"]["root_dirs"] = ROOT_DIRS if ROOT_DIRS else ""
    new_config["General"]["tv_download_dir"] = TV_DOWNLOAD_DIR
    new_config["General"]["keep_processed_dir"] = int(KEEP_PROCESSED_DIR)
    new_config["General"]["move_associated_files"] = int(MOVE_ASSOCIATED_FILES)
    new_config["General"]["process_automatically"] = int(PROCESS_AUTOMATICALLY)
    new_config["General"]["rename_episodes"] = int(RENAME_EPISODES)

    new_config["General"]["extra_scripts"] = "|".join(EXTRA_SCRIPTS)
    new_config["General"]["git_path"] = GIT_PATH
    new_config["General"]["ignore_words"] = IGNORE_WORDS

    new_config["Blackhole"] = {}
    new_config["Blackhole"]["nzb_dir"] = NZB_DIR
    new_config["Blackhole"]["torrent_dir"] = TORRENT_DIR

    new_config["EZRSS"] = {}
    new_config["EZRSS"]["ezrss"] = int(EZRSS)

    new_config["TVTORRENTS"] = {}
    new_config["TVTORRENTS"]["tvtorrents"] = int(TVTORRENTS)
    new_config["TVTORRENTS"]["tvtorrents_digest"] = TVTORRENTS_DIGEST
    new_config["TVTORRENTS"]["tvtorrents_hash"] = TVTORRENTS_HASH

    new_config["NZBs"] = {}
    new_config["NZBs"]["nzbs"] = int(NZBS)
    new_config["NZBs"]["nzbs_uid"] = NZBS_UID
    new_config["NZBs"]["nzbs_hash"] = NZBS_HASH

    new_config["NZBsRUS"] = {}
    new_config["NZBsRUS"]["nzbsrus"] = int(NZBSRUS)
    new_config["NZBsRUS"]["nzbsrus_uid"] = NZBSRUS_UID
    new_config["NZBsRUS"]["nzbsrus_hash"] = NZBSRUS_HASH

    new_config["NZBMatrix"] = {}
    new_config["NZBMatrix"]["nzbmatrix"] = int(NZBMATRIX)
    new_config["NZBMatrix"]["nzbmatrix_username"] = NZBMATRIX_USERNAME
    new_config["NZBMatrix"]["nzbmatrix_apikey"] = NZBMATRIX_APIKEY

    new_config["Newzbin"] = {}
    new_config["Newzbin"]["newzbin"] = int(NEWZBIN)
    new_config["Newzbin"]["newzbin_username"] = NEWZBIN_USERNAME
    new_config["Newzbin"]["newzbin_password"] = NEWZBIN_PASSWORD

    new_config["Womble"] = {}
    new_config["Womble"]["womble"] = int(WOMBLE)

    new_config["SABnzbd"] = {}
    new_config["SABnzbd"]["sab_username"] = SAB_USERNAME
    new_config["SABnzbd"]["sab_password"] = SAB_PASSWORD
    new_config["SABnzbd"]["sab_apikey"] = SAB_APIKEY
    new_config["SABnzbd"]["sab_category"] = SAB_CATEGORY
    new_config["SABnzbd"]["sab_host"] = SAB_HOST

    new_config["NZBget"] = {}
    new_config["NZBget"]["nzbget_password"] = NZBGET_PASSWORD
    new_config["NZBget"]["nzbget_category"] = NZBGET_CATEGORY
    new_config["NZBget"]["nzbget_host"] = NZBGET_HOST

    new_config["XBMC"] = {}
    new_config["XBMC"]["use_xbmc"] = int(USE_XBMC)
    new_config["XBMC"]["xbmc_notify_onsnatch"] = int(XBMC_NOTIFY_ONSNATCH)
    new_config["XBMC"]["xbmc_notify_ondownload"] = int(XBMC_NOTIFY_ONDOWNLOAD)
    new_config["XBMC"]["xbmc_update_library"] = int(XBMC_UPDATE_LIBRARY)
    new_config["XBMC"]["xbmc_update_full"] = int(XBMC_UPDATE_FULL)
    new_config["XBMC"]["xbmc_host"] = XBMC_HOST
    new_config["XBMC"]["xbmc_username"] = XBMC_USERNAME
    new_config["XBMC"]["xbmc_password"] = XBMC_PASSWORD

    new_config["Plex"] = {}
    new_config["Plex"]["use_plex"] = int(USE_PLEX)
    new_config["Plex"]["plex_notify_onsnatch"] = int(PLEX_NOTIFY_ONSNATCH)
    new_config["Plex"]["plex_notify_ondownload"] = int(PLEX_NOTIFY_ONDOWNLOAD)
    new_config["Plex"]["plex_update_library"] = int(PLEX_UPDATE_LIBRARY)
    new_config["Plex"]["plex_server_host"] = PLEX_SERVER_HOST
    new_config["Plex"]["plex_host"] = PLEX_HOST
    new_config["Plex"]["plex_username"] = PLEX_USERNAME
    new_config["Plex"]["plex_password"] = PLEX_PASSWORD

    new_config["Growl"] = {}
    new_config["Growl"]["use_growl"] = int(USE_GROWL)
    new_config["Growl"]["growl_notify_onsnatch"] = int(GROWL_NOTIFY_ONSNATCH)
    new_config["Growl"]["growl_notify_ondownload"] = int(GROWL_NOTIFY_ONDOWNLOAD)
    new_config["Growl"]["growl_host"] = GROWL_HOST
    new_config["Growl"]["growl_password"] = GROWL_PASSWORD

    new_config["Prowl"] = {}
    new_config["Prowl"]["use_prowl"] = int(USE_PROWL)
    new_config["Prowl"]["prowl_notify_onsnatch"] = int(PROWL_NOTIFY_ONSNATCH)
    new_config["Prowl"]["prowl_notify_ondownload"] = int(PROWL_NOTIFY_ONDOWNLOAD)
    new_config["Prowl"]["prowl_api"] = PROWL_API
    new_config["Prowl"]["prowl_priority"] = PROWL_PRIORITY

    new_config["Twitter"] = {}
    new_config["Twitter"]["use_twitter"] = int(USE_TWITTER)
    new_config["Twitter"]["twitter_notify_onsnatch"] = int(TWITTER_NOTIFY_ONSNATCH)
    new_config["Twitter"]["twitter_notify_ondownload"] = int(TWITTER_NOTIFY_ONDOWNLOAD)
    new_config["Twitter"]["twitter_username"] = TWITTER_USERNAME
    new_config["Twitter"]["twitter_password"] = TWITTER_PASSWORD
    new_config["Twitter"]["twitter_prefix"] = TWITTER_PREFIX

    new_config["Notifo"] = {}
    new_config["Notifo"]["use_notifo"] = int(USE_NOTIFO)
    new_config["Notifo"]["notifo_notify_onsnatch"] = int(NOTIFO_NOTIFY_ONSNATCH)
    new_config["Notifo"]["notifo_notify_ondownload"] = int(NOTIFO_NOTIFY_ONDOWNLOAD)
    new_config["Notifo"]["notifo_username"] = NOTIFO_USERNAME
    new_config["Notifo"]["notifo_apisecret"] = NOTIFO_APISECRET

    new_config["Boxcar"] = {}
    new_config["Boxcar"]["use_boxcar"] = int(USE_BOXCAR)
    new_config["Boxcar"]["boxcar_notify_onsnatch"] = int(BOXCAR_NOTIFY_ONSNATCH)
    new_config["Boxcar"]["boxcar_notify_ondownload"] = int(BOXCAR_NOTIFY_ONDOWNLOAD)
    new_config["Boxcar"]["boxcar_username"] = BOXCAR_USERNAME

    new_config["Libnotify"] = {}
    new_config["Libnotify"]["use_libnotify"] = int(USE_LIBNOTIFY)
    new_config["Libnotify"]["libnotify_notify_onsnatch"] = int(LIBNOTIFY_NOTIFY_ONSNATCH)
    new_config["Libnotify"]["libnotify_notify_ondownload"] = int(LIBNOTIFY_NOTIFY_ONDOWNLOAD)

    new_config["NMJ"] = {}
    new_config["NMJ"]["use_nmj"] = int(USE_NMJ)
    new_config["NMJ"]["nmj_host"] = NMJ_HOST
    new_config["NMJ"]["nmj_database"] = NMJ_DATABASE
    new_config["NMJ"]["nmj_mount"] = NMJ_MOUNT

    new_config["Synology"] = {}
    new_config["Synology"]["use_synoindex"] = int(USE_SYNOINDEX)

    new_config["Trakt"] = {}
    new_config["Trakt"]["use_trakt"] = int(USE_TRAKT)
    new_config["Trakt"]["trakt_username"] = TRAKT_USERNAME
    new_config["Trakt"]["trakt_password"] = TRAKT_PASSWORD
    new_config["Trakt"]["trakt_api"] = TRAKT_API

    new_config["pyTivo"] = {}
    new_config["pyTivo"]["use_pytivo"] = int(USE_PYTIVO)
    new_config["pyTivo"]["pytivo_notify_onsnatch"] = int(PYTIVO_NOTIFY_ONSNATCH)
    new_config["pyTivo"]["pytivo_notify_ondownload"] = int(PYTIVO_NOTIFY_ONDOWNLOAD)
    new_config["pyTivo"]["pyTivo_update_library"] = int(PYTIVO_UPDATE_LIBRARY)
    new_config["pyTivo"]["pytivo_host"] = PYTIVO_HOST
    new_config["pyTivo"]["pytivo_share_name"] = PYTIVO_SHARE_NAME
    new_config["pyTivo"]["pytivo_tivo_name"] = PYTIVO_TIVO_NAME

    new_config["Newznab"] = {}
    new_config["Newznab"]["newznab_data"] = "!!!".join([x.configStr() for x in newznabProviderList])

    new_config["GUI"] = {}
    new_config["GUI"]["coming_eps_layout"] = COMING_EPS_LAYOUT
    new_config["GUI"]["coming_eps_display_paused"] = int(COMING_EPS_DISPLAY_PAUSED)
    new_config["GUI"]["coming_eps_sort"] = COMING_EPS_SORT

    new_config.write()
示例#40
0
def save_config():

    new_config = ConfigObj()
    new_config.filename = sickbeard.CONFIG_FILE

    new_config['General'] = {}
    new_config['General']['log_dir'] = LOG_DIR
    new_config['General']['web_port'] = WEB_PORT
    new_config['General']['web_host'] = WEB_HOST
    new_config['General']['web_ipv6'] = WEB_IPV6
    new_config['General']['web_log'] = int(WEB_LOG)
    new_config['General']['web_root'] = WEB_ROOT
    new_config['General']['web_username'] = WEB_USERNAME
    new_config['General']['web_password'] = WEB_PASSWORD
    new_config['General']['nzb_method'] = NZB_METHOD
    new_config['General']['usenet_retention'] = int(USENET_RETENTION)
    new_config['General']['search_frequency'] = int(SEARCH_FREQUENCY)
    new_config['General']['download_propers'] = int(DOWNLOAD_PROPERS)
    new_config['General']['quality_default'] = int(QUALITY_DEFAULT)
    new_config['General']['season_folders_format'] = SEASON_FOLDERS_FORMAT
    new_config['General']['season_folders_default'] = int(SEASON_FOLDERS_DEFAULT)
    new_config['General']['provider_order'] = ' '.join([x.getID() for x in providers.sortedProviderList()])
    new_config['General']['version_notify'] = int(VERSION_NOTIFY)
    new_config['General']['naming_ep_name'] = int(NAMING_EP_NAME)
    new_config['General']['naming_show_name'] = int(NAMING_SHOW_NAME)
    new_config['General']['naming_ep_type'] = int(NAMING_EP_TYPE)
    new_config['General']['naming_multi_ep_type'] = int(NAMING_MULTI_EP_TYPE)
    new_config['General']['naming_sep_type'] = int(NAMING_SEP_TYPE)
    new_config['General']['naming_use_periods'] = int(NAMING_USE_PERIODS)
    new_config['General']['naming_quality'] = int(NAMING_QUALITY)
    new_config['General']['naming_dates'] = int(NAMING_DATES)
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)

    new_config['General']['use_banner'] = int(USE_BANNER)
    new_config['General']['use_listview'] = int(USE_LISTVIEW)
    new_config['General']['metadata_xbmc'] = metadata_provider_dict['XBMC'].get_config()
    new_config['General']['metadata_mediabrowser'] = metadata_provider_dict['MediaBrowser'].get_config()
    new_config['General']['metadata_ps3'] = metadata_provider_dict['Sony PS3'].get_config()

    new_config['General']['cache_dir'] = CACHE_DIR if CACHE_DIR else 'cache'
    new_config['General']['tv_download_dir'] = TV_DOWNLOAD_DIR
    new_config['General']['keep_processed_dir'] = int(KEEP_PROCESSED_DIR)
    new_config['General']['move_associated_files'] = int(MOVE_ASSOCIATED_FILES)
    new_config['General']['process_automatically'] = int(PROCESS_AUTOMATICALLY)
    new_config['General']['rename_episodes'] = int(RENAME_EPISODES)
    
    new_config['General']['extra_scripts'] = '|'.join(EXTRA_SCRIPTS)
    new_config['General']['git_path'] = GIT_PATH

    new_config['Blackhole'] = {}
    new_config['Blackhole']['nzb_dir'] = NZB_DIR
    new_config['Blackhole']['torrent_dir'] = TORRENT_DIR

    new_config['EZRSS'] = {}
    new_config['EZRSS']['ezrss'] = int(EZRSS)

    new_config['TVBinz'] = {}
    new_config['TVBinz']['tvbinz'] = int(TVBINZ)
    new_config['TVBinz']['tvbinz_uid'] = TVBINZ_UID
    new_config['TVBinz']['tvbinz_hash'] = TVBINZ_HASH
    new_config['TVBinz']['tvbinz_auth'] = TVBINZ_AUTH

    new_config['NZBs'] = {}
    new_config['NZBs']['nzbs'] = int(NZBS)
    new_config['NZBs']['nzbs_uid'] = NZBS_UID
    new_config['NZBs']['nzbs_hash'] = NZBS_HASH

    new_config['NZBsRUS'] = {}
    new_config['NZBsRUS']['nzbsrus'] = int(NZBSRUS)
    new_config['NZBsRUS']['nzbsrus_uid'] = NZBSRUS_UID
    new_config['NZBsRUS']['nzbsrus_hash'] = NZBSRUS_HASH

    new_config['NZBMatrix'] = {}
    new_config['NZBMatrix']['nzbmatrix'] = int(NZBMATRIX)
    new_config['NZBMatrix']['nzbmatrix_username'] = NZBMATRIX_USERNAME
    new_config['NZBMatrix']['nzbmatrix_apikey'] = NZBMATRIX_APIKEY

    new_config['Newzbin'] = {}
    new_config['Newzbin']['newzbin'] = int(NEWZBIN)
    new_config['Newzbin']['newzbin_username'] = NEWZBIN_USERNAME
    new_config['Newzbin']['newzbin_password'] = NEWZBIN_PASSWORD

    new_config['Bin-Req'] = {}
    new_config['Bin-Req']['binreq'] = int(BINREQ)

    new_config['Womble'] = {}
    new_config['Womble']['womble'] = int(WOMBLE)

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['sab_username'] = SAB_USERNAME
    new_config['SABnzbd']['sab_password'] = SAB_PASSWORD
    new_config['SABnzbd']['sab_apikey'] = SAB_APIKEY
    new_config['SABnzbd']['sab_category'] = SAB_CATEGORY
    new_config['SABnzbd']['sab_host'] = SAB_HOST

    new_config['XBMC'] = {}
    new_config['XBMC']['use_xbmc'] = int(USE_XBMC)    
    new_config['XBMC']['xbmc_notify_onsnatch'] = int(XBMC_NOTIFY_ONSNATCH)
    new_config['XBMC']['xbmc_notify_ondownload'] = int(XBMC_NOTIFY_ONDOWNLOAD)
    new_config['XBMC']['xbmc_update_library'] = int(XBMC_UPDATE_LIBRARY)
    new_config['XBMC']['xbmc_update_full'] = int(XBMC_UPDATE_FULL)
    new_config['XBMC']['xbmc_host'] = XBMC_HOST
    new_config['XBMC']['xbmc_username'] = XBMC_USERNAME
    new_config['XBMC']['xbmc_password'] = XBMC_PASSWORD

    new_config['Growl'] = {}
    new_config['Growl']['use_growl'] = int(USE_GROWL)
    new_config['Growl']['growl_notify_onsnatch'] = int(GROWL_NOTIFY_ONSNATCH)
    new_config['Growl']['growl_notify_ondownload'] = int(GROWL_NOTIFY_ONDOWNLOAD) 
    new_config['Growl']['growl_host'] = GROWL_HOST
    new_config['Growl']['growl_password'] = GROWL_PASSWORD

    new_config['Twitter'] = {}
    new_config['Twitter']['use_twitter'] = int(USE_TWITTER)
    new_config['Twitter']['twitter_notify_onsnatch'] = int(TWITTER_NOTIFY_ONSNATCH)
    new_config['Twitter']['twitter_notify_ondownload'] = int(TWITTER_NOTIFY_ONDOWNLOAD)
    new_config['Twitter']['twitter_username'] = TWITTER_USERNAME
    new_config['Twitter']['twitter_password'] = TWITTER_PASSWORD
    new_config['Twitter']['twitter_prefix'] = TWITTER_PREFIX

    new_config['Newznab'] = {}
    new_config['Newznab']['newznab_data'] = '!!!'.join([x.configStr() for x in newznabProviderList])

    new_config['GUI'] = {}
    new_config['GUI']['coming_eps_layout'] = COMING_EPS_LAYOUT
    new_config['GUI']['coming_eps_display_paused'] = int(COMING_EPS_DISPLAY_PAUSED)
    new_config['GUI']['coming_eps_sort'] = COMING_EPS_SORT

    new_config.write()
示例#41
0
import xbmcaddon
from lib.configobj import ConfigObj

__addon__ = xbmcaddon.Addon(id='service.downloadmanager.SickPotatoHead')
__addonhome__ = xbmc.translatePath(__addon__.getAddonInfo('profile'))
sickbeard_launch = (__addon__.getSetting('SICKBEARD_LAUNCH').lower() == 'true')
couchpotato_launch = (
    __addon__.getSetting('COUCHPOTATO_LAUNCH').lower() == 'true')
headphones_launch = (
    __addon__.getSetting('HEADPHONES_LAUNCH').lower() == 'true')

if sickbeard_launch:
    try:
        pSickBeardSettings = xbmc.translatePath(__addonhome__ +
                                                'sickbeard.ini')
        sickBeardConfig = ConfigObj(pSickBeardSettings, create_empty=False)
        sickBeardApiKey = sickBeardConfig['General']['api_key']
        urllib2.urlopen('http://localhost:8082/api/' + sickBeardApiKey +
                        '/?cmd=sb.shutdown')
        xbmc.log('AUDO: Shutting SickBeard down...', level=xbmc.LOGDEBUG)
    except Exception, e:
        xbmc.log('AUDO: SickBeard exception occurred', level=xbmc.LOGERROR)
        xbmc.log(str(e), level=xbmc.LOGERROR)
        pass

if couchpotato_launch:
    try:
        pCouchPotatoServerSettings = xbmc.translatePath(
            __addonhome__ + 'couchpotatoserver.ini')
        couchPotatoServerConfig = ConfigObj(pCouchPotatoServerSettings,
                                            create_empty=False,
示例#42
0
def main():

    # do some preliminary stuff
    sickbeard.MY_FULLNAME = os.path.normpath(os.path.abspath(__file__))
    sickbeard.MY_NAME = os.path.basename(sickbeard.MY_FULLNAME)
    sickbeard.PROG_DIR = os.path.dirname(sickbeard.MY_FULLNAME)
    sickbeard.MY_ARGS = sys.argv[1:]

    try:
        locale.setlocale(locale.LC_ALL, "")
    except (locale.Error, IOError):
        pass
    sickbeard.SYS_ENCODING = locale.getpreferredencoding()
    
    # for OSes that are poorly configured I'll just force UTF-8
    if not sickbeard.SYS_ENCODING or sickbeard.SYS_ENCODING in ('ANSI_X3.4-1968', 'US-ASCII'):
        sickbeard.SYS_ENCODING = 'UTF-8'

    sickbeard.CONFIG_FILE = os.path.join(sickbeard.PROG_DIR, "config.ini")

    # need console logging for SickBeard.py and SickBeard-console.exe
    consoleLogging = (not hasattr(sys, "frozen")) or (sickbeard.MY_NAME.lower().find('-console') > 0)

    # rename the main thread
    threading.currentThread().name = "MAIN"

    try:
        opts, args = getopt.getopt(sys.argv[1:], "qfdp:", ['quiet', 'forceupdate', 'daemon', 'port=', 'tvbinz'])
    except getopt.GetoptError:
        print "Available options: --quiet, --forceupdate, --port, --daemon"
        sys.exit()

    forceUpdate = False
    forcedPort = None

    for o, a in opts:
        # for now we'll just silence the logging
        if (o in ('-q', '--quiet')):
            consoleLogging = False
        # for now we'll just silence the logging
        if (o in ('--tvbinz')):
            sickbeard.SHOW_TVBINZ = True

        # should we update right away?
        if (o in ('-f', '--forceupdate')):
            forceUpdate = True

        # use a different port
        if (o in ('-p', '--port')):
            forcedPort = int(a)

        # Run as a daemon
        if (o in ('-d', '--daemon')):
            if sys.platform == 'win32':
                print "Daemonize not supported under Windows, starting normally"
            else:
                consoleLogging = False
                sickbeard.DAEMON = True

    if consoleLogging:
        print "Starting up Sick Beard "+SICKBEARD_VERSION+" from " + sickbeard.CONFIG_FILE

    # load the config and publish it to the sickbeard package
    if not os.path.isfile(sickbeard.CONFIG_FILE):
        logger.log(u"Unable to find config.ini, all settings will be default", logger.ERROR)

    sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)

    # initialize the config and our threads
    sickbeard.initialize(consoleLogging=consoleLogging)

    sickbeard.showList = []

    if sickbeard.DAEMON:
        daemonize()
    
    # use this pid for everything
    sickbeard.PID = os.getpid()

    if forcedPort:
        logger.log(u"Forcing web server to port "+str(forcedPort))
        startPort = forcedPort
    else:
        startPort = sickbeard.WEB_PORT

    logger.log(u"Starting Sick Beard on http://localhost:"+str(startPort))

    if sickbeard.WEB_LOG:
        log_dir = sickbeard.LOG_DIR
    else:
        log_dir = None

    # sickbeard.WEB_HOST is available as a configuration value in various
    # places but is not configurable. It is supported here for historic
    # reasons.
    if sickbeard.WEB_HOST and sickbeard.WEB_HOST != '0.0.0.0':
        webhost = sickbeard.WEB_HOST
    else:
        if sickbeard.WEB_IPV6:
            webhost = '::'
        else:
            webhost = '0.0.0.0'

    try:
        initWebServer({
                'port':      startPort,
                'host':      webhost,
                'data_root': os.path.join(sickbeard.PROG_DIR, 'data'),
                'web_root':  sickbeard.WEB_ROOT,
                'log_dir':   log_dir,
                'username':  sickbeard.WEB_USERNAME,
                'password':  sickbeard.WEB_PASSWORD,
        })
    except IOError:
        logger.log(u"Unable to start web server, is something else running on port %d?" % startPort, logger.ERROR)
        if sickbeard.LAUNCH_BROWSER:
            logger.log(u"Launching browser and exiting", logger.ERROR)
            sickbeard.launchBrowser(startPort)
        sys.exit()

    # build from the DB to start with
    logger.log(u"Loading initial show list")
    loadShowsFromDB()

    # fire up all our threads
    sickbeard.start()

    # launch browser if we're supposed to
    if sickbeard.LAUNCH_BROWSER:
        sickbeard.launchBrowser(startPort)

    # start an update if we're supposed to
    if forceUpdate:
        sickbeard.showUpdateScheduler.action.run(force=True)

    # stay alive while my threads do the work
    while (True):

        time.sleep(1)

    return
示例#43
0
def save_config():

    new_config = ConfigObj()
    new_config.filename = sickbeard.CONFIG_FILE

    new_config["General"] = {}
    new_config["General"]["log_dir"] = LOG_DIR
    new_config["General"]["web_port"] = WEB_PORT
    new_config["General"]["web_host"] = WEB_HOST
    new_config["General"]["web_ipv6"] = WEB_IPV6
    new_config["General"]["web_log"] = int(WEB_LOG)
    new_config["General"]["web_root"] = WEB_ROOT
    new_config["General"]["web_username"] = WEB_USERNAME
    new_config["General"]["web_password"] = WEB_PASSWORD
    new_config["General"]["nzb_method"] = NZB_METHOD
    new_config["General"]["usenet_retention"] = int(USENET_RETENTION)
    new_config["General"]["search_frequency"] = int(SEARCH_FREQUENCY)
    new_config["General"]["backlog_search_frequency"] = int(BACKLOG_SEARCH_FREQUENCY)
    new_config["General"]["use_nzb"] = int(USE_NZB)
    new_config["General"]["download_propers"] = int(DOWNLOAD_PROPERS)
    new_config["General"]["quality_default"] = int(QUALITY_DEFAULT)
    new_config["General"]["season_folders_format"] = SEASON_FOLDERS_FORMAT
    new_config["General"]["season_folders_default"] = int(SEASON_FOLDERS_DEFAULT)
    new_config["General"]["provider_order"] = " ".join([x.getID() for x in providers.sortedProviderList()])
    new_config["General"]["version_notify"] = int(VERSION_NOTIFY)
    new_config["General"]["naming_ep_name"] = int(NAMING_EP_NAME)
    new_config["General"]["naming_show_name"] = int(NAMING_SHOW_NAME)
    new_config["General"]["naming_ep_type"] = int(NAMING_EP_TYPE)
    new_config["General"]["naming_multi_ep_type"] = int(NAMING_MULTI_EP_TYPE)
    new_config["General"]["naming_sep_type"] = int(NAMING_SEP_TYPE)
    new_config["General"]["naming_use_periods"] = int(NAMING_USE_PERIODS)
    new_config["General"]["naming_quality"] = int(NAMING_QUALITY)
    new_config["General"]["naming_dates"] = int(NAMING_DATES)
    new_config["General"]["use_torrent"] = int(USE_TORRENT)
    new_config["General"]["launch_browser"] = int(LAUNCH_BROWSER)
    new_config["General"]["metadata_type"] = METADATA_TYPE
    new_config["General"]["metadata_show"] = int(METADATA_SHOW)
    new_config["General"]["metadata_episode"] = int(METADATA_EPISODE)
    new_config["General"]["art_poster"] = int(ART_POSTER)
    new_config["General"]["art_fanart"] = int(ART_FANART)
    new_config["General"]["art_thumbnails"] = int(ART_THUMBNAILS)
    new_config["General"]["art_season_thumbnails"] = int(ART_SEASON_THUMBNAILS)
    new_config["General"]["cache_dir"] = CACHE_DIR if CACHE_DIR else "cache"
    new_config["General"]["tv_download_dir"] = TV_DOWNLOAD_DIR
    new_config["General"]["keep_processed_dir"] = int(KEEP_PROCESSED_DIR)
    new_config["General"]["process_automatically"] = int(PROCESS_AUTOMATICALLY)
    new_config["General"]["rename_episodes"] = int(RENAME_EPISODES)

    new_config["General"]["extra_scripts"] = "|".join(EXTRA_SCRIPTS)
    new_config["General"]["git_path"] = GIT_PATH

    new_config["Blackhole"] = {}
    new_config["Blackhole"]["nzb_dir"] = NZB_DIR
    new_config["Blackhole"]["torrent_dir"] = TORRENT_DIR

    new_config["TVBinz"] = {}
    new_config["TVBinz"]["tvbinz"] = int(TVBINZ)
    new_config["TVBinz"]["tvbinz_uid"] = TVBINZ_UID
    new_config["TVBinz"]["tvbinz_hash"] = TVBINZ_HASH
    new_config["TVBinz"]["tvbinz_auth"] = TVBINZ_AUTH

    new_config["NZBs"] = {}
    new_config["NZBs"]["nzbs"] = int(NZBS)
    new_config["NZBs"]["nzbs_uid"] = NZBS_UID
    new_config["NZBs"]["nzbs_hash"] = NZBS_HASH

    new_config["NZBsRUS"] = {}
    new_config["NZBsRUS"]["nzbsrus"] = int(NZBSRUS)
    new_config["NZBsRUS"]["nzbsrus_uid"] = NZBSRUS_UID
    new_config["NZBsRUS"]["nzbsrus_hash"] = NZBSRUS_HASH

    new_config["NZBMatrix"] = {}
    new_config["NZBMatrix"]["nzbmatrix"] = int(NZBMATRIX)
    new_config["NZBMatrix"]["nzbmatrix_username"] = NZBMATRIX_USERNAME
    new_config["NZBMatrix"]["nzbmatrix_apikey"] = NZBMATRIX_APIKEY

    new_config["Newzbin"] = {}
    new_config["Newzbin"]["newzbin"] = int(NEWZBIN)
    new_config["Newzbin"]["newzbin_username"] = NEWZBIN_USERNAME
    new_config["Newzbin"]["newzbin_password"] = NEWZBIN_PASSWORD

    new_config["Bin-Req"] = {}
    new_config["Bin-Req"]["binreq"] = int(BINREQ)

    new_config["Womble"] = {}
    new_config["Womble"]["womble"] = int(WOMBLE)

    new_config["SABnzbd"] = {}
    new_config["SABnzbd"]["sab_username"] = SAB_USERNAME
    new_config["SABnzbd"]["sab_password"] = SAB_PASSWORD
    new_config["SABnzbd"]["sab_apikey"] = SAB_APIKEY
    new_config["SABnzbd"]["sab_category"] = SAB_CATEGORY
    new_config["SABnzbd"]["sab_host"] = SAB_HOST

    new_config["XBMC"] = {}
    new_config["XBMC"]["xbmc_notify_onsnatch"] = int(XBMC_NOTIFY_ONSNATCH)
    new_config["XBMC"]["xbmc_notify_ondownload"] = int(XBMC_NOTIFY_ONDOWNLOAD)
    new_config["XBMC"]["xbmc_update_library"] = int(XBMC_UPDATE_LIBRARY)
    new_config["XBMC"]["xbmc_update_full"] = int(XBMC_UPDATE_FULL)
    new_config["XBMC"]["xbmc_host"] = XBMC_HOST
    new_config["XBMC"]["xbmc_username"] = XBMC_USERNAME
    new_config["XBMC"]["xbmc_password"] = XBMC_PASSWORD

    new_config["Growl"] = {}
    new_config["Growl"]["use_growl"] = int(USE_GROWL)
    new_config["Growl"]["growl_host"] = GROWL_HOST
    new_config["Growl"]["growl_password"] = GROWL_PASSWORD

    new_config["Twitter"] = {}
    new_config["Twitter"]["use_twitter"] = int(USE_TWITTER)
    new_config["Twitter"]["twitter_username"] = TWITTER_USERNAME
    new_config["Twitter"]["twitter_password"] = TWITTER_PASSWORD
    new_config["Twitter"]["twitter_prefix"] = TWITTER_PREFIX

    new_config["Newznab"] = {}
    new_config["Newznab"]["newznab_data"] = "!!!".join([x.configStr() for x in newznabProviderList])

    new_config.write()
示例#44
0
class SickRage(object):
    def __init__(self):
        # system event callback for shutdown/restart
        sickbeard.events = Events(self.shutdown)

        # daemon constants
        self.runAsDaemon = False
        self.CREATEPID = False
        self.PIDFILE = ''

        # webserver constants
        self.webserver = None
        self.forceUpdate = False
        self.forcedPort = None
        self.noLaunch = False

    def help_message(self):
        """
        print help message for commandline options
        """
        help_msg = "\n"
        help_msg += "Usage: " + sickbeard.MY_FULLNAME + " <option> <another option>\n"
        help_msg += "\n"
        help_msg += "Options:\n"
        help_msg += "\n"
        help_msg += "    -h          --help              Prints this message\n"
        help_msg += "    -f          --forceupdate       Force update all shows in the DB (from tvdb) on startup\n"
        help_msg += "    -q          --quiet             Disables logging to console\n"
        help_msg += "                --nolaunch          Suppress launching web browser on startup\n"

        if sys.platform == 'win32' or sys.platform == 'darwin':
            help_msg += "    -d          --daemon            Running as real daemon is not supported on Windows\n"
            help_msg += "                                    On Windows and MAC, --daemon is substituted with: --quiet --nolaunch\n"
        else:
            help_msg += "    -d          --daemon            Run as double forked daemon (includes options --quiet --nolaunch)\n"
            help_msg += "                --pidfile=<path>    Combined with --daemon creates a pidfile (full path including filename)\n"

        help_msg += "    -p <port>   --port=<port>       Override default/configured port to listen on\n"
        help_msg += "                --datadir=<path>    Override folder (full path) as location for\n"
        help_msg += "                                    storing database, configfile, cache, logfiles \n"
        help_msg += "                                    Default: " + sickbeard.PROG_DIR + "\n"
        help_msg += "                --config=<path>     Override config filename (full path including filename)\n"
        help_msg += "                                    to load configuration from \n"
        help_msg += "                                    Default: config.ini in " + sickbeard.PROG_DIR + " or --datadir location\n"
        help_msg += "                --noresize          Prevent resizing of the banner/posters even if PIL is installed\n"

        return help_msg

    def start(self):
        # do some preliminary stuff
        sickbeard.MY_FULLNAME = os.path.normpath(os.path.abspath(__file__))
        sickbeard.MY_NAME = os.path.basename(sickbeard.MY_FULLNAME)
        sickbeard.PROG_DIR = os.path.dirname(sickbeard.MY_FULLNAME)
        sickbeard.DATA_DIR = sickbeard.PROG_DIR
        sickbeard.MY_ARGS = sys.argv[1:]
        sickbeard.SYS_ENCODING = None

        try:
            locale.setlocale(locale.LC_ALL, "")
            sickbeard.SYS_ENCODING = locale.getpreferredencoding()
        except (locale.Error, IOError):
            pass

        # For OSes that are poorly configured I'll just randomly force UTF-8
        if not sickbeard.SYS_ENCODING or sickbeard.SYS_ENCODING in ('ANSI_X3.4-1968', 'US-ASCII', 'ASCII'):
            sickbeard.SYS_ENCODING = 'UTF-8'

        if not hasattr(sys, "setdefaultencoding"):
            reload(sys)
  
        if sys.platform == 'win32':
            if sys.getwindowsversion()[0] >= 6 and sys.stdout.encoding == 'cp65001':
                sickbeard.SYS_ENCODING = 'UTF-8'

        try:
            # pylint: disable=E1101
            # On non-unicode builds this will raise an AttributeError, if encoding type is not valid it throws a LookupError
            sys.setdefaultencoding(sickbeard.SYS_ENCODING)
        except:
            sys.exit("Sorry, you MUST add the SickRage folder to the PYTHONPATH environment variable\n" +
                     "or find another way to force Python to use " + sickbeard.SYS_ENCODING + " for string encoding.")

        # Need console logging for SickBeard.py and SickBeard-console.exe
        self.consoleLogging = (not hasattr(sys, "frozen")) or (sickbeard.MY_NAME.lower().find('-console') > 0)

        # Rename the main thread
        threading.currentThread().name = "MAIN"

        try:
            opts, args = getopt.getopt(sys.argv[1:], "hfqdp::",
                                       ['help', 'forceupdate', 'quiet', 'nolaunch', 'daemon', 'pidfile=', 'port=',
                                        'datadir=', 'config=', 'noresize'])  # @UnusedVariable
        except getopt.GetoptError:
            sys.exit(self.help_message())

        for o, a in opts:
            # Prints help message
            if o in ('-h', '--help'):
                sys.exit(self.help_message())

            # For now we'll just silence the logging
            if o in ('-q', '--quiet'):
                self.consoleLogging = False

            # Should we update (from indexer) all shows in the DB right away?
            if o in ('-f', '--forceupdate'):
                self.forceUpdate = True

            # Suppress launching web browser
            # Needed for OSes without default browser assigned
            # Prevent duplicate browser window when restarting in the app
            if o in ('--nolaunch',):
                self.noLaunch = True

            # Override default/configured port
            if o in ('-p', '--port'):
                try:
                    self.forcedPort = int(a)
                except ValueError:
                    sys.exit("Port: " + str(a) + " is not a number. Exiting.")

            # Run as a double forked daemon
            if o in ('-d', '--daemon'):
                self.runAsDaemon = True
                # When running as daemon disable consoleLogging and don't start browser
                self.consoleLogging = False
                self.noLaunch = True

                if sys.platform == 'win32' or sys.platform == 'darwin':
                    self.runAsDaemon = False

            # Write a pidfile if requested
            if o in ('--pidfile',):
                self.CREATEPID = True
                self.PIDFILE = str(a)

                # If the pidfile already exists, sickbeard may still be running, so exit
                if os.path.exists(self.PIDFILE):
                    sys.exit("PID file: " + self.PIDFILE + " already exists. Exiting.")

            # Specify folder to load the config file from
            if o in ('--config',):
                sickbeard.CONFIG_FILE = os.path.abspath(a)

            # Specify folder to use as the data dir
            if o in ('--datadir',):
                sickbeard.DATA_DIR = os.path.abspath(a)

            # Prevent resizing of the banner/posters even if PIL is installed
            if o in ('--noresize',):
                sickbeard.NO_RESIZE = True

        # The pidfile is only useful in daemon mode, make sure we can write the file properly
        if self.CREATEPID:
            if self.runAsDaemon:
                pid_dir = os.path.dirname(self.PIDFILE)
                if not os.access(pid_dir, os.F_OK):
                    sys.exit("PID dir: " + pid_dir + " doesn't exist. Exiting.")
                if not os.access(pid_dir, os.W_OK):
                    sys.exit("PID dir: " + pid_dir + " must be writable (write permissions). Exiting.")

            else:
                if self.consoleLogging:
                    sys.stdout.write("Not running in daemon mode. PID file creation disabled.\n")

                self.CREATEPID = False

        # If they don't specify a config file then put it in the data dir
        if not sickbeard.CONFIG_FILE:
            sickbeard.CONFIG_FILE = os.path.join(sickbeard.DATA_DIR, "config.ini")

        # Make sure that we can create the data dir
        if not os.access(sickbeard.DATA_DIR, os.F_OK):
            try:
                os.makedirs(sickbeard.DATA_DIR, 0744)
            except os.error, e:
                raise SystemExit("Unable to create datadir '" + sickbeard.DATA_DIR + "'")

        # Make sure we can write to the data dir
        if not os.access(sickbeard.DATA_DIR, os.W_OK):
            raise SystemExit("Datadir must be writeable '" + sickbeard.DATA_DIR + "'")

        # Make sure we can write to the config file
        if not os.access(sickbeard.CONFIG_FILE, os.W_OK):
            if os.path.isfile(sickbeard.CONFIG_FILE):
                raise SystemExit("Config file '" + sickbeard.CONFIG_FILE + "' must be writeable.")
            elif not os.access(os.path.dirname(sickbeard.CONFIG_FILE), os.W_OK):
                raise SystemExit(
                    "Config file root dir '" + os.path.dirname(sickbeard.CONFIG_FILE) + "' must be writeable.")

        os.chdir(sickbeard.DATA_DIR)

        # Check if we need to perform a restore first
        try:
            restoreDir = os.path.join(sickbeard.DATA_DIR, 'restore')
            if self.consoleLogging and os.path.exists(restoreDir):
                if self.restoreDB(restoreDir, sickbeard.DATA_DIR):
                    sys.stdout.write("Restore: restoring DB and config.ini successful...\n")
                else:
                    sys.stdout.write("Restore: restoring DB and config.ini FAILED!\n")
        except Exception as e:
            sys.stdout.write("Restore: restoring DB and config.ini FAILED!\n")

        # Load the config and publish it to the sickbeard package
        if self.consoleLogging and not os.path.isfile(sickbeard.CONFIG_FILE):
            sys.stdout.write("Unable to find '" + sickbeard.CONFIG_FILE + "' , all settings will be default!" + "\n")

        sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)

        # Initialize the config and our threads
        sickbeard.initialize(consoleLogging=self.consoleLogging)

        if self.runAsDaemon:
            self.daemonize()

        # Get PID
        sickbeard.PID = os.getpid()

        # Build from the DB to start with
        self.loadShowsFromDB()

        if self.forcedPort:
            logger.log(u"Forcing web server to port " + str(self.forcedPort))
            self.startPort = self.forcedPort
        else:
            self.startPort = sickbeard.WEB_PORT

        if sickbeard.WEB_LOG:
            self.log_dir = sickbeard.LOG_DIR
        else:
            self.log_dir = None

        # sickbeard.WEB_HOST is available as a configuration value in various
        # places but is not configurable. It is supported here for historic reasons.
        if sickbeard.WEB_HOST and sickbeard.WEB_HOST != '0.0.0.0':
            self.webhost = sickbeard.WEB_HOST
        else:
            if sickbeard.WEB_IPV6:
                self.webhost = '::'
            else:
                self.webhost = '0.0.0.0'

        # web server options
        self.web_options = {
            'port': int(self.startPort),
            'host': self.webhost,
            'data_root': os.path.join(sickbeard.PROG_DIR, 'gui', sickbeard.GUI_NAME),
            'web_root': sickbeard.WEB_ROOT,
            'log_dir': self.log_dir,
            'username': sickbeard.WEB_USERNAME,
            'password': sickbeard.WEB_PASSWORD,
            'enable_https': sickbeard.ENABLE_HTTPS,
            'handle_reverse_proxy': sickbeard.HANDLE_REVERSE_PROXY,
            'https_cert': os.path.join(sickbeard.PROG_DIR, sickbeard.HTTPS_CERT),
            'https_key': os.path.join(sickbeard.PROG_DIR, sickbeard.HTTPS_KEY),
        }

        # start web server
        try:
            self.webserver = SRWebServer(self.web_options)
            self.webserver.start()
        except IOError:
            logger.log(u"Unable to start web server, is something else running on port %d?" % self.startPort,
                       logger.ERROR)
            if sickbeard.LAUNCH_BROWSER and not self.runAsDaemon:
                logger.log(u"Launching browser and exiting", logger.ERROR)
                sickbeard.launchBrowser('https' if sickbeard.ENABLE_HTTPS else 'http', self.startPort, sickbeard.WEB_ROOT)
            os._exit(1)

        if self.consoleLogging:
            print "Starting up SickRage " + sickbeard.BRANCH + " from " + sickbeard.CONFIG_FILE

        # Fire up all our threads
        sickbeard.start()

        # Build internal name cache
        name_cache.buildNameCache()

        # refresh network timezones
        network_timezones.update_network_dict()

        # sure, why not?
        if sickbeard.USE_FAILED_DOWNLOADS:
            failed_history.trimHistory()

        # Start an update if we're supposed to
        if self.forceUpdate or sickbeard.UPDATE_SHOWS_ON_START:
            sickbeard.showUpdateScheduler.forceRun()

        # Launch browser
        if sickbeard.LAUNCH_BROWSER and not (self.noLaunch or self.runAsDaemon):
            sickbeard.launchBrowser('https' if sickbeard.ENABLE_HTTPS else 'http', self.startPort, sickbeard.WEB_ROOT)

        # main loop
        while (True):
            time.sleep(1)
示例#45
0
def save_config():

    new_config = ConfigObj()
    new_config.filename = CONFIG_FILE

    new_config['General'] = {}
    new_config['General']['config_version'] = CONFIG_VERSION
    new_config['General']['log_dir'] = ACTUAL_LOG_DIR if ACTUAL_LOG_DIR else 'Logs'
    new_config['General']['web_port'] = WEB_PORT
    new_config['General']['web_host'] = WEB_HOST
    new_config['General']['web_ipv6'] = int(WEB_IPV6)
    new_config['General']['web_log'] = int(WEB_LOG)
    new_config['General']['web_root'] = WEB_ROOT
    new_config['General']['web_username'] = WEB_USERNAME
    new_config['General']['web_password'] = WEB_PASSWORD
    new_config['General']['anon_redirect'] = ANON_REDIRECT
    new_config['General']['use_api'] = int(USE_API)
    new_config['General']['api_key'] = API_KEY
    new_config['General']['enable_https'] = int(ENABLE_HTTPS)
    new_config['General']['https_cert'] = HTTPS_CERT
    new_config['General']['https_key'] = HTTPS_KEY

    new_config['General']['use_nzbs'] = int(USE_NZBS)
    new_config['General']['use_torrents'] = int(USE_TORRENTS)
    new_config['General']['nzb_method'] = NZB_METHOD
    new_config['General']['usenet_retention'] = int(USENET_RETENTION)
    new_config['General']['search_frequency'] = int(SEARCH_FREQUENCY)
    new_config['General']['download_propers'] = int(DOWNLOAD_PROPERS)
    new_config['General']['quality_default'] = int(QUALITY_DEFAULT)
    new_config['General']['status_default'] = int(STATUS_DEFAULT)
    new_config['General']['flatten_folders_default'] = int(FLATTEN_FOLDERS_DEFAULT)
    new_config['General']['provider_order'] = ' '.join(PROVIDER_ORDER)
    new_config['General']['version_notify'] = int(VERSION_NOTIFY)
    new_config['General']['naming_pattern'] = NAMING_PATTERN
    new_config['General']['naming_custom_abd'] = int(NAMING_CUSTOM_ABD)
    new_config['General']['naming_abd_pattern'] = NAMING_ABD_PATTERN
    new_config['General']['naming_multi_ep'] = int(NAMING_MULTI_EP)
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)

    new_config['General']['use_listview'] = int(USE_LISTVIEW)
    new_config['General']['metadata_xbmc'] = METADATA_XBMC
    new_config['General']['metadata_xbmc_12plus'] = METADATA_XBMC_12PLUS
    new_config['General']['metadata_mediabrowser'] = METADATA_MEDIABROWSER
    new_config['General']['metadata_ps3'] = METADATA_PS3
    new_config['General']['metadata_wdtv'] = METADATA_WDTV
    new_config['General']['metadata_tivo'] = METADATA_TIVO
    new_config['General']['metadata_mede8er'] = METADATA_MEDE8ER

    new_config['General']['cache_dir'] = ACTUAL_CACHE_DIR if ACTUAL_CACHE_DIR else 'cache'
    new_config['General']['root_dirs'] = ROOT_DIRS if ROOT_DIRS else ''
    new_config['General']['tv_download_dir'] = TV_DOWNLOAD_DIR
    new_config['General']['keep_processed_dir'] = int(KEEP_PROCESSED_DIR)
    new_config['General']['move_associated_files'] = int(MOVE_ASSOCIATED_FILES)
    new_config['General']['process_automatically'] = int(PROCESS_AUTOMATICALLY)
    new_config['General']['rename_episodes'] = int(RENAME_EPISODES)
    new_config['General']['create_missing_show_dirs'] = int(CREATE_MISSING_SHOW_DIRS)
    new_config['General']['add_shows_wo_dir'] = int(ADD_SHOWS_WO_DIR)

    new_config['General']['extra_scripts'] = '|'.join(EXTRA_SCRIPTS)
    new_config['General']['git_path'] = GIT_PATH
    new_config['General']['ignore_words'] = IGNORE_WORDS

    new_config['Blackhole'] = {}
    new_config['Blackhole']['nzb_dir'] = NZB_DIR
    new_config['Blackhole']['torrent_dir'] = TORRENT_DIR

    new_config['EZRSS'] = {}
    new_config['EZRSS']['ezrss'] = int(EZRSS)

    new_config['HDBITS'] = {}
    new_config['HDBITS']['hdbits'] = int(HDBITS)
    new_config['HDBITS']['hdbits_username'] = HDBITS_USERNAME
    new_config['HDBITS']['hdbits_passkey'] = HDBITS_PASSKEY

    new_config['TVTORRENTS'] = {}
    new_config['TVTORRENTS']['tvtorrents'] = int(TVTORRENTS)
    new_config['TVTORRENTS']['tvtorrents_digest'] = TVTORRENTS_DIGEST
    new_config['TVTORRENTS']['tvtorrents_hash'] = TVTORRENTS_HASH

    new_config['BTN'] = {}
    new_config['BTN']['btn'] = int(BTN)
    new_config['BTN']['btn_api_key'] = BTN_API_KEY

    new_config['TorrentLeech'] = {}
    new_config['TorrentLeech']['torrentleech'] = int(TORRENTLEECH)
    new_config['TorrentLeech']['torrentleech_key'] = TORRENTLEECH_KEY

    new_config['NZBs'] = {}
    new_config['NZBs']['nzbs'] = int(NZBS)
    new_config['NZBs']['nzbs_uid'] = NZBS_UID
    new_config['NZBs']['nzbs_hash'] = NZBS_HASH

    new_config['Womble'] = {}
    new_config['Womble']['womble'] = int(WOMBLE)

    new_config['omgwtfnzbs'] = {}
    new_config['omgwtfnzbs']['omgwtfnzbs'] = int(OMGWTFNZBS)
    new_config['omgwtfnzbs']['omgwtfnzbs_username'] = OMGWTFNZBS_USERNAME
    new_config['omgwtfnzbs']['omgwtfnzbs_apikey'] = OMGWTFNZBS_APIKEY

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['sab_username'] = SAB_USERNAME
    new_config['SABnzbd']['sab_password'] = SAB_PASSWORD
    new_config['SABnzbd']['sab_apikey'] = SAB_APIKEY
    new_config['SABnzbd']['sab_category'] = SAB_CATEGORY
    new_config['SABnzbd']['sab_host'] = SAB_HOST

    new_config['NZBget'] = {}
    new_config['NZBget']['nzbget_username'] = NZBGET_USERNAME
    new_config['NZBget']['nzbget_password'] = NZBGET_PASSWORD
    new_config['NZBget']['nzbget_category'] = NZBGET_CATEGORY
    new_config['NZBget']['nzbget_host'] = NZBGET_HOST

    new_config['XBMC'] = {}
    new_config['XBMC']['use_xbmc'] = int(USE_XBMC)
    new_config['XBMC']['xbmc_always_on'] = int(XBMC_ALWAYS_ON)
    new_config['XBMC']['xbmc_notify_onsnatch'] = int(XBMC_NOTIFY_ONSNATCH)
    new_config['XBMC']['xbmc_notify_ondownload'] = int(XBMC_NOTIFY_ONDOWNLOAD)
    new_config['XBMC']['xbmc_update_library'] = int(XBMC_UPDATE_LIBRARY)
    new_config['XBMC']['xbmc_update_full'] = int(XBMC_UPDATE_FULL)
    new_config['XBMC']['xbmc_update_onlyfirst'] = int(XBMC_UPDATE_ONLYFIRST)
    new_config['XBMC']['xbmc_host'] = XBMC_HOST
    new_config['XBMC']['xbmc_username'] = XBMC_USERNAME
    new_config['XBMC']['xbmc_password'] = XBMC_PASSWORD

    new_config['Plex'] = {}
    new_config['Plex']['use_plex'] = int(USE_PLEX)
    new_config['Plex']['plex_notify_onsnatch'] = int(PLEX_NOTIFY_ONSNATCH)
    new_config['Plex']['plex_notify_ondownload'] = int(PLEX_NOTIFY_ONDOWNLOAD)
    new_config['Plex']['plex_update_library'] = int(PLEX_UPDATE_LIBRARY)
    new_config['Plex']['plex_server_host'] = PLEX_SERVER_HOST
    new_config['Plex']['plex_host'] = PLEX_HOST
    new_config['Plex']['plex_username'] = PLEX_USERNAME
    new_config['Plex']['plex_password'] = PLEX_PASSWORD

    new_config['Growl'] = {}
    new_config['Growl']['use_growl'] = int(USE_GROWL)
    new_config['Growl']['growl_notify_onsnatch'] = int(GROWL_NOTIFY_ONSNATCH)
    new_config['Growl']['growl_notify_ondownload'] = int(GROWL_NOTIFY_ONDOWNLOAD)
    new_config['Growl']['growl_host'] = GROWL_HOST
    new_config['Growl']['growl_password'] = GROWL_PASSWORD

    new_config['Prowl'] = {}
    new_config['Prowl']['use_prowl'] = int(USE_PROWL)
    new_config['Prowl']['prowl_notify_onsnatch'] = int(PROWL_NOTIFY_ONSNATCH)
    new_config['Prowl']['prowl_notify_ondownload'] = int(PROWL_NOTIFY_ONDOWNLOAD)
    new_config['Prowl']['prowl_api'] = PROWL_API
    new_config['Prowl']['prowl_priority'] = PROWL_PRIORITY

    new_config['Twitter'] = {}
    new_config['Twitter']['use_twitter'] = int(USE_TWITTER)
    new_config['Twitter']['twitter_notify_onsnatch'] = int(TWITTER_NOTIFY_ONSNATCH)
    new_config['Twitter']['twitter_notify_ondownload'] = int(TWITTER_NOTIFY_ONDOWNLOAD)
    new_config['Twitter']['twitter_username'] = TWITTER_USERNAME
    new_config['Twitter']['twitter_password'] = TWITTER_PASSWORD
    new_config['Twitter']['twitter_prefix'] = TWITTER_PREFIX

    new_config['Boxcar'] = {}
    new_config['Boxcar']['use_boxcar'] = int(USE_BOXCAR)
    new_config['Boxcar']['boxcar_notify_onsnatch'] = int(BOXCAR_NOTIFY_ONSNATCH)
    new_config['Boxcar']['boxcar_notify_ondownload'] = int(BOXCAR_NOTIFY_ONDOWNLOAD)
    new_config['Boxcar']['boxcar_username'] = BOXCAR_USERNAME

    new_config['Pushover'] = {}
    new_config['Pushover']['use_pushover'] = int(USE_PUSHOVER)
    new_config['Pushover']['pushover_notify_onsnatch'] = int(PUSHOVER_NOTIFY_ONSNATCH)
    new_config['Pushover']['pushover_notify_ondownload'] = int(PUSHOVER_NOTIFY_ONDOWNLOAD)
    new_config['Pushover']['pushover_userkey'] = PUSHOVER_USERKEY

    new_config['Libnotify'] = {}
    new_config['Libnotify']['use_libnotify'] = int(USE_LIBNOTIFY)
    new_config['Libnotify']['libnotify_notify_onsnatch'] = int(LIBNOTIFY_NOTIFY_ONSNATCH)
    new_config['Libnotify']['libnotify_notify_ondownload'] = int(LIBNOTIFY_NOTIFY_ONDOWNLOAD)

    new_config['NMJ'] = {}
    new_config['NMJ']['use_nmj'] = int(USE_NMJ)
    new_config['NMJ']['nmj_host'] = NMJ_HOST
    new_config['NMJ']['nmj_database'] = NMJ_DATABASE
    new_config['NMJ']['nmj_mount'] = NMJ_MOUNT

    new_config['Synology'] = {}
    new_config['Synology']['use_synoindex'] = int(USE_SYNOINDEX)

    new_config['NMJv2'] = {}
    new_config['NMJv2']['use_nmjv2'] = int(USE_NMJv2)
    new_config['NMJv2']['nmjv2_host'] = NMJv2_HOST
    new_config['NMJv2']['nmjv2_database'] = NMJv2_DATABASE
    new_config['NMJv2']['nmjv2_dbloc'] = NMJv2_DBLOC

    new_config['Trakt'] = {}
    new_config['Trakt']['use_trakt'] = int(USE_TRAKT)
    new_config['Trakt']['trakt_username'] = TRAKT_USERNAME
    new_config['Trakt']['trakt_password'] = TRAKT_PASSWORD
    new_config['Trakt']['trakt_api'] = TRAKT_API

    new_config['pyTivo'] = {}
    new_config['pyTivo']['use_pytivo'] = int(USE_PYTIVO)
    new_config['pyTivo']['pytivo_notify_onsnatch'] = int(PYTIVO_NOTIFY_ONSNATCH)
    new_config['pyTivo']['pytivo_notify_ondownload'] = int(PYTIVO_NOTIFY_ONDOWNLOAD)
    new_config['pyTivo']['pyTivo_update_library'] = int(PYTIVO_UPDATE_LIBRARY)
    new_config['pyTivo']['pytivo_host'] = PYTIVO_HOST
    new_config['pyTivo']['pytivo_share_name'] = PYTIVO_SHARE_NAME
    new_config['pyTivo']['pytivo_tivo_name'] = PYTIVO_TIVO_NAME

    new_config['NMA'] = {}
    new_config['NMA']['use_nma'] = int(USE_NMA)
    new_config['NMA']['nma_notify_onsnatch'] = int(NMA_NOTIFY_ONSNATCH)
    new_config['NMA']['nma_notify_ondownload'] = int(NMA_NOTIFY_ONDOWNLOAD)
    new_config['NMA']['nma_api'] = NMA_API
    new_config['NMA']['nma_priority'] = NMA_PRIORITY

    new_config['Newznab'] = {}
    new_config['Newznab']['newznab_data'] = NEWZNAB_DATA

    new_config['GUI'] = {}
    new_config['GUI']['coming_eps_layout'] = COMING_EPS_LAYOUT
    new_config['GUI']['coming_eps_display_paused'] = int(COMING_EPS_DISPLAY_PAUSED)
    new_config['GUI']['coming_eps_sort'] = COMING_EPS_SORT

    new_config.write()
示例#46
0
def config_write():

    new_config = ConfigObj()
    new_config.filename = CONFIG_FILE

    new_config['General'] = {}
    new_config['General']['http_port'] = HTTP_PORT
    new_config['General']['http_host'] = HTTP_HOST
    new_config['General']['http_username'] = HTTP_USERNAME
    new_config['General']['http_password'] = HTTP_PASSWORD
    new_config['General']['http_root'] = HTTP_ROOT
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    new_config['General']['log_dir'] = LOG_DIR
    new_config['General']['git_path'] = GIT_PATH

    new_config['General']['music_dir'] = MUSIC_DIR
    new_config['General']['destination_dir'] = DESTINATION_DIR
    new_config['General']['preferred_quality'] = PREFERRED_QUALITY
    new_config['General']['preferred_bitrate'] = PREFERRED_BITRATE
    new_config['General']['detect_bitrate'] = int(DETECT_BITRATE)
    new_config['General']['auto_add_artists'] = int(ADD_ARTISTS)
    new_config['General']['correct_metadata'] = int(CORRECT_METADATA)
    new_config['General']['move_files'] = int(MOVE_FILES)
    new_config['General']['rename_files'] = int(RENAME_FILES)
    new_config['General']['folder_format'] = FOLDER_FORMAT
    new_config['General']['file_format'] = FILE_FORMAT
    new_config['General']['cleanup_files'] = int(CLEANUP_FILES)
    new_config['General']['add_album_art'] = int(ADD_ALBUM_ART)
    new_config['General']['embed_album_art'] = int(EMBED_ALBUM_ART)
    new_config['General']['embed_lyrics'] = int(EMBED_LYRICS)
    new_config['General']['download_dir'] = DOWNLOAD_DIR
    new_config['General']['blackhole'] = int(BLACKHOLE)
    new_config['General']['blackhole_dir'] = BLACKHOLE_DIR
    new_config['General']['usenet_retention'] = USENET_RETENTION
    new_config['General']['include_extras'] = int(INCLUDE_EXTRAS)
    
    new_config['General']['numberofseeders'] = NUMBEROFSEEDERS
    new_config['General']['torrentblackhole_dir'] = TORRENTBLACKHOLE_DIR
    new_config['General']['isohunt'] = int(ISOHUNT)
    new_config['General']['kat'] = int(KAT)
    new_config['General']['mininova'] = int(MININOVA)
    new_config['General']['download_torrent_dir'] = DOWNLOAD_TORRENT_DIR
    
    new_config['General']['search_interval'] = SEARCH_INTERVAL
    new_config['General']['libraryscan_interval'] = LIBRARYSCAN_INTERVAL
    new_config['General']['download_scan_interval'] = DOWNLOAD_SCAN_INTERVAL

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['sab_host'] = SAB_HOST
    new_config['SABnzbd']['sab_username'] = SAB_USERNAME
    new_config['SABnzbd']['sab_password'] = SAB_PASSWORD
    new_config['SABnzbd']['sab_apikey'] = SAB_APIKEY
    new_config['SABnzbd']['sab_category'] = SAB_CATEGORY

    new_config['NZBMatrix'] = {}
    new_config['NZBMatrix']['nzbmatrix'] = int(NZBMATRIX)
    new_config['NZBMatrix']['nzbmatrix_username'] = NZBMATRIX_USERNAME
    new_config['NZBMatrix']['nzbmatrix_apikey'] = NZBMATRIX_APIKEY

    new_config['Newznab'] = {}
    new_config['Newznab']['newznab'] = int(NEWZNAB)
    new_config['Newznab']['newznab_host'] = NEWZNAB_HOST
    new_config['Newznab']['newznab_apikey'] = NEWZNAB_APIKEY

    new_config['NZBsorg'] = {}
    new_config['NZBsorg']['nzbsorg'] = int(NZBSORG)
    new_config['NZBsorg']['nzbsorg_uid'] = NZBSORG_UID
    new_config['NZBsorg']['nzbsorg_hash'] = NZBSORG_HASH
    
    new_config['Newzbin'] = {}
    new_config['Newzbin']['newzbin'] = int(NEWZBIN)
    new_config['Newzbin']['newzbin_uid'] = NEWZBIN_UID
    new_config['Newzbin']['newzbin_password'] = NEWZBIN_PASSWORD
    
    new_config['Prowl'] = {}
    new_config['Prowl']['prowl_enabled'] = int(PROWL_ENABLED)
    new_config['Prowl']['prowl_keys'] = PROWL_KEYS
    new_config['Prowl']['prowl_onsnatch'] = int(PROWL_ONSNATCH)
    new_config['Prowl']['prowl_priority'] = int(PROWL_PRIORITY)
    
    new_config['General']['lastfm_username'] = LASTFM_USERNAME
    new_config['General']['interface'] = INTERFACE
    new_config['General']['folder_permissions'] = FOLDER_PERMISSIONS

    new_config['General']['encode'] = int(ENCODE)
    new_config['General']['encoder'] = ENCODER
    new_config['General']['bitrate'] = int(BITRATE)
    new_config['General']['samplingfrequency'] = int(SAMPLINGFREQUENCY)
    new_config['General']['encoderfolder'] = ENCODERFOLDER
    new_config['General']['advancedencoder'] = ADVANCEDENCODER
    new_config['General']['encoderoutputformat'] = ENCODEROUTPUTFORMAT
    new_config['General']['encoderquality'] = ENCODERQUALITY
    new_config['General']['encodervbrcbr'] = ENCODERVBRCBR
    new_config['General']['encoderlossless'] = ENCODERLOSSLESS
    
    new_config['General']['mirror'] = MIRROR
    new_config['General']['customhost'] = CUSTOMHOST
    new_config['General']['customport'] = CUSTOMPORT
    new_config['General']['customsleep'] = CUSTOMSLEEP
    new_config['General']['hpuser'] = HPUSER
    new_config['General']['hppass'] = HPPASS
    
    new_config.write()
示例#47
0
def save_config():

    new_config = ConfigObj()
    new_config.filename = CONFIG_FILE

    new_config['General'] = {}
    new_config['General']['log_dir'] = LOG_DIR
    new_config['General']['web_port'] = WEB_PORT
    new_config['General']['web_host'] = WEB_HOST
    new_config['General']['web_ipv6'] = int(WEB_IPV6)
    new_config['General']['web_log'] = int(WEB_LOG)
    new_config['General']['web_root'] = WEB_ROOT
    new_config['General']['web_username'] = WEB_USERNAME
    new_config['General']['web_password'] = WEB_PASSWORD
    new_config['General']['use_api'] = int(USE_API)
    new_config['General']['api_key'] = API_KEY
    new_config['General']['use_nzbs'] = int(USE_NZBS)
    new_config['General']['use_torrents'] = int(USE_TORRENTS)
    new_config['General']['nzb_method'] = NZB_METHOD
    new_config['General']['usenet_retention'] = int(USENET_RETENTION)
    new_config['General']['search_frequency'] = int(SEARCH_FREQUENCY)
    new_config['General']['download_propers'] = int(DOWNLOAD_PROPERS)
    new_config['General']['quality_default'] = int(QUALITY_DEFAULT)
    new_config['General']['status_default'] = int(STATUS_DEFAULT)
    new_config['General']['season_folders_format'] = SEASON_FOLDERS_FORMAT
    new_config['General']['season_folders_default'] = int(SEASON_FOLDERS_DEFAULT)
    new_config['General']['provider_order'] = ' '.join([x.getID() for x in providers.sortedProviderList()])
    new_config['General']['version_notify'] = int(VERSION_NOTIFY)
    new_config['General']['naming_ep_name'] = int(NAMING_EP_NAME)
    new_config['General']['naming_show_name'] = int(NAMING_SHOW_NAME)
    new_config['General']['naming_ep_type'] = int(NAMING_EP_TYPE)
    new_config['General']['naming_multi_ep_type'] = int(NAMING_MULTI_EP_TYPE)
    new_config['General']['naming_sep_type'] = int(NAMING_SEP_TYPE)
    new_config['General']['naming_use_periods'] = int(NAMING_USE_PERIODS)
    new_config['General']['naming_quality'] = int(NAMING_QUALITY)
    new_config['General']['naming_dates'] = int(NAMING_DATES)
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)

    new_config['General']['use_banner'] = int(USE_BANNER)
    new_config['General']['use_listview'] = int(USE_LISTVIEW)
    new_config['General']['metadata_xbmc'] = metadata_provider_dict['XBMC'].get_config()
    new_config['General']['metadata_mediabrowser'] = metadata_provider_dict['MediaBrowser'].get_config()
    new_config['General']['metadata_ps3'] = metadata_provider_dict['Sony PS3'].get_config()
    new_config['General']['metadata_wdtv'] = metadata_provider_dict['WDTV'].get_config()
    new_config['General']['metadata_tivo'] = metadata_provider_dict['TIVO'].get_config()

    new_config['General']['cache_dir'] = ACTUAL_CACHE_DIR if ACTUAL_CACHE_DIR else 'cache'
    new_config['General']['root_dirs'] = ROOT_DIRS if ROOT_DIRS else ''
    new_config['General']['tv_download_dir'] = TV_DOWNLOAD_DIR
    new_config['General']['keep_processed_dir'] = int(KEEP_PROCESSED_DIR)
    new_config['General']['move_associated_files'] = int(MOVE_ASSOCIATED_FILES)
    new_config['General']['process_automatically'] = int(PROCESS_AUTOMATICALLY)
    new_config['General']['rename_episodes'] = int(RENAME_EPISODES)
    
    new_config['General']['extra_scripts'] = '|'.join(EXTRA_SCRIPTS)
    new_config['General']['git_path'] = GIT_PATH
    new_config['General']['ignore_words'] = IGNORE_WORDS

    new_config['Blackhole'] = {}
    new_config['Blackhole']['nzb_dir'] = NZB_DIR
    new_config['Blackhole']['torrent_dir'] = TORRENT_DIR

    new_config['EZRSS'] = {}
    new_config['EZRSS']['ezrss'] = int(EZRSS)
    
    new_config['TVTORRENTS'] = {}
    new_config['TVTORRENTS']['tvtorrents'] = int(TVTORRENTS)
    new_config['TVTORRENTS']['tvtorrents_digest'] = TVTORRENTS_DIGEST
    new_config['TVTORRENTS']['tvtorrents_hash'] = TVTORRENTS_HASH

    new_config['NZBs'] = {}
    new_config['NZBs']['nzbs'] = int(NZBS)
    new_config['NZBs']['nzbs_uid'] = NZBS_UID
    new_config['NZBs']['nzbs_hash'] = NZBS_HASH

    new_config['NZBsRUS'] = {}
    new_config['NZBsRUS']['nzbsrus'] = int(NZBSRUS)
    new_config['NZBsRUS']['nzbsrus_uid'] = NZBSRUS_UID
    new_config['NZBsRUS']['nzbsrus_hash'] = NZBSRUS_HASH

    new_config['NZBMatrix'] = {}
    new_config['NZBMatrix']['nzbmatrix'] = int(NZBMATRIX)
    new_config['NZBMatrix']['nzbmatrix_username'] = NZBMATRIX_USERNAME
    new_config['NZBMatrix']['nzbmatrix_apikey'] = NZBMATRIX_APIKEY

    new_config['Newzbin'] = {}
    new_config['Newzbin']['newzbin'] = int(NEWZBIN)
    new_config['Newzbin']['newzbin_username'] = NEWZBIN_USERNAME
    new_config['Newzbin']['newzbin_password'] = NEWZBIN_PASSWORD

    new_config['Womble'] = {}
    new_config['Womble']['womble'] = int(WOMBLE)

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['sab_username'] = SAB_USERNAME
    new_config['SABnzbd']['sab_password'] = SAB_PASSWORD
    new_config['SABnzbd']['sab_apikey'] = SAB_APIKEY
    new_config['SABnzbd']['sab_category'] = SAB_CATEGORY
    new_config['SABnzbd']['sab_host'] = SAB_HOST

    new_config['NZBget'] = {}
    new_config['NZBget']['nzbget_password'] = NZBGET_PASSWORD
    new_config['NZBget']['nzbget_category'] = NZBGET_CATEGORY
    new_config['NZBget']['nzbget_host'] = NZBGET_HOST

    new_config['XBMC'] = {}
    new_config['XBMC']['use_xbmc'] = int(USE_XBMC)
    new_config['XBMC']['xbmc_notify_onsnatch'] = int(XBMC_NOTIFY_ONSNATCH)
    new_config['XBMC']['xbmc_notify_ondownload'] = int(XBMC_NOTIFY_ONDOWNLOAD)
    new_config['XBMC']['xbmc_update_library'] = int(XBMC_UPDATE_LIBRARY)
    new_config['XBMC']['xbmc_update_full'] = int(XBMC_UPDATE_FULL)
    new_config['XBMC']['xbmc_host'] = XBMC_HOST
    new_config['XBMC']['xbmc_username'] = XBMC_USERNAME
    new_config['XBMC']['xbmc_password'] = XBMC_PASSWORD

    new_config['Plex'] = {}
    new_config['Plex']['use_plex'] = int(USE_PLEX)
    new_config['Plex']['plex_notify_onsnatch'] = int(PLEX_NOTIFY_ONSNATCH)
    new_config['Plex']['plex_notify_ondownload'] = int(PLEX_NOTIFY_ONDOWNLOAD)
    new_config['Plex']['plex_update_library'] = int(PLEX_UPDATE_LIBRARY)
    new_config['Plex']['plex_server_host'] = PLEX_SERVER_HOST
    new_config['Plex']['plex_host'] = PLEX_HOST
    new_config['Plex']['plex_username'] = PLEX_USERNAME
    new_config['Plex']['plex_password'] = PLEX_PASSWORD

    new_config['Growl'] = {}
    new_config['Growl']['use_growl'] = int(USE_GROWL)
    new_config['Growl']['growl_notify_onsnatch'] = int(GROWL_NOTIFY_ONSNATCH)
    new_config['Growl']['growl_notify_ondownload'] = int(GROWL_NOTIFY_ONDOWNLOAD) 
    new_config['Growl']['growl_host'] = GROWL_HOST
    new_config['Growl']['growl_password'] = GROWL_PASSWORD
    
    new_config['Prowl'] = {}
    new_config['Prowl']['use_prowl'] = int(USE_PROWL)
    new_config['Prowl']['prowl_notify_onsnatch'] = int(PROWL_NOTIFY_ONSNATCH)
    new_config['Prowl']['prowl_notify_ondownload'] = int(PROWL_NOTIFY_ONDOWNLOAD) 
    new_config['Prowl']['prowl_api'] = PROWL_API
    new_config['Prowl']['prowl_priority'] = PROWL_PRIORITY

    new_config['Twitter'] = {}
    new_config['Twitter']['use_twitter'] = int(USE_TWITTER)
    new_config['Twitter']['twitter_notify_onsnatch'] = int(TWITTER_NOTIFY_ONSNATCH)
    new_config['Twitter']['twitter_notify_ondownload'] = int(TWITTER_NOTIFY_ONDOWNLOAD)
    new_config['Twitter']['twitter_username'] = TWITTER_USERNAME
    new_config['Twitter']['twitter_password'] = TWITTER_PASSWORD
    new_config['Twitter']['twitter_prefix'] = TWITTER_PREFIX

    new_config['Notifo'] = {}
    new_config['Notifo']['use_notifo'] = int(USE_NOTIFO)
    new_config['Notifo']['notifo_notify_onsnatch'] = int(NOTIFO_NOTIFY_ONSNATCH)
    new_config['Notifo']['notifo_notify_ondownload'] = int(NOTIFO_NOTIFY_ONDOWNLOAD)
    new_config['Notifo']['notifo_username'] = NOTIFO_USERNAME
    new_config['Notifo']['notifo_apisecret'] = NOTIFO_APISECRET

    new_config['Boxcar'] = {}
    new_config['Boxcar']['use_boxcar'] = int(USE_BOXCAR)
    new_config['Boxcar']['boxcar_notify_onsnatch'] = int(BOXCAR_NOTIFY_ONSNATCH)
    new_config['Boxcar']['boxcar_notify_ondownload'] = int(BOXCAR_NOTIFY_ONDOWNLOAD)
    new_config['Boxcar']['boxcar_username'] = BOXCAR_USERNAME

    new_config['Libnotify'] = {}
    new_config['Libnotify']['use_libnotify'] = int(USE_LIBNOTIFY)
    new_config['Libnotify']['libnotify_notify_onsnatch'] = int(LIBNOTIFY_NOTIFY_ONSNATCH)
    new_config['Libnotify']['libnotify_notify_ondownload'] = int(LIBNOTIFY_NOTIFY_ONDOWNLOAD)

    new_config['NMJ'] = {}
    new_config['NMJ']['use_nmj'] = int(USE_NMJ)
    new_config['NMJ']['nmj_host'] = NMJ_HOST
    new_config['NMJ']['nmj_database'] = NMJ_DATABASE
    new_config['NMJ']['nmj_mount'] = NMJ_MOUNT

    new_config['Synology'] = {}
    new_config['Synology']['use_synoindex'] = int(USE_SYNOINDEX)

    new_config['Trakt'] = {}
    new_config['Trakt']['use_trakt'] = int(USE_TRAKT)
    new_config['Trakt']['trakt_username'] = TRAKT_USERNAME
    new_config['Trakt']['trakt_password'] = TRAKT_PASSWORD
    new_config['Trakt']['trakt_api'] = TRAKT_API

    new_config['pyTivo'] = {}
    new_config['pyTivo']['use_pytivo'] = int(USE_PYTIVO)
    new_config['pyTivo']['pytivo_notify_onsnatch'] = int(PYTIVO_NOTIFY_ONSNATCH)
    new_config['pyTivo']['pytivo_notify_ondownload'] = int(PYTIVO_NOTIFY_ONDOWNLOAD)
    new_config['pyTivo']['pyTivo_update_library'] = int(PYTIVO_UPDATE_LIBRARY)
    new_config['pyTivo']['pytivo_host'] = PYTIVO_HOST
    new_config['pyTivo']['pytivo_share_name'] = PYTIVO_SHARE_NAME
    new_config['pyTivo']['pytivo_tivo_name'] = PYTIVO_TIVO_NAME

    new_config['Newznab'] = {}
    new_config['Newznab']['newznab_data'] = '!!!'.join([x.configStr() for x in newznabProviderList])

    new_config['GUI'] = {}
    new_config['GUI']['coming_eps_layout'] = COMING_EPS_LAYOUT
    new_config['GUI']['coming_eps_display_paused'] = int(COMING_EPS_DISPLAY_PAUSED)
    new_config['GUI']['coming_eps_sort'] = COMING_EPS_SORT

    new_config.write()
示例#48
0
def config_write():

    new_config = ConfigObj()
    new_config.filename = CONFIG_FILE

    new_config['General'] = {}
    new_config['General']['http_port'] = HTTP_PORT
    new_config['General']['http_host'] = HTTP_HOST
    new_config['General']['http_username'] = HTTP_USERNAME
    new_config['General']['http_password'] = HTTP_PASSWORD
    new_config['General']['http_root'] = HTTP_ROOT
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    new_config['General']['log_dir'] = LOG_DIR
    new_config['General']['git_path'] = GIT_PATH

    new_config['General']['music_dir'] = MUSIC_DIR
    new_config['General']['destination_dir'] = DESTINATION_DIR
    new_config['General']['preferred_quality'] = PREFERRED_QUALITY
    new_config['General']['preferred_bitrate'] = PREFERRED_BITRATE
    new_config['General']['detect_bitrate'] = int(DETECT_BITRATE)
    new_config['General']['correct_metadata'] = int(CORRECT_METADATA)
    new_config['General']['move_files'] = int(MOVE_FILES)
    new_config['General']['rename_files'] = int(RENAME_FILES)
    new_config['General']['folder_format'] = FOLDER_FORMAT
    new_config['General']['file_format'] = FILE_FORMAT
    new_config['General']['cleanup_files'] = int(CLEANUP_FILES)
    new_config['General']['add_album_art'] = int(ADD_ALBUM_ART)
    new_config['General']['embed_album_art'] = int(EMBED_ALBUM_ART)
    new_config['General']['download_dir'] = DOWNLOAD_DIR
    new_config['General']['blackhole'] = int(BLACKHOLE)
    new_config['General']['blackhole_dir'] = BLACKHOLE_DIR
    new_config['General']['usenet_retention'] = USENET_RETENTION
    new_config['General']['include_extras'] = int(INCLUDE_EXTRAS)
    
    new_config['General']['nzb_search_interval'] = NZB_SEARCH_INTERVAL
    new_config['General']['libraryscan_interval'] = LIBRARYSCAN_INTERVAL
    new_config['General']['download_scan_interval'] = DOWNLOAD_SCAN_INTERVAL

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['sab_host'] = SAB_HOST
    new_config['SABnzbd']['sab_username'] = SAB_USERNAME
    new_config['SABnzbd']['sab_password'] = SAB_PASSWORD
    new_config['SABnzbd']['sab_apikey'] = SAB_APIKEY
    new_config['SABnzbd']['sab_category'] = SAB_CATEGORY

    new_config['NZBMatrix'] = {}
    new_config['NZBMatrix']['nzbmatrix'] = int(NZBMATRIX)
    new_config['NZBMatrix']['nzbmatrix_username'] = NZBMATRIX_USERNAME
    new_config['NZBMatrix']['nzbmatrix_apikey'] = NZBMATRIX_APIKEY

    new_config['Newznab'] = {}
    new_config['Newznab']['newznab'] = int(NEWZNAB)
    new_config['Newznab']['newznab_host'] = NEWZNAB_HOST
    new_config['Newznab']['newznab_apikey'] = NEWZNAB_APIKEY

    new_config['NZBsorg'] = {}
    new_config['NZBsorg']['nzbsorg'] = int(NZBSORG)
    new_config['NZBsorg']['nzbsorg_uid'] = NZBSORG_UID
    new_config['NZBsorg']['nzbsorg_hash'] = NZBSORG_HASH
    
    new_config['Newzbin'] = {}
    new_config['Newzbin']['newzbin'] = int(NEWZBIN)
    new_config['Newzbin']['newzbin_uid'] = NEWZBIN_UID
    new_config['Newzbin']['newzbin_password'] = NEWZBIN_PASSWORD
    
    new_config['General']['lastfm_username'] = LASTFM_USERNAME
    new_config['General']['interface'] = INTERFACE
    
    new_config.write()
示例#49
0
def config_write():
    new_config = ConfigObj()
    new_config.filename = CONFIGFILE

    new_config['General'] = {}
    new_config['General']['http_port'] = HTTP_PORT
    new_config['General']['http_host'] = HTTP_HOST
    new_config['General']['http_user'] = HTTP_USER
    new_config['General']['http_pass'] = HTTP_PASS
    new_config['General']['http_root'] = HTTP_ROOT
    new_config['General']['http_look'] = HTTP_LOOK
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    new_config['General']['logdir'] = LOGDIR
    new_config['General']['loglevel'] = int(LOGLEVEL)

    new_config['General']['imp_onlyisbn'] = int(IMP_ONLYISBN)
    new_config['General']['imp_preflang'] = IMP_PREFLANG
    new_config['General']['imp_autoadd'] =  IMP_AUTOADD

    new_config['General']['ebook_type'] = EBOOK_TYPE

    new_config['Git'] = {}
    new_config['Git']['git_user'] = GIT_USER
    new_config['Git']['git_repo'] = GIT_REPO
    new_config['Git']['git_branch'] = GIT_BRANCH
    new_config['Git']['install_type'] = INSTALL_TYPE
    new_config['Git']['current_version'] = CURRENT_VERSION
    new_config['Git']['latest_version'] = LATEST_VERSION
    new_config['Git']['commits_behind'] = COMMITS_BEHIND

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['sab_host'] = SAB_HOST
    new_config['SABnzbd']['sab_port'] = SAB_PORT
    new_config['SABnzbd']['sab_subdir'] = SAB_SUBDIR
    new_config['SABnzbd']['sab_user'] = SAB_USER
    new_config['SABnzbd']['sab_pass'] = SAB_PASS
    new_config['SABnzbd']['sab_api'] = SAB_API
    new_config['SABnzbd']['sab_cat'] = SAB_CAT

    new_config['General']['destination_dir'] = DESTINATION_DIR
    new_config['General']['destination_copy'] = int(DESTINATION_COPY)
    new_config['General']['download_dir'] = DOWNLOAD_DIR
    new_config['General']['blackhole'] = int(BLACKHOLE)
    new_config['General']['blackholedir'] = BLACKHOLEDIR
    new_config['General']['usenet_retention'] = USENET_RETENTION
    
    new_config['API'] = {}
    new_config['API']['book_api'] = BOOK_API
    new_config['API']['gr_api'] = GR_API
    new_config['API']['gb_api'] = GB_API

    new_config['NZBMatrix'] = {}
    new_config['NZBMatrix']['nzbmatrix'] = int(NZBMATRIX)
    new_config['NZBMatrix']['nzbmatrix_user'] = NZBMATRIX_USER
    new_config['NZBMatrix']['nzbmatrix_api'] = NZBMATRIX_API

    new_config['Newznab'] = {}
    new_config['Newznab']['newznab'] = int(NEWZNAB)
    new_config['Newznab']['newznab_host'] = NEWZNAB_HOST
    new_config['Newznab']['newznab_api'] = NEWZNAB_API

    new_config['Newznab2'] = {}
    new_config['Newznab2']['newznab2'] = int(NEWZNAB2)
    new_config['Newznab2']['newznab_host2'] = NEWZNAB_HOST2
    new_config['Newznab2']['newznab_api2'] = NEWZNAB_API2

    new_config['Newzbin'] = {}
    new_config['Newzbin']['newzbin'] = int(NEWZBIN)
    new_config['Newzbin']['newzbin_uid'] = NEWZBIN_UID
    new_config['Newzbin']['newzbin_pass'] = NEWZBIN_PASS

    new_config['UsenetCrawler'] = {}
    new_config['UsenetCrawler']['usenetcrawler'] = int(USENETCRAWLER)
    new_config['UsenetCrawler']['usenetcrawler_host'] = USENETCRAWLER_HOST
    new_config['UsenetCrawler']['usenetcrawler_api'] = USENETCRAWLER_API

    new_config['SearchScan'] = {}
    new_config['SearchScan']['search_interval'] = SEARCH_INTERVAL
    new_config['SearchScan']['scan_interval'] = SCAN_INTERVAL
    new_config['SearchScan']['versioncheck_interval'] = VERSIONCHECK_INTERVAL

    new_config['PostProcess'] = {}
    new_config['PostProcess']['ebook_dest_folder'] = EBOOK_DEST_FOLDER
    new_config['PostProcess']['ebook_dest_file'] = EBOOK_DEST_FILE
    new_config['PostProcess']['mag_dest_folder'] = MAG_DEST_FOLDER
    new_config['PostProcess']['mag_dest_file'] = MAG_DEST_FILE

    new_config['Twitter'] = {}
    new_config['Twitter']['use_twitter'] = int(USE_TWITTER)
    new_config['Twitter']['twitter_notify_onsnatch'] = int(TWITTER_NOTIFY_ONSNATCH)
    new_config['Twitter']['twitter_notify_ondownload'] = int(TWITTER_NOTIFY_ONDOWNLOAD)
    new_config['Twitter']['twitter_username'] = TWITTER_USERNAME
    new_config['Twitter']['twitter_password'] = TWITTER_PASSWORD
    new_config['Twitter']['twitter_prefix'] = TWITTER_PREFIX

    new_config.write()
示例#50
0
文件: __init__.py 项目: mriutta/mylar
def config_write():
    new_config = ConfigObj()
    new_config.filename = CONFIG_FILE
    new_config['General'] = {}
    new_config['General']['config_version'] = CONFIG_VERSION
    new_config['General']['http_port'] = HTTP_PORT
    new_config['General']['http_host'] = HTTP_HOST
    new_config['General']['http_username'] = HTTP_USERNAME
    new_config['General']['http_password'] = HTTP_PASSWORD
    new_config['General']['http_root'] = HTTP_ROOT
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    new_config['General']['log_dir'] = LOG_DIR
    new_config['General']['logverbose'] = int(LOGVERBOSE)
    new_config['General']['git_path'] = GIT_PATH
    new_config['General']['cache_dir'] = CACHE_DIR
    new_config['General']['annuals_on'] = int(ANNUALS_ON)
    new_config['General']['cv_only'] = int(CV_ONLY)
    new_config['General']['cv_onetimer'] = int(CV_ONETIMER)
    new_config['General']['cvapifix'] = int(CVAPIFIX)    
    new_config['General']['check_github'] = int(CHECK_GITHUB)
    new_config['General']['check_github_on_startup'] = int(CHECK_GITHUB_ON_STARTUP)
    new_config['General']['check_github_interval'] = CHECK_GITHUB_INTERVAL

    new_config['General']['destination_dir'] = DESTINATION_DIR
    new_config['General']['chmod_dir'] = CHMOD_DIR
    new_config['General']['chmod_file'] = CHMOD_FILE
    new_config['General']['usenet_retention'] = USENET_RETENTION

    new_config['General']['search_interval'] = SEARCH_INTERVAL
    new_config['General']['nzb_startup_search'] = int(NZB_STARTUP_SEARCH)
    new_config['General']['libraryscan'] = int(LIBRARYSCAN)
    new_config['General']['libraryscan_interval'] = LIBRARYSCAN_INTERVAL
    new_config['General']['add_comics'] = int(ADD_COMICS)
    new_config['General']['comic_dir'] = COMIC_DIR
    new_config['General']['imp_move'] = int(IMP_MOVE)
    new_config['General']['imp_rename'] = int(IMP_RENAME)
    new_config['General']['imp_metadata'] = int(IMP_METADATA)
    new_config['General']['download_scan_interval'] = DOWNLOAD_SCAN_INTERVAL
    new_config['General']['interface'] = INTERFACE
    new_config['General']['autowant_all'] = int(AUTOWANT_ALL)
    new_config['General']['autowant_upcoming'] = int(AUTOWANT_UPCOMING)
    new_config['General']['preferred_quality'] = int(PREFERRED_QUALITY)
    new_config['General']['comic_cover_local'] = int(COMIC_COVER_LOCAL)
    new_config['General']['correct_metadata'] = int(CORRECT_METADATA)
    new_config['General']['move_files'] = int(MOVE_FILES)
    new_config['General']['rename_files'] = int(RENAME_FILES)
    new_config['General']['folder_format'] = FOLDER_FORMAT
    new_config['General']['file_format'] = FILE_FORMAT
    new_config['General']['blackhole'] = int(BLACKHOLE)
    new_config['General']['blackhole_dir'] = BLACKHOLE_DIR
    new_config['General']['replace_spaces'] = int(REPLACE_SPACES)
    new_config['General']['replace_char'] = REPLACE_CHAR
    new_config['General']['zero_level'] = int(ZERO_LEVEL)
    new_config['General']['zero_level_n'] = ZERO_LEVEL_N
    new_config['General']['lowercase_filenames'] = int(LOWERCASE_FILENAMES)
    new_config['General']['syno_fix'] = int(SYNO_FIX)
    new_config['General']['search_delay'] = SEARCH_DELAY
    new_config['General']['grabbag_dir'] = GRABBAG_DIR
    new_config['General']['highcount'] = HIGHCOUNT
    new_config['General']['read2filename'] = int(READ2FILENAME)
    new_config['General']['storyarcdir'] = int(STORYARCDIR)
    new_config['General']['use_minsize'] = int(USE_MINSIZE)
    new_config['General']['minsize'] = MINSIZE
    new_config['General']['use_maxsize'] = int(USE_MAXSIZE)
    new_config['General']['maxsize'] = MAXSIZE
    new_config['General']['add_to_csv'] = int(ADD_TO_CSV)
    new_config['General']['cvinfo'] = int(CVINFO)
    new_config['General']['log_level'] = LOG_LEVEL
    new_config['General']['enable_extra_scripts'] = int(ENABLE_EXTRA_SCRIPTS)
    new_config['General']['extra_scripts'] = EXTRA_SCRIPTS
    new_config['General']['enable_pre_scripts'] = int(ENABLE_PRE_SCRIPTS)
    new_config['General']['pre_scripts'] = PRE_SCRIPTS
    new_config['General']['post_processing'] = int(POST_PROCESSING)
    new_config['General']['weekfolder'] = int(WEEKFOLDER)
    new_config['General']['locmove'] = int(LOCMOVE)
    new_config['General']['newcom_dir'] = NEWCOM_DIR
    new_config['General']['fftonewcom_dir'] = int(FFTONEWCOM_DIR)

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['use_sabnzbd'] = int(USE_SABNZBD)
    new_config['SABnzbd']['sab_host'] = SAB_HOST
    new_config['SABnzbd']['sab_username'] = SAB_USERNAME
    new_config['SABnzbd']['sab_password'] = SAB_PASSWORD
    new_config['SABnzbd']['sab_apikey'] = SAB_APIKEY
    new_config['SABnzbd']['sab_category'] = SAB_CATEGORY
    new_config['SABnzbd']['sab_priority'] = SAB_PRIORITY
    new_config['SABnzbd']['sab_directory'] = SAB_DIRECTORY

    new_config['NZBGet'] = {}
    new_config['NZBGet']['use_nzbget'] = int(USE_NZBGET)
    new_config['NZBGet']['nzbget_host'] = NZBGET_HOST
    new_config['NZBGet']['nzbget_port'] = NZBGET_PORT
    new_config['NZBGet']['nzbget_username'] = NZBGET_USERNAME
    new_config['NZBGet']['nzbget_password'] = NZBGET_PASSWORD
    new_config['NZBGet']['nzbget_category'] = NZBGET_CATEGORY
    new_config['NZBGet']['nzbget_priority'] = NZBGET_PRIORITY


    new_config['NZBsu'] = {}
    new_config['NZBsu']['nzbsu'] = int(NZBSU)
    new_config['NZBsu']['nzbsu_apikey'] = NZBSU_APIKEY

    new_config['DOGnzb'] = {}
    new_config['DOGnzb']['dognzb'] = int(DOGNZB)
    new_config['DOGnzb']['dognzb_apikey'] = DOGNZB_APIKEY

    new_config['nzbx'] = {}
    new_config['nzbx']['nzbx'] = int(NZBX)

    new_config['Experimental'] = {}
    new_config['Experimental']['experimental'] = int(EXPERIMENTAL)

    new_config['Newznab'] = {}
    new_config['Newznab']['newznab'] = int(NEWZNAB)

    # Need to unpack the extra newznabs for saving in config.ini
    flattened_newznabs = []
    for newznab in EXTRA_NEWZNABS:
        for item in newznab:
            flattened_newznabs.append(item)

    new_config['Newznab']['extra_newznabs'] = flattened_newznabs

    new_config['Prowl'] = {}
    new_config['Prowl']['prowl_enabled'] = int(PROWL_ENABLED)
    new_config['Prowl']['prowl_keys'] = PROWL_KEYS
    new_config['Prowl']['prowl_onsnatch'] = int(PROWL_ONSNATCH)
    new_config['Prowl']['prowl_priority'] = int(PROWL_PRIORITY)

    new_config['NMA'] = {}
    new_config['NMA']['nma_enabled'] = int(NMA_ENABLED)
    new_config['NMA']['nma_apikey'] = NMA_APIKEY
    new_config['NMA']['nma_priority'] = NMA_PRIORITY
    new_config['NMA']['nma_onsnatch'] = int(NMA_ONSNATCH)

    new_config['PUSHOVER'] = {}
    new_config['PUSHOVER']['pushover_enabled'] = int(PUSHOVER_ENABLED)
    new_config['PUSHOVER']['pushover_apikey'] = PUSHOVER_APIKEY
    new_config['PUSHOVER']['pushover_userkey'] = PUSHOVER_USERKEY
    new_config['PUSHOVER']['pushover_priority'] = PUSHOVER_PRIORITY
    new_config['PUSHOVER']['pushover_onsnatch'] = int(PUSHOVER_ONSNATCH)

    new_config['Raw'] = {}
    new_config['Raw']['raw'] = int(RAW)
    new_config['Raw']['raw_provider'] = RAW_PROVIDER
    new_config['Raw']['raw_username'] = RAW_USERNAME
    new_config['Raw']['raw_password'] = RAW_PASSWORD
    new_config['Raw']['raw_groups'] = RAW_GROUPS

    new_config.write()
示例#51
0
def save_config():
    new_config = ConfigObj()
    new_config.filename = CONFIG_FILE

    # For passwords you must include the word `password` in the item_name and add `helpers.encrypt(ITEM_NAME, ENCRYPTION_VERSION)` in save_config()
    new_config['General'] = {}
    new_config['General']['config_version'] = CONFIG_VERSION
    new_config['General']['encryption_version'] = int(ENCRYPTION_VERSION)
    new_config['General']['log_dir'] = ACTUAL_LOG_DIR if ACTUAL_LOG_DIR else 'Logs'
    new_config['General']['socket_timeout'] = SOCKET_TIMEOUT
    new_config['General']['web_port'] = WEB_PORT
    new_config['General']['web_host'] = WEB_HOST
    new_config['General']['web_ipv6'] = int(WEB_IPV6)
    new_config['General']['web_log'] = int(WEB_LOG)
    new_config['General']['web_root'] = WEB_ROOT
    new_config['General']['web_username'] = WEB_USERNAME
    new_config['General']['web_password'] = helpers.encrypt(WEB_PASSWORD, ENCRYPTION_VERSION)
    new_config['General']['localhost_ip'] = LOCALHOST_IP
    new_config['General']['cpu_preset'] = CPU_PRESET
    new_config['General']['anon_redirect'] = ANON_REDIRECT
    new_config['General']['use_api'] = int(USE_API)
    new_config['General']['api_key'] = API_KEY
    new_config['General']['debug'] = int(DEBUG)
    new_config['General']['handle_reverse_proxy'] = int(HANDLE_REVERSE_PROXY)
    new_config['General']['update_frequency'] = int(UPDATE_FREQUENCY)
    new_config['General']['version_notify'] = int(VERSION_NOTIFY)
    new_config['General']['auto_update'] = int(AUTO_UPDATE)
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    new_config['General']['proxy_setting'] = PROXY_SETTING

    new_config['General']['use_listview'] = int(USE_LISTVIEW)

    new_config['General']['extra_scripts'] = '|'.join(EXTRA_SCRIPTS)
    new_config['General']['git_path'] = GIT_PATH

    new_config['Plex'] = {}
    new_config['Plex']['use_plex'] = int(USE_PLEX)
    new_config['Plex']['plex_notify_onsnatch'] = int(PLEX_NOTIFY_ONSNATCH)
    new_config['Plex']['plex_notify_ondownload'] = int(PLEX_NOTIFY_ONDOWNLOAD)
    new_config['Plex']['plex_update_library'] = int(PLEX_UPDATE_LIBRARY)
    new_config['Plex']['plex_server_host'] = PLEX_SERVER_HOST
    new_config['Plex']['plex_host'] = PLEX_HOST
    new_config['Plex']['plex_username'] = PLEX_USERNAME
    new_config['Plex']['plex_password'] = helpers.encrypt(PLEX_PASSWORD, ENCRYPTION_VERSION)

    new_config['Boxcar2'] = {}
    new_config['Boxcar2']['use_boxcar2'] = int(USE_BOXCAR2)
    new_config['Boxcar2']['boxcar2_notify_onsnatch'] = int(BOXCAR2_NOTIFY_ONSNATCH)
    new_config['Boxcar2']['boxcar2_notify_ondownload'] = int(BOXCAR2_NOTIFY_ONDOWNLOAD)
    new_config['Boxcar2']['boxcar2_accesstoken'] = BOXCAR2_ACCESSTOKEN

    new_config['Trakt'] = {}
    new_config['Trakt']['use_trakt'] = int(USE_TRAKT)
    new_config['Trakt']['trakt_username'] = TRAKT_USERNAME
    new_config['Trakt']['trakt_password'] = helpers.encrypt(TRAKT_PASSWORD, ENCRYPTION_VERSION)
    new_config['Trakt']['trakt_api'] = TRAKT_API
    new_config['Trakt']['trakt_remove_watchlist'] = int(TRAKT_REMOVE_WATCHLIST)
    new_config['Trakt']['trakt_use_watchlist'] = int(TRAKT_USE_WATCHLIST)
    new_config['Trakt']['trakt_method_add'] = TRAKT_METHOD_ADD
    new_config['Trakt']['trakt_start_paused'] = int(TRAKT_START_PAUSED)
    new_config['Trakt']['trakt_use_recommended'] = int(TRAKT_USE_RECOMMENDED)
    new_config['Trakt']['trakt_sync'] = int(TRAKT_SYNC)

    new_config['GUI'] = {}
    new_config['GUI']['gui_name'] = GUI_NAME
    new_config['GUI']['fuzzy_dating'] = int(FUZZY_DATING)
    new_config['GUI']['trim_zero'] = int(TRIM_ZERO)
    new_config['GUI']['date_preset'] = DATE_PRESET
    new_config['GUI']['time_preset'] = TIME_PRESET_W_SECONDS
    new_config['GUI']['timezone_display'] = TIMEZONE_DISPLAY

    new_config['EventGhost'] = {}
    new_config['EventGhost']['eventghost_plex'] = int(USE_PLEX)
    new_config['EventGhost']['eventghost_server_host'] = PLEX_SERVER_HOST
    new_config['EventGhost']['eventghost_host'] = PLEX_HOST

    new_config['Drives'] = {}
    new_config['Drives']['use_drives'] = int(USE_DRIVES)
    new_config['Drives']['use_driveA'] = int(USE_DRIVEA)
    new_config['Drives']['use_driveB'] = int(USE_DRIVEB)
    new_config['Drives']['use_driveC'] = int(USE_DRIVEC)
    new_config['Drives']['driveA_name'] = DRIVEA_NAME
    new_config['Drives']['driveB_name'] = DRIVEB_NAME
    new_config['Drives']['driveC_name'] = DRIVEC_NAME

    new_config['Sickbeard'] = {}
    new_config['Sickbeard']['use_sickbeard'] = int(USE_SICKBEARD)
    new_config['Sickbeard']['sickbeard_host'] = SICKBEARD_HOST
    new_config['Sickbeard']['sickbeard_api'] = SICKBEARD_API

    new_config['Speedfan'] = {}
    new_config['Speedfan']['use_speedfan'] = int(USE_SPEEDFAN)
    new_config['Speedfan']['speedfan_log_location'] = SPEEDFAN_LOG_LOCATION

    new_config.write()
示例#52
0
def config_write():

    new_config = ConfigObj(encoding="UTF-8")
    new_config.filename = CONFIG_FILE

    new_config['General'] = {}
    new_config['General']['config_version'] = CONFIG_VERSION
    new_config['General']['http_port'] = HTTP_PORT
    new_config['General']['http_host'] = HTTP_HOST
    new_config['General']['http_username'] = HTTP_USERNAME
    new_config['General']['http_password'] = HTTP_PASSWORD
    new_config['General']['http_root'] = HTTP_ROOT
    new_config['General']['http_proxy'] = int(HTTP_PROXY)
    new_config['General']['enable_https'] = int(ENABLE_HTTPS)
    new_config['General']['https_cert'] = HTTPS_CERT
    new_config['General']['https_key'] = HTTPS_KEY
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    new_config['General']['api_enabled'] = int(API_ENABLED)
    new_config['General']['api_key'] = API_KEY
    new_config['General']['log_dir'] = LOG_DIR
    new_config['General']['cache_dir'] = CACHE_DIR
    new_config['General']['git_path'] = GIT_PATH
    new_config['General']['git_user'] = GIT_USER
    new_config['General']['git_branch'] = GIT_BRANCH

    new_config['General']['check_github'] = int(CHECK_GITHUB)
    new_config['General']['check_github_on_startup'] = int(CHECK_GITHUB_ON_STARTUP)
    new_config['General']['check_github_interval'] = CHECK_GITHUB_INTERVAL

    new_config['General']['music_dir'] = MUSIC_DIR
    new_config['General']['destination_dir'] = DESTINATION_DIR
    new_config['General']['lossless_destination_dir'] = LOSSLESS_DESTINATION_DIR
    new_config['General']['preferred_quality'] = PREFERRED_QUALITY
    new_config['General']['preferred_bitrate'] = PREFERRED_BITRATE
    new_config['General']['preferred_bitrate_high_buffer'] = PREFERRED_BITRATE_HIGH_BUFFER
    new_config['General']['preferred_bitrate_low_buffer'] = PREFERRED_BITRATE_LOW_BUFFER
    new_config['General']['preferred_bitrate_allow_lossless'] = int(PREFERRED_BITRATE_ALLOW_LOSSLESS)
    new_config['General']['detect_bitrate'] = int(DETECT_BITRATE)
    new_config['General']['auto_add_artists'] = int(ADD_ARTISTS)
    new_config['General']['correct_metadata'] = int(CORRECT_METADATA)
    new_config['General']['move_files'] = int(MOVE_FILES)
    new_config['General']['rename_files'] = int(RENAME_FILES)
    new_config['General']['folder_format'] = FOLDER_FORMAT
    new_config['General']['file_format'] = FILE_FORMAT
    new_config['General']['file_underscores'] = int(FILE_UNDERSCORES)
    new_config['General']['cleanup_files'] = int(CLEANUP_FILES)
    new_config['General']['add_album_art'] = int(ADD_ALBUM_ART)
    new_config['General']['album_art_format'] = ALBUM_ART_FORMAT
    new_config['General']['embed_album_art'] = int(EMBED_ALBUM_ART)
    new_config['General']['embed_lyrics'] = int(EMBED_LYRICS)
    new_config['General']['nzb_downloader'] = NZB_DOWNLOADER
    new_config['General']['torrent_downloader'] = TORRENT_DOWNLOADER
    new_config['General']['download_dir'] = DOWNLOAD_DIR
    new_config['General']['blackhole_dir'] = BLACKHOLE_DIR
    new_config['General']['usenet_retention'] = USENET_RETENTION
    new_config['General']['include_extras'] = int(INCLUDE_EXTRAS)
    new_config['General']['extras'] = EXTRAS
    new_config['General']['autowant_upcoming'] = int(AUTOWANT_UPCOMING)
    new_config['General']['autowant_all'] = int(AUTOWANT_ALL)
    new_config['General']['keep_torrent_files'] = int(KEEP_TORRENT_FILES)

    new_config['General']['numberofseeders'] = NUMBEROFSEEDERS
    new_config['General']['torrentblackhole_dir'] = TORRENTBLACKHOLE_DIR
    new_config['General']['isohunt'] = int(ISOHUNT)
    new_config['General']['kat'] = int(KAT)
    new_config['General']['mininova'] = int(MININOVA)
    new_config['General']['piratebay'] = int(PIRATEBAY)
    new_config['General']['piratebay_proxy_url'] = PIRATEBAY_PROXY_URL
    new_config['General']['download_torrent_dir'] = DOWNLOAD_TORRENT_DIR

    new_config['Waffles'] = {}
    new_config['Waffles']['waffles'] = int(WAFFLES)
    new_config['Waffles']['waffles_uid'] = WAFFLES_UID
    new_config['Waffles']['waffles_passkey'] = WAFFLES_PASSKEY

    new_config['Rutracker'] = {}
    new_config['Rutracker']['rutracker'] = int(RUTRACKER)
    new_config['Rutracker']['rutracker_user'] = RUTRACKER_USER
    new_config['Rutracker']['rutracker_password'] = RUTRACKER_PASSWORD

    new_config['What.cd'] = {}
    new_config['What.cd']['whatcd'] = int(WHATCD)
    new_config['What.cd']['whatcd_username'] = WHATCD_USERNAME
    new_config['What.cd']['whatcd_password'] = WHATCD_PASSWORD

    new_config['General']['search_interval'] = SEARCH_INTERVAL
    new_config['General']['libraryscan'] = int(LIBRARYSCAN)
    new_config['General']['libraryscan_interval'] = LIBRARYSCAN_INTERVAL
    new_config['General']['download_scan_interval'] = DOWNLOAD_SCAN_INTERVAL

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['sab_host'] = SAB_HOST
    new_config['SABnzbd']['sab_username'] = SAB_USERNAME
    new_config['SABnzbd']['sab_password'] = SAB_PASSWORD
    new_config['SABnzbd']['sab_apikey'] = SAB_APIKEY
    new_config['SABnzbd']['sab_category'] = SAB_CATEGORY

    new_config['NZBget'] = {}
    new_config['NZBget']['nzbget_username'] = NZBGET_USERNAME
    new_config['NZBget']['nzbget_password'] = NZBGET_PASSWORD
    new_config['NZBget']['nzbget_category'] = NZBGET_CATEGORY
    new_config['NZBget']['nzbget_host'] = NZBGET_HOST

    new_config['Headphones'] = {}
    new_config['Headphones']['headphones_indexer'] = int(HEADPHONES_INDEXER)

    new_config['Transmission'] = {}
    new_config['Transmission']['transmission_host'] = TRANSMISSION_HOST
    new_config['Transmission']['transmission_username'] = TRANSMISSION_USERNAME
    new_config['Transmission']['transmission_password'] = TRANSMISSION_PASSWORD
    
    new_config['uTorrent'] = {}
    new_config['uTorrent']['utorrent_host'] = UTORRENT_HOST
    new_config['uTorrent']['utorrent_username'] = UTORRENT_USERNAME
    new_config['uTorrent']['utorrent_password'] = UTORRENT_PASSWORD

    new_config['Newznab'] = {}
    new_config['Newznab']['newznab'] = int(NEWZNAB)
    new_config['Newznab']['newznab_host'] = NEWZNAB_HOST
    new_config['Newznab']['newznab_apikey'] = NEWZNAB_APIKEY
    new_config['Newznab']['newznab_enabled'] = int(NEWZNAB_ENABLED)
    # Need to unpack the extra newznabs for saving in config.ini
    flattened_newznabs = []
    for newznab in EXTRA_NEWZNABS:
        for item in newznab:
            flattened_newznabs.append(item)

    new_config['Newznab']['extra_newznabs'] = flattened_newznabs

    new_config['NZBsorg'] = {}
    new_config['NZBsorg']['nzbsorg'] = int(NZBSORG)
    new_config['NZBsorg']['nzbsorg_uid'] = NZBSORG_UID
    new_config['NZBsorg']['nzbsorg_hash'] = NZBSORG_HASH

    new_config['NZBsRus'] = {}
    new_config['NZBsRus']['nzbsrus'] = int(NZBSRUS)
    new_config['NZBsRus']['nzbsrus_uid'] = NZBSRUS_UID
    new_config['NZBsRus']['nzbsrus_apikey'] = NZBSRUS_APIKEY

    new_config['omgwtfnzbs'] = {}
    new_config['omgwtfnzbs']['omgwtfnzbs'] = int(OMGWTFNZBS)
    new_config['omgwtfnzbs']['omgwtfnzbs_uid'] = OMGWTFNZBS_UID
    new_config['omgwtfnzbs']['omgwtfnzbs_apikey'] = OMGWTFNZBS_APIKEY

    new_config['General']['preferred_words'] = PREFERRED_WORDS
    new_config['General']['ignored_words'] = IGNORED_WORDS
    new_config['General']['required_words'] = REQUIRED_WORDS

    new_config['Prowl'] = {}
    new_config['Prowl']['prowl_enabled'] = int(PROWL_ENABLED)
    new_config['Prowl']['prowl_keys'] = PROWL_KEYS
    new_config['Prowl']['prowl_onsnatch'] = int(PROWL_ONSNATCH)
    new_config['Prowl']['prowl_priority'] = int(PROWL_PRIORITY)

    new_config['XBMC'] = {}
    new_config['XBMC']['xbmc_enabled'] = int(XBMC_ENABLED)
    new_config['XBMC']['xbmc_host'] = XBMC_HOST
    new_config['XBMC']['xbmc_username'] = XBMC_USERNAME
    new_config['XBMC']['xbmc_password'] = XBMC_PASSWORD
    new_config['XBMC']['xbmc_update'] = int(XBMC_UPDATE)
    new_config['XBMC']['xbmc_notify'] = int(XBMC_NOTIFY)

    new_config['NMA'] = {}
    new_config['NMA']['nma_enabled'] = int(NMA_ENABLED)
    new_config['NMA']['nma_apikey'] = NMA_APIKEY
    new_config['NMA']['nma_priority'] = NMA_PRIORITY
    new_config['NMA']['nma_onsnatch'] = int(PROWL_ONSNATCH)

    new_config['Pushover'] = {}
    new_config['Pushover']['pushover_enabled'] = int(PUSHOVER_ENABLED)
    new_config['Pushover']['pushover_keys'] = PUSHOVER_KEYS
    new_config['Pushover']['pushover_onsnatch'] = int(PUSHOVER_ONSNATCH)
    new_config['Pushover']['pushover_priority'] = int(PUSHOVER_PRIORITY)

    new_config['Synoindex'] = {}
    new_config['Synoindex']['synoindex_enabled'] = int(SYNOINDEX_ENABLED)

    new_config['General']['lastfm_username'] = LASTFM_USERNAME
    new_config['General']['interface'] = INTERFACE
    new_config['General']['folder_permissions'] = FOLDER_PERMISSIONS
    new_config['General']['file_permissions'] = FILE_PERMISSIONS

    new_config['General']['music_encoder'] = int(MUSIC_ENCODER)
    new_config['General']['encoder'] = ENCODER
    new_config['General']['xldprofile'] = XLDPROFILE
    new_config['General']['bitrate'] = int(BITRATE)
    new_config['General']['samplingfrequency'] = int(SAMPLINGFREQUENCY)
    new_config['General']['encoder_path'] = ENCODER_PATH
    new_config['General']['advancedencoder'] = ADVANCEDENCODER
    new_config['General']['encoderoutputformat'] = ENCODEROUTPUTFORMAT
    new_config['General']['encoderquality'] = ENCODERQUALITY
    new_config['General']['encodervbrcbr'] = ENCODERVBRCBR
    new_config['General']['encoderlossless'] = int(ENCODERLOSSLESS)
    new_config['General']['delete_lossless_files'] = int(DELETE_LOSSLESS_FILES)

    new_config['General']['mirror'] = MIRROR
    new_config['General']['customhost'] = CUSTOMHOST
    new_config['General']['customport'] = CUSTOMPORT
    new_config['General']['customsleep'] = CUSTOMSLEEP
    new_config['General']['hpuser'] = HPUSER
    new_config['General']['hppass'] = HPPASS

    new_config['Advanced'] = {}
    new_config['Advanced']['album_completion_pct'] = ALBUM_COMPLETION_PCT
    new_config['Advanced']['cache_sizemb'] = CACHE_SIZEMB
    new_config['Advanced']['journal_mode'] = JOURNAL_MODE

    new_config.write()
示例#53
0
def config_write():

    new_config = ConfigObj()
    new_config.filename = CONFIG_FILE

    new_config['General'] = {}
    new_config['General']['http_port'] = HTTP_PORT
    new_config['General']['http_host'] = HTTP_HOST
    new_config['General']['http_username'] = HTTP_USERNAME
    new_config['General']['http_password'] = HTTP_PASSWORD
    new_config['General']['http_root'] = HTTP_ROOT
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    new_config['General']['log_dir'] = LOG_DIR
    new_config['General']['git_path'] = GIT_PATH

    new_config['General']['music_dir'] = MUSIC_DIR
    new_config['General']['destination_dir'] = DESTINATION_DIR
    new_config['General']['preferred_quality'] = PREFERRED_QUALITY
    new_config['General']['preferred_bitrate'] = PREFERRED_BITRATE
    new_config['General']['detect_bitrate'] = int(DETECT_BITRATE)
    new_config['General']['auto_add_artists'] = int(ADD_ARTISTS)
    new_config['General']['correct_metadata'] = int(CORRECT_METADATA)
    new_config['General']['move_files'] = int(MOVE_FILES)
    new_config['General']['rename_files'] = int(RENAME_FILES)
    new_config['General']['folder_format'] = FOLDER_FORMAT
    new_config['General']['file_format'] = FILE_FORMAT
    new_config['General']['cleanup_files'] = int(CLEANUP_FILES)
    new_config['General']['add_album_art'] = int(ADD_ALBUM_ART)
    new_config['General']['embed_album_art'] = int(EMBED_ALBUM_ART)
    new_config['General']['embed_lyrics'] = int(EMBED_LYRICS)
    new_config['General']['download_dir'] = DOWNLOAD_DIR
    new_config['General']['blackhole'] = int(BLACKHOLE)
    new_config['General']['blackhole_dir'] = BLACKHOLE_DIR
    new_config['General']['usenet_retention'] = USENET_RETENTION
    new_config['General']['include_extras'] = int(INCLUDE_EXTRAS)

    new_config['General']['numberofseeders'] = NUMBEROFSEEDERS
    new_config['General']['torrentblackhole_dir'] = TORRENTBLACKHOLE_DIR
    new_config['General']['isohunt'] = int(ISOHUNT)
    new_config['General']['kat'] = int(KAT)
    new_config['General']['mininova'] = int(MININOVA)
    new_config['General']['download_torrent_dir'] = DOWNLOAD_TORRENT_DIR

    new_config['General']['search_interval'] = SEARCH_INTERVAL
    new_config['General']['libraryscan_interval'] = LIBRARYSCAN_INTERVAL
    new_config['General']['download_scan_interval'] = DOWNLOAD_SCAN_INTERVAL

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['sab_host'] = SAB_HOST
    new_config['SABnzbd']['sab_username'] = SAB_USERNAME
    new_config['SABnzbd']['sab_password'] = SAB_PASSWORD
    new_config['SABnzbd']['sab_apikey'] = SAB_APIKEY
    new_config['SABnzbd']['sab_category'] = SAB_CATEGORY

    new_config['NZBMatrix'] = {}
    new_config['NZBMatrix']['nzbmatrix'] = int(NZBMATRIX)
    new_config['NZBMatrix']['nzbmatrix_username'] = NZBMATRIX_USERNAME
    new_config['NZBMatrix']['nzbmatrix_apikey'] = NZBMATRIX_APIKEY

    new_config['Newznab'] = {}
    new_config['Newznab']['newznab'] = int(NEWZNAB)
    new_config['Newznab']['newznab_host'] = NEWZNAB_HOST
    new_config['Newznab']['newznab_apikey'] = NEWZNAB_APIKEY

    new_config['NZBsorg'] = {}
    new_config['NZBsorg']['nzbsorg'] = int(NZBSORG)
    new_config['NZBsorg']['nzbsorg_uid'] = NZBSORG_UID
    new_config['NZBsorg']['nzbsorg_hash'] = NZBSORG_HASH

    new_config['Newzbin'] = {}
    new_config['Newzbin']['newzbin'] = int(NEWZBIN)
    new_config['Newzbin']['newzbin_uid'] = NEWZBIN_UID
    new_config['Newzbin']['newzbin_password'] = NEWZBIN_PASSWORD

    new_config['General']['lastfm_username'] = LASTFM_USERNAME
    new_config['General']['interface'] = INTERFACE
    new_config['General']['folder_permissions'] = FOLDER_PERMISSIONS

    new_config['General']['encode'] = int(ENCODE)
    new_config['General']['encoder'] = ENCODER
    new_config['General']['bitrate'] = int(BITRATE)
    new_config['General']['samplingfrequency'] = int(SAMPLINGFREQUENCY)
    new_config['General']['encoderfolder'] = ENCODERFOLDER
    new_config['General']['advancedencoder'] = ADVANCEDENCODER
    new_config['General']['encoderoutputformat'] = ENCODEROUTPUTFORMAT
    new_config['General']['encoderquality'] = ENCODERQUALITY
    new_config['General']['encodervbrcbr'] = ENCODERVBRCBR
    new_config['General']['encoderlossless'] = ENCODERLOSSLESS

    new_config.write()
示例#54
0
def config_write():

    new_config = ConfigObj(encoding="UTF-8")
    new_config.filename = CONFIG_FILE

    new_config['General'] = {}
    new_config['General']['config_version'] = CONFIG_VERSION
    new_config['General']['http_port'] = HTTP_PORT
    new_config['General']['http_host'] = HTTP_HOST
    new_config['General']['http_username'] = HTTP_USERNAME
    new_config['General']['http_password'] = HTTP_PASSWORD
    new_config['General']['http_root'] = HTTP_ROOT
    new_config['General']['http_proxy'] = int(HTTP_PROXY)
    new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
    new_config['General']['api_enabled'] = int(API_ENABLED)
    new_config['General']['api_key'] = API_KEY
    new_config['General']['log_dir'] = LOG_DIR
    new_config['General']['cache_dir'] = CACHE_DIR
    new_config['General']['git_path'] = GIT_PATH
    new_config['General']['git_user'] = GIT_USER
    new_config['General']['git_branch'] = GIT_BRANCH

    new_config['General']['check_github'] = int(CHECK_GITHUB)
    new_config['General']['check_github_on_startup'] = int(
        CHECK_GITHUB_ON_STARTUP)
    new_config['General']['check_github_interval'] = CHECK_GITHUB_INTERVAL

    new_config['General']['music_dir'] = MUSIC_DIR
    new_config['General']['destination_dir'] = DESTINATION_DIR
    new_config['General'][
        'lossless_destination_dir'] = LOSSLESS_DESTINATION_DIR
    new_config['General']['preferred_quality'] = PREFERRED_QUALITY
    new_config['General']['preferred_bitrate'] = PREFERRED_BITRATE
    new_config['General'][
        'preferred_bitrate_high_buffer'] = PREFERRED_BITRATE_HIGH_BUFFER
    new_config['General'][
        'preferred_bitrate_low_buffer'] = PREFERRED_BITRATE_LOW_BUFFER
    new_config['General']['preferred_bitrate_allow_lossless'] = int(
        PREFERRED_BITRATE_ALLOW_LOSSLESS)
    new_config['General']['detect_bitrate'] = int(DETECT_BITRATE)
    new_config['General']['auto_add_artists'] = int(ADD_ARTISTS)
    new_config['General']['correct_metadata'] = int(CORRECT_METADATA)
    new_config['General']['move_files'] = int(MOVE_FILES)
    new_config['General']['rename_files'] = int(RENAME_FILES)
    new_config['General']['folder_format'] = FOLDER_FORMAT
    new_config['General']['file_format'] = FILE_FORMAT
    new_config['General']['cleanup_files'] = int(CLEANUP_FILES)
    new_config['General']['add_album_art'] = int(ADD_ALBUM_ART)
    new_config['General']['album_art_format'] = ALBUM_ART_FORMAT
    new_config['General']['embed_album_art'] = int(EMBED_ALBUM_ART)
    new_config['General']['embed_lyrics'] = int(EMBED_LYRICS)
    new_config['General']['nzb_downloader'] = NZB_DOWNLOADER
    new_config['General']['download_dir'] = DOWNLOAD_DIR
    new_config['General']['blackhole_dir'] = BLACKHOLE_DIR
    new_config['General']['usenet_retention'] = USENET_RETENTION
    new_config['General']['include_extras'] = int(INCLUDE_EXTRAS)
    new_config['General']['extras'] = EXTRAS
    new_config['General']['autowant_upcoming'] = int(AUTOWANT_UPCOMING)
    new_config['General']['autowant_all'] = int(AUTOWANT_ALL)
    new_config['General']['keep_torrent_files'] = int(KEEP_TORRENT_FILES)

    new_config['General']['numberofseeders'] = NUMBEROFSEEDERS
    new_config['General']['torrentblackhole_dir'] = TORRENTBLACKHOLE_DIR
    new_config['General']['isohunt'] = int(ISOHUNT)
    new_config['General']['kat'] = int(KAT)
    new_config['General']['mininova'] = int(MININOVA)
    new_config['General']['download_torrent_dir'] = DOWNLOAD_TORRENT_DIR

    new_config['Waffles'] = {}
    new_config['Waffles']['waffles'] = int(WAFFLES)
    new_config['Waffles']['waffles_uid'] = WAFFLES_UID
    new_config['Waffles']['waffles_passkey'] = WAFFLES_PASSKEY

    new_config['Rutracker'] = {}
    new_config['Rutracker']['rutracker'] = int(RUTRACKER)
    new_config['Rutracker']['rutracker_user'] = RUTRACKER_USER
    new_config['Rutracker']['rutracker_password'] = RUTRACKER_PASSWORD

    new_config['What.cd'] = {}
    new_config['What.cd']['whatcd'] = int(WHATCD)
    new_config['What.cd']['whatcd_username'] = WHATCD_USERNAME
    new_config['What.cd']['whatcd_password'] = WHATCD_PASSWORD

    new_config['General']['search_interval'] = SEARCH_INTERVAL
    new_config['General']['libraryscan'] = int(LIBRARYSCAN)
    new_config['General']['libraryscan_interval'] = LIBRARYSCAN_INTERVAL
    new_config['General']['download_scan_interval'] = DOWNLOAD_SCAN_INTERVAL

    new_config['SABnzbd'] = {}
    new_config['SABnzbd']['sab_host'] = SAB_HOST
    new_config['SABnzbd']['sab_username'] = SAB_USERNAME
    new_config['SABnzbd']['sab_password'] = SAB_PASSWORD
    new_config['SABnzbd']['sab_apikey'] = SAB_APIKEY
    new_config['SABnzbd']['sab_category'] = SAB_CATEGORY

    new_config['NZBget'] = {}
    new_config['NZBget']['nzbget_username'] = NZBGET_USERNAME
    new_config['NZBget']['nzbget_password'] = NZBGET_PASSWORD
    new_config['NZBget']['nzbget_category'] = NZBGET_CATEGORY
    new_config['NZBget']['nzbget_host'] = NZBGET_HOST

    new_config['NZBMatrix'] = {}
    new_config['NZBMatrix']['nzbmatrix'] = int(NZBMATRIX)
    new_config['NZBMatrix']['nzbmatrix_username'] = NZBMATRIX_USERNAME
    new_config['NZBMatrix']['nzbmatrix_apikey'] = NZBMATRIX_APIKEY

    new_config['Newznab'] = {}
    new_config['Newznab']['newznab'] = int(NEWZNAB)
    new_config['Newznab']['newznab_host'] = NEWZNAB_HOST
    new_config['Newznab']['newznab_apikey'] = NEWZNAB_APIKEY
    new_config['Newznab']['newznab_enabled'] = int(NEWZNAB_ENABLED)
    # Need to unpack the extra newznabs for saving in config.ini
    flattened_newznabs = []
    for newznab in EXTRA_NEWZNABS:
        for item in newznab:
            flattened_newznabs.append(item)

    new_config['Newznab']['extra_newznabs'] = flattened_newznabs

    new_config['NZBsorg'] = {}
    new_config['NZBsorg']['nzbsorg'] = int(NZBSORG)
    new_config['NZBsorg']['nzbsorg_uid'] = NZBSORG_UID
    new_config['NZBsorg']['nzbsorg_hash'] = NZBSORG_HASH

    new_config['Newzbin'] = {}
    new_config['Newzbin']['newzbin'] = int(NEWZBIN)
    new_config['Newzbin']['newzbin_uid'] = NEWZBIN_UID
    new_config['Newzbin']['newzbin_password'] = NEWZBIN_PASSWORD

    new_config['NZBsRus'] = {}
    new_config['NZBsRus']['nzbsrus'] = int(NZBSRUS)
    new_config['NZBsRus']['nzbsrus_uid'] = NZBSRUS_UID
    new_config['NZBsRus']['nzbsrus_apikey'] = NZBSRUS_APIKEY

    new_config['nzbX'] = {}
    new_config['nzbX']['nzbx'] = int(NZBX)

    new_config['General']['preferred_words'] = PREFERRED_WORDS
    new_config['General']['ignored_words'] = IGNORED_WORDS
    new_config['General']['required_words'] = REQUIRED_WORDS

    new_config['Prowl'] = {}
    new_config['Prowl']['prowl_enabled'] = int(PROWL_ENABLED)
    new_config['Prowl']['prowl_keys'] = PROWL_KEYS
    new_config['Prowl']['prowl_onsnatch'] = int(PROWL_ONSNATCH)
    new_config['Prowl']['prowl_priority'] = int(PROWL_PRIORITY)

    new_config['XBMC'] = {}
    new_config['XBMC']['xbmc_enabled'] = int(XBMC_ENABLED)
    new_config['XBMC']['xbmc_host'] = XBMC_HOST
    new_config['XBMC']['xbmc_username'] = XBMC_USERNAME
    new_config['XBMC']['xbmc_password'] = XBMC_PASSWORD
    new_config['XBMC']['xbmc_update'] = int(XBMC_UPDATE)
    new_config['XBMC']['xbmc_notify'] = int(XBMC_NOTIFY)

    new_config['NMA'] = {}
    new_config['NMA']['nma_enabled'] = int(NMA_ENABLED)
    new_config['NMA']['nma_apikey'] = NMA_APIKEY
    new_config['NMA']['nma_priority'] = NMA_PRIORITY
    new_config['NMA']['nma_onsnatch'] = int(PROWL_ONSNATCH)

    new_config['Pushover'] = {}
    new_config['Pushover']['pushover_enabled'] = int(PUSHOVER_ENABLED)
    new_config['Pushover']['pushover_keys'] = PUSHOVER_KEYS
    new_config['Pushover']['pushover_onsnatch'] = int(PUSHOVER_ONSNATCH)
    new_config['Pushover']['pushover_priority'] = int(PUSHOVER_PRIORITY)

    new_config['Synoindex'] = {}
    new_config['Synoindex']['synoindex_enabled'] = int(SYNOINDEX_ENABLED)

    new_config['General']['lastfm_username'] = LASTFM_USERNAME
    new_config['General']['interface'] = INTERFACE
    new_config['General']['folder_permissions'] = FOLDER_PERMISSIONS

    new_config['General']['music_encoder'] = int(MUSIC_ENCODER)
    new_config['General']['encoder'] = ENCODER
    new_config['General']['xldprofile'] = XLDPROFILE
    new_config['General']['bitrate'] = int(BITRATE)
    new_config['General']['samplingfrequency'] = int(SAMPLINGFREQUENCY)
    new_config['General']['encoder_path'] = ENCODER_PATH
    new_config['General']['advancedencoder'] = ADVANCEDENCODER
    new_config['General']['encoderoutputformat'] = ENCODEROUTPUTFORMAT
    new_config['General']['encoderquality'] = ENCODERQUALITY
    new_config['General']['encodervbrcbr'] = ENCODERVBRCBR
    new_config['General']['encoderlossless'] = int(ENCODERLOSSLESS)
    new_config['General']['delete_lossless_files'] = int(DELETE_LOSSLESS_FILES)

    new_config['General']['mirror'] = MIRROR
    new_config['General']['customhost'] = CUSTOMHOST
    new_config['General']['customport'] = CUSTOMPORT
    new_config['General']['customsleep'] = CUSTOMSLEEP
    new_config['General']['hpuser'] = HPUSER
    new_config['General']['hppass'] = HPPASS

    new_config['Advanced'] = {}
    new_config['Advanced']['album_completion_pct'] = ALBUM_COMPLETION_PCT
    new_config['Advanced']['cache_sizemb'] = CACHE_SIZEMB

    new_config.write()
示例#55
0
def config_write():
    new_config = ConfigObj()
    new_config.filename = CONFIG_FILE

    print ("falalal")

    new_config["General"] = {}
    new_config["General"]["config_version"] = CONFIG_VERSION
    new_config["General"]["http_port"] = HTTP_PORT
    new_config["General"]["http_host"] = HTTP_HOST
    new_config["General"]["http_username"] = HTTP_USERNAME
    new_config["General"]["http_password"] = HTTP_PASSWORD
    new_config["General"]["http_root"] = HTTP_ROOT
    new_config["General"]["launch_browser"] = int(LAUNCH_BROWSER)
    new_config["General"]["log_dir"] = LOG_DIR
    new_config["General"]["logverbose"] = int(LOGVERBOSE)
    new_config["General"]["git_path"] = GIT_PATH

    new_config["General"]["check_github"] = int(CHECK_GITHUB)
    new_config["General"]["check_github_on_startup"] = int(CHECK_GITHUB_ON_STARTUP)
    new_config["General"]["check_github_interval"] = CHECK_GITHUB_INTERVAL

    new_config["General"]["destination_dir"] = DESTINATION_DIR
    new_config["General"]["usenet_retention"] = USENET_RETENTION

    new_config["General"]["search_interval"] = SEARCH_INTERVAL
    new_config["General"]["libraryscan_interval"] = LIBRARYSCAN_INTERVAL
    new_config["General"]["download_scan_interval"] = DOWNLOAD_SCAN_INTERVAL
    new_config["General"]["interface"] = INTERFACE
    new_config["General"]["autowant_all"] = AUTOWANT_ALL
    new_config["General"]["autowant_upcoming"] = AUTOWANT_UPCOMING
    new_config["General"]["preferred_quality"] = PREFERRED_QUALITY
    new_config["General"]["comic_cover_local"] = COMIC_COVER_LOCAL
    new_config["General"]["correct_metadata"] = int(CORRECT_METADATA)
    new_config["General"]["move_files"] = int(MOVE_FILES)
    new_config["General"]["rename_files"] = int(RENAME_FILES)
    new_config["General"]["folder_format"] = FOLDER_FORMAT
    new_config["General"]["file_format"] = FILE_FORMAT
    new_config["General"]["blackhole"] = int(BLACKHOLE)
    new_config["General"]["blackhole_dir"] = BLACKHOLE_DIR
    new_config["General"]["replace_spaces"] = int(REPLACE_SPACES)
    new_config["General"]["replace_char"] = REPLACE_CHAR
    new_config["General"]["zero_level"] = int(ZERO_LEVEL)
    new_config["General"]["zero_level_n"] = ZERO_LEVEL_N
    new_config["General"]["use_minsize"] = int(USE_MINSIZE)
    new_config["General"]["minsize"] = MINSIZE
    new_config["General"]["use_maxsize"] = int(USE_MAXSIZE)
    new_config["General"]["maxsize"] = MAXSIZE

    new_config["General"]["enable_extra_scripts"] = int(ENABLE_EXTRA_SCRIPTS)
    new_config["General"]["extra_scripts"] = EXTRA_SCRIPTS
    new_config["General"]["enable_pre_scripts"] = int(ENABLE_PRE_SCRIPTS)
    new_config["General"]["pre_scripts"] = PRE_SCRIPTS

    new_config["SABnzbd"] = {}
    new_config["SABnzbd"]["sab_host"] = SAB_HOST
    new_config["SABnzbd"]["sab_username"] = SAB_USERNAME
    new_config["SABnzbd"]["sab_password"] = SAB_PASSWORD
    new_config["SABnzbd"]["sab_apikey"] = SAB_APIKEY
    new_config["SABnzbd"]["sab_category"] = SAB_CATEGORY
    new_config["SABnzbd"]["sab_priority"] = SAB_PRIORITY

    new_config["NZBsu"] = {}
    new_config["NZBsu"]["nzbsu"] = int(NZBSU)
    new_config["NZBsu"]["nzbsu_apikey"] = NZBSU_APIKEY

    new_config["DOGnzb"] = {}
    new_config["DOGnzb"]["dognzb"] = int(DOGNZB)
    new_config["DOGnzb"]["dognzb_apikey"] = DOGNZB_APIKEY

    new_config["nzbx"] = {}
    new_config["nzbx"]["nzbx"] = int(NZBX)

    new_config["Experimental"] = {}
    new_config["Experimental"]["experimental"] = int(EXPERIMENTAL)

    new_config["Newznab"] = {}
    new_config["Newznab"]["newznab"] = int(NEWZNAB)
    new_config["Newznab"]["newznab_host"] = NEWZNAB_HOST
    new_config["Newznab"]["newznab_apikey"] = NEWZNAB_APIKEY
    new_config["Newznab"]["newznab_enabled"] = int(NEWZNAB_ENABLED)
    # Need to unpack the extra newznabs for saving in config.ini
    flattened_newznabs = []
    for newznab in EXTRA_NEWZNABS:
        for item in newznab:
            flattened_newznabs.append(item)

    new_config["Newznab"]["extra_newznabs"] = flattened_newznabs

    new_config["Raw"] = {}
    new_config["Raw"]["raw"] = int(RAW)
    new_config["Raw"]["raw_provider"] = RAW_PROVIDER
    new_config["Raw"]["raw_username"] = RAW_USERNAME
    new_config["Raw"]["raw_password"] = RAW_PASSWORD
    new_config["Raw"]["raw_groups"] = RAW_GROUPS

    new_config.write()
示例#56
0
            raise SystemExit("Config file root dir '" +
                             os.path.dirname(sickbeard.CONFIG_FILE) +
                             "' must be writeable.")

    os.chdir(sickbeard.DATA_DIR)

    if consoleLogging:
        print "Starting up SickRage " + SICKBEARD_VERSION + " from " + sickbeard.CONFIG_FILE

    # Load the config and publish it to the sickbeard package
    if not os.path.isfile(sickbeard.CONFIG_FILE):
        logger.log(
            u"Unable to find '" + sickbeard.CONFIG_FILE +
            "' , all settings will be default!", logger.ERROR)

    sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)

    CUR_DB_VERSION = db.DBConnection().checkDBVersion()
    if CUR_DB_VERSION > 0:
        if CUR_DB_VERSION < MIN_DB_VERSION:
            raise SystemExit("Your database version (" + str(db.DBConnection().checkDBVersion()) + ") is too old to migrate from with this version of SickRage (" + str(MIN_DB_VERSION) + ").\n" + \
                             "Upgrade using a previous version of SB first, or start with no database file to begin fresh.")
        if CUR_DB_VERSION > MAX_DB_VERSION:
            raise SystemExit("Your database version (" + str(db.DBConnection().checkDBVersion()) + ") has been incremented past what this version of SickRage supports (" + str(MAX_DB_VERSION) + ").\n" + \
                             "If you have used other forks of SB, your database may be unusable due to their modifications.")

            # Initialize the config and our threads
    sickbeard.initialize(consoleLogging=consoleLogging)

    sickbeard.showList = []
示例#57
0
def main():

    # Set paths
    if hasattr(sys, 'frozen'):
        lazylibrarian.FULL_PATH = os.path.abspath(sys.executable)
    else:
        lazylibrarian.FULL_PATH = os.path.abspath(__file__)

    lazylibrarian.PROG_DIR = os.path.dirname(lazylibrarian.FULL_PATH)
    lazylibrarian.ARGS = sys.argv[1:]

    # Set arguments
    from optparse import OptionParser

    p = OptionParser()
    p.add_option('-d',
                 '--daemon',
                 action="store_true",
                 dest='daemon',
                 help="Run the server as a daemon")
    p.add_option('-q',
                 '--quiet',
                 action="store_true",
                 dest='quiet',
                 help="Don't log to console")
    p.add_option('--debug',
                 action="store_true",
                 dest='debug',
                 help="Show debuglog messages")
    p.add_option('--nolaunch',
                 action="store_true",
                 dest='nolaunch',
                 help="Don't start browser")
    p.add_option('--port',
                 dest='port',
                 default=None,
                 help="Force webinterface to listen on this port")
    p.add_option('--datadir',
                 dest='datadir',
                 default=None,
                 help="Path to the data directory")
    p.add_option('--config',
                 dest='config',
                 default=None,
                 help="Path to config.ini file")
    p.add_option('-p',
                 '--pidfile',
                 dest='pidfile',
                 default=None,
                 help="Store the process id in the given file")

    options, args = p.parse_args()

    if options.debug:
        lazylibrarian.LOGLEVEL = 2

    if options.quiet:
        lazylibrarian.LOGLEVEL = 0

    if options.daemon:
        if not sys.platform == 'win32':
            lazylibrarian.DAEMON = True
            lazylibrarian.LOGLEVEL = 0
            lazylibrarian.daemonize()
        else:
            print "Daemonize not supported under Windows, starting normally"

    if options.nolaunch:
        lazylibrarian.LAUNCH_BROWSER = False

    if options.port:
        lazylibrarian.HTTP_PORT = int(options.port)
        logger.info('Starting LazyLibrarian on forced port: %i ...' %
                    lazylibrarian.HTTP_PORT)

    if options.datadir:
        lazylibrarian.DATADIR = str(options.datadir)
    else:
        lazylibrarian.DATADIR = lazylibrarian.PROG_DIR

    if options.config:
        lazylibrarian.CONFIGFILE = str(options.config)
    else:
        lazylibrarian.CONFIGFILE = os.path.join(lazylibrarian.DATADIR,
                                                "config.ini")

    if options.pidfile:
        if lazylibrarian.DAEMON:
            lazylibrarian.PIDFILE = str(options.pidfile)

    # create and check (optional) paths
    if not os.path.exists(lazylibrarian.DATADIR):
        try:
            os.makedirs(lazylibrarian.DATADIR)
        except OSError:
            raise SystemExit('Could not create data directory: ' +
                             lazylibrarian.DATADIR + '. Exit ...')

    if not os.access(lazylibrarian.DATADIR, os.W_OK):
        raise SystemExit('Cannot write to the data directory: ' +
                         lazylibrarian.DATADIR + '. Exit ...')

    # create database and config
    lazylibrarian.DBFILE = os.path.join(lazylibrarian.DATADIR,
                                        'lazylibrarian.db')
    lazylibrarian.CFG = ConfigObj(lazylibrarian.CONFIGFILE, encoding='utf-8')

    lazylibrarian.initialize()

    if lazylibrarian.DAEMON:
        lazylibrarian.daemonize()

    # Try to start the server.
    webStart.initialize({
        'http_port': lazylibrarian.HTTP_PORT,
        'http_host': lazylibrarian.HTTP_HOST,
        'http_root': lazylibrarian.HTTP_ROOT,
        'http_user': lazylibrarian.HTTP_USER,
        'http_pass': lazylibrarian.HTTP_PASS,
    })

    if lazylibrarian.LAUNCH_BROWSER and not options.nolaunch:
        lazylibrarian.launch_browser(lazylibrarian.HTTP_HOST,
                                     lazylibrarian.HTTP_PORT,
                                     lazylibrarian.HTTP_ROOT)

    lazylibrarian.start()

    while True:
        if not lazylibrarian.SIGNAL:

            try:
                time.sleep(1)
            except KeyboardInterrupt:
                lazylibrarian.shutdown()
        else:
            if lazylibrarian.SIGNAL == 'shutdown':
                lazylibrarian.shutdown()
            elif lazylibrarian.SIGNAL == 'restart':
                lazylibrarian.shutdown(restart=True)
            else:
                lazylibrarian.shutdown(restart=True, update=True)
            lazylibrarian.SIGNAL = None
    return