Ejemplo n.º 1
0
    file_item = inv.getFileItem("file")
    file_path = file_item.getName()
    file_head, file_name = os.path.split(file_path)
    file_title, file_ext = os.path.splitext(file_name)
    if not file_ext == '.csv':
        raise UserException(
            "The file name should have the extension .csv, but in fact it "
            "has the extension '" + file_ext + "'.")
    idx = file_title.rfind('_')
    table = file_title[:idx]
    version = file_title[idx+1:]
    f = StringIO.StringIO()
    if sys.platform.startswith('java'):
        from java.io import InputStreamReader
        stream = InputStreamReader(file_item.getInputStream(), 'utf-8')
        bt = stream.read()
        while bt != -1:
            f.write(chr(bt))
            bt = stream.read()
    else:
        f.writelines(file_item.f.stream)

    f.seek(0)

    def content():
        sess = None
        try:
            sess = db.session()
            reader = iter(csv.reader(f))
            reader.next()
            if table == 'Line_Loss_Factor_Class':
Ejemplo n.º 2
0
        trace = "".join([str(item) + "\r\n" for item in entry.getValue()])
        thread_element.setTextContent(trace + " " + str(dir(thread)))
        thread_element.setAttribute("id", str(thread.getId()))
        thread_element.setAttribute("name", thread.getName())
        thread_element.setAttribute("is-interrupted", str(thread.isInterrupted()))
        thread_element.setAttribute("status", thread.getState().toString())
        thread_element.setAttribute("request", req_map.get(thread.getId()))

    con = Hiber.session().connection()
    db_metadata = con.getMetaData()
    source.setAttribute("db-product-name", db_metadata.getDatabaseProductName())
    source.setAttribute("db-product-version", db_metadata.getDatabaseProductVersion())
    source.setAttribute("db-driver-name", db_metadata.getDriverName())
    source.setAttribute("db-driver-version", db_metadata.getDriverVersion())
    istream = InputStreamReader(Monad.getContext().getResource("/WEB-INF/VERSION").openStream(), "UTF-8")
    c = istream.read()
    sr = StringWriter()
    while c != -1:
        sr.write(c)
        c = istream.read()
    source.setAttribute("chellow-version", sr.toString())

    source.setAttribute("transaction-isolation", str(con.getTransactionIsolation()))

    pstmt = con.prepareStatement("select * from pg_stat_activity")
    rs = pstmt.executeQuery()
    rs_meta = rs.getMetaData()
    pg_stat_activity_el = doc.createElement("pg-stat-activity")
    source.appendChild(pg_stat_activity_el)
    for i in range(1, rs_meta.getColumnCount() + 1):
        column_el = doc.createElement("column")