#!/usr/bin/env python import site from django.core.management import execute_manager, setup_environ try: import settings_local as settings except ImportError: try: import settings # Assumed to be in the same directory. except ImportError: import sys sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) sys.exit(1) site.addsitedir(settings.path('apps')) site.addsitedir(settings.path('lib')) # The first thing execute_manager does is call `setup_environ`. Logging config # needs to access settings, so we'll setup the environ early. setup_environ(settings) # Import for side-effect: configures our logging handlers. import log_settings if __name__ == "__main__": execute_manager(settings)
import shutil import time from collections import defaultdict from datetime import datetime, timedelta from operator import itemgetter import hb import settings_local as settings log = logging.getLogger('glow') # The default version number we look for. FX = settings.FIREFOX_VERSION JSON_DIR = os.path.join(settings.BASE_DIR, 'json') PICKLE = settings.path('glow.pickle') BACKUP = PICKLE + '.bak' hbase = hb.Client(settings.HBASE_HOST, settings.HBASE_PORT, settings.HBASE_TABLES['realtime']) # Maps {country: continent}. continents = json.load(open(settings.path('continents.json'))) # Maps {country code: name}. countries = json.load(open(settings.path('countries.json'))) # Maps {country code: {region code: name}}. regions = json.load(open(settings.path('regions.json'))) geo = (continents, countries, regions)
import logging import shutil import time from collections import defaultdict from datetime import datetime, timedelta from operator import itemgetter import hb import settings_local as settings log = logging.getLogger('glow') # The default version number we look for. FX = settings.FIREFOX_VERSION JSON_DIR = os.path.join(settings.BASE_DIR, 'json') PICKLE = settings.path('glow.pickle') BACKUP = PICKLE + '.bak' hbase = hb.Client(settings.HBASE_HOST, settings.HBASE_PORT, settings.HBASE_TABLES['realtime']) # Maps {country: continent}. continents = json.load(open(settings.path('continents.json'))) # Maps {country code: name}. countries = json.load(open(settings.path('countries.json'))) # Maps {country code: {region code: name}}. regions = json.load(open(settings.path('regions.json'))) geo = (continents, countries, regions)
fmt = '[%(asctime)s] %(name)s:%(levelname)s %(message)s' cfg = { 'version': 1, 'filters': {}, 'formatters': { 'file': {'format': fmt}, 'syslog': {'format': '%s: %s' % (settings.SYSLOG_TAG, fmt)}, }, 'handlers': { 'file': { '()': logging.FileHandler, 'filename': settings.path('glow.log'), 'mode': 'a', 'formatter': 'file', }, 'syslog': { '()': logging.handlers.SysLogHandler, 'facility': logging.handlers.SysLogHandler.LOG_USER, 'formatter': 'syslog', }, }, 'root': { 'level': logging.DEBUG, 'handlers': ['file'], }, }