Пример #1
0
def get_config():
    op = OptionParser()
    op.add_option("--config",
        action="store", type="string", dest="config",
        default=os.path.join(os.path.dirname(os.path.abspath(__file__)), 'config.ini'),
        help="path to the config file [config.ini]")

    options, args = op.parse_args()

    if not os.path.exists(options.config):
        print "ERROR: %s doesn't exist" % (os.path.abspath(options.config))
        sys.exit(1)

    parser = ConfigParser.RawConfigParser(defaults={'debug': 'false'})
    parser.read(options.config)

    def now():
        return Date.eod().value

    def today():
        return Date.today().value

    try:
        const = CNV.string2datetime(parser.get('alerts', 'now'))

        def now():
            return const

        today = now
    except Exception:
        pass


    return {
        'username': parser.get('alerts', 'username'),
        'password': parser.get('alerts', 'password'),
        'host': parser.get('alerts', 'host'),
        'database': parser.get('alerts', 'database'),
        'maildir': parser.get('alerts', 'maildir'),
        'now': now,
        'today': today,
        'DEBUG': parser.getboolean('alerts', 'debug'),
    }
#
# Author: Kyle Lahnakoski ([email protected])
#
from __future__ import unicode_literals
from pyLibrary.maths import Math
from pyLibrary.env import startup
from pyLibrary.cnv import CNV
from pyLibrary.env.logs import Log
from pyLibrary.times.timer import Timer


with Timer("load pandas"):
    import pandas
    from pandas.core.frame import DataFrame

MINIMUM_DATE = CNV.string2datetime("20130720", "%Y%m%d")
MINIMUM_ID = 0
parts = [0, 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000, 25000, 50000, 100000, 250000]

arrays = []

#TRAVERSE THE JSON GRAPH AND REPORT THE float() ARRAY POPULATIONS
def arrays_add(id, path, r):
    try:
        if isinstance(r, dict):
            for k, v in [(k, v) for k, v in r.items()]:
                new_path = path + "[" + k + "]"
                arrays_add(id, new_path, v)
        elif isinstance(r, list):
            try:
                values = r.map(float)