Ejemplo n.º 1
0
def printname(long_string):
    """
    Parse incoming string using basic Python string operations
    This method is for hans to use when he incorporates it into the Cold Fusion
    It is not part of PYTHI. If you deleted it, PYTHI would not care.
    """
    parsed = long_string.split("&")
    code = parsed[0].lstrip("dbcode=")
    print(code)
    entity = parsed[1].lstrip("entity_num=")
    print(entity)
    pc = parsed[2].lstrip("probe_code=")
    sd = parsed[3].lstrip("start_date=")
    ed = parsed[4].lstrip("end_date=")
    interval = parsed[5].lstrip("interval=")

    start_date = datetime.datetime(int(sd[0:4]), int(sd[4:6]), int(sd[6:8]), int(sd[8:10]), int(sd[10:12]), 0)
    start_date_string = datetime.datetime.strftime(start_date,'%Y-%m-%d %H:%M:%S')
    end_date = datetime.datetime(int(ed[0:4]), int(ed[4:6]), int(ed[6:8]), int(ed[8:10]), int(ed[10:12]), 0)
    end_date_string = datetime.datetime.strftime(end_date,'%Y-%m-%d %H:%M:%S')

    table_name = code + entity

    printable = "starts on: " + datetime.datetime.strftime(start_date,'%Y-%m-%d %H:%M:%S') + " and ends on: " + datetime.datetime.strftime(end_date,'%Y-%m-%d %H:%M:%S')

    returning_string = "You have chosen " + pc + " from table " + table_name + " which " + printable + " and aggregates for " + interval + " minutes!"


    returning_html = pgb.simple_glitch(code, entity, pc, start_date_string, end_date_string, interval)

    return returning_html
Ejemplo n.º 2
0
def links_to_datas(dbcode):
    """ takes the input from the probes menu and sends it to the back end"""
    startdate = request.forms.get('startdate')
    enddate = request.forms.get('enddate')
    pc = request.forms.get('menu-selection')

    # the 7-digit code, like MS04312 etc.
    dbcode = dbcode

    # in minutes
    interval = request.forms.get('interval')

    date_error = "you must enter the date time as YYYY-MM-DD HH:MM:SS"

    try:
        start_date_string = startdate
    except Exception:
        return date_error
    try:
        end_date_string = enddate
    except Exception:
        return date_error

    # in most cases we shouldn't mess this up, it should always be 7, probably change this.
    if len(dbcode) > 5:
        code = str(dbcode[0:5])
        entity = str(dbcode[5:7])

    returning_html = pgb.simple_glitch(code, entity, pc, start_date_string, end_date_string, interval)
    return returning_html