<commit_before>import os
import sys
import logging
import threading
import ConfigParser
from optparse import OptionParser
from plex_scrobble.lastfm import LastFm
from plex_scrobble.plex_monitor import monitor_log, ScrobbleCache


def cache_retry(config):

    threading.Timer(7200, cache_retry).start()
    cache = ScrobbleCache()
    cache.retry_queue()
    cache.close

def main(config):

    logger.info('starting log monitor thread.')
    log_watch = threading.Thread(target=monitor_log, args=(config,))
    log_watch.start()

if __name__ == '__main__':

    p = OptionParser()
    p.add_option('-c', '--config', action='store', dest='config_file',
        help='The location to the configuration file.')
    p.add_option('-a', '--authenticate', action='store_true', dest='authenticate',
        default=False, help='Generate a new last.fm session key.')

    p.set_defaults(config_file=os.path.expanduser(
      '~/.config/plex-scrobble/plex_scrobble.conf'))

    (options, args) = p.parse_args()

    if not os.path.exists(options.config_file):
        print 'Exiting, unable to locate config file {0}. use -c to specify config target'.format(
            options.config_file)
        sys.exit(1)

    # apply defaults to *required* configuration values.
    config = ConfigParser.ConfigParser(defaults = {
        'session': os.path.expanduser('~/.config/plex-scrobble/session_key'),
        'mediaserver_url': 'http://localhost:32400',
        'log_file': '/tmp/plex_scrobble.log'
      })
    config.read(options.config_file)

    FORMAT = '%(asctime)-15s [%(process)d] [%(name)s %(funcName)s] [%(levelname)s] %(message)s'
    logging.basicConfig(filename=config.get('plex-scrobble',
      'log_file'), format=FORMAT, level=logging.DEBUG)
    logger = logging.getLogger('main')

    # dump our configuration values to the logfile
    for key in config.items('plex-scrobble'):
        logger.debug('config : {0} -> {1}'.format(key[0], key[1]))

    # if a valid session object does not exist, prompt user
    # to authenticate.
    if (not os.path.exists(config.get('plex-scrobble','session')) or
      options.authenticate):
        logger.info('Prompting to authenticate to Last.fm.')
        last_fm = LastFm(config)
        last_fm.last_fm_auth()
        print 'Please relaunch plex-scrobble service.'
        logger.warn('Exiting application.')
        sys.exit(0)

    m = main(config)
<commit_msg>changing default location of config directory.<commit_after>import os
import sys
import logging
import threading
import ConfigParser
from optparse import OptionParser
from plex_scrobble.lastfm import LastFm
from plex_scrobble.plex_monitor import monitor_log, ScrobbleCache


def cache_retry(config):

    threading.Timer(7200, cache_retry).start()
    cache = ScrobbleCache()
    cache.retry_queue()
    cache.close

def main(config):

    logger.info('starting log monitor thread.')
    log_watch = threading.Thread(target=monitor_log, args=(config,))
    log_watch.start()

if __name__ == '__main__':

    p = OptionParser()
    p.add_option('-c', '--config', action='store', dest='config_file',
        help='The location to the configuration file.')
    p.add_option('-a', '--authenticate', action='store_true', dest='authenticate',
        default=False, help='Generate a new last.fm session key.')

    p.set_defaults(config_file=os.path.expanduser(
      '~/.config/plex-lastfm-scrobbler/plex_scrobble.conf'))

    (options, args) = p.parse_args()

    if not os.path.exists(options.config_file):
        print 'Exiting, unable to locate config file {0}. use -c to specify config target'.format(
            options.config_file)
        sys.exit(1)

    # apply defaults to *required* configuration values.
    config = ConfigParser.ConfigParser(defaults = {
        'session': os.path.expanduser('~/.config/plex-lastfm-scrobbler/session_key'),
        'mediaserver_url': 'http://localhost:32400',
        'log_file': '/tmp/plex_scrobble.log'
      })
    config.read(options.config_file)

    FORMAT = '%(asctime)-15s [%(process)d] [%(name)s %(funcName)s] [%(levelname)s] %(message)s'
    logging.basicConfig(filename=config.get('plex-scrobble',
      'log_file'), format=FORMAT, level=logging.DEBUG)
    logger = logging.getLogger('main')

    # dump our configuration values to the logfile
    for key in config.items('plex-scrobble'):
        logger.debug('config : {0} -> {1}'.format(key[0], key[1]))

    # if a valid session object does not exist, prompt user
    # to authenticate.
    if (not os.path.exists(config.get('plex-scrobble','session')) or
      options.authenticate):
        logger.info('Prompting to authenticate to Last.fm.')
        last_fm = LastFm(config)
        last_fm.last_fm_auth()
        print 'Please relaunch plex-scrobble service.'
        logger.warn('Exiting application.')
        sys.exit(0)

    m = main(config)

{'fraction_non_alphanumeric': 0.1348245434024215, 'fraction_numerical': 0.007387646213831316, 'mean_word_length': 3.5424044734389564, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1518269', 'n_tokens_mistral': 1582, 'n_tokens_neox': 1523, 'n_words': 343}