예제 #1
0
def cwms(request):
    cwms = CWMS(verbose=True)
    name = request.param
    cwms.connect(name=name)
    yield cwms
    try:
        cwms.delete_location("CWMSPY", "DELETE TS DATA")
        cwms.delete_location("CWMSPY", "DELETE TS ID")
        cwms.delete_location("CWMSPY")
    except:
        pass
    cwms.close()
예제 #2
0
def cwms_data(request):

    cwms = CWMS(verbose=True)
    cwms.connect()
    units, tz = ["cms", "UTC"]
    units, tz = request.param

    alter_session_sql = "ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'"
    cur = cwms.conn.cursor()
    cur.execute(alter_session_sql)
    cur.close()

    try:
        cwms.delete_location("CWMSPY", "DELETE TS DATA")
        cwms.delete_location("CWMSPY", "DELETE TS ID")
        cwms.delete_location("CWMSPY")
    except:
        pass
    cwms.store_location("CWMSPY")
    p_cwms_ts_id = "CWMSPY.Flow.Inst.0.0.REV"
    p_units = units
    times = [
        x.strftime("%Y/%m/%d")
        for x in pd.date_range(datetime(2016, 12, 31), periods=400)
    ]
    values = [math.sin(x) for x in range(len(times))]

    try:
        cwms.store_ts(
            p_cwms_ts_id=p_cwms_ts_id,
            p_units=p_units,
            times=times,
            values=values,
            qualities=None,
            p_override_prot="T",
            timezone=tz,
        )
    except Exception as e:
        try:
            cwms.delete_location("CWMSPY", "DELETE TS DATA")
            cwms.delete_location("CWMSPY", "DELETE TS ID")
            cwms.delete_location("CWMSPY")
        except:
            pass
        c = cwms.close()
        raise e
    yield cwms, times, values, p_cwms_ts_id, units, tz
    cwms.delete_location("CWMSPY", "DELETE TS DATA")
    cwms.delete_location("CWMSPY", "DELETE TS ID")
    cwms.delete_location("CWMSPY")
    c = cwms.close()
예제 #3
0
파일: cli.py 프로젝트: jetilton/cwmspy
def loc(verbose, name, loc, d):
    cwms = CWMS(verbose=verbose)
    cwms.connect(name=name)
    try:
        if d:
            cwms.delete_location(loc, "DELETE TS DATA")
            cwms.delete_location(loc, "DELETE TS ID")
            cwms.delete_location(loc)
        else:
            cwms.store_location(p_location_id=loc)
    except:
        cwms.close()
        return 0

    cwms.close()
예제 #4
0
def cwms():

    cwms = CWMS(verbose=True)
    cwms.connect()

    try:
        cwms.delete_location("CWMSPY", "DELETE TS DATA")
        cwms.delete_location("CWMSPY", "DELETE TS ID")
        cwms.delete_location("CWMSPY")
    except:
        pass
    alter_session_sql = "ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'"
    cur = cwms.conn.cursor()
    cur.execute(alter_session_sql)
    cur.close()
    cwms.store_location("CWMSPY")
    yield cwms
    # test
    try:
        cwms.delete_location("CWMSPY", "DELETE TS DATA")
        cwms.delete_location("CWMSPY", "DELETE TS ID")
        cwms.delete_location("CWMSPY")
    except:
        pass
    c = cwms.close()
예제 #5
0
def cwms():
    cwms = CWMS(verbose=True)
    yield cwms
    c = cwms.close()
예제 #6
0
파일: fixtures.py 프로젝트: jetilton/cwmspy
def connection(name):
    cwms = CWMS(verbose=True)
    cwms.connect(name=name)
    yield cwms
    cwms.close()