Ejemplo n.º 1
0
async def main(doc_id):
    global sid
    # Connect to engine
    async with set_connection(**props) as websocket:
        msg = await websocket.recv()
        logging.debug(f"< {msg}")
    # Connect to App
    async with set_connection(doc_id, **props) as websocket:
        sid = 0
        msg = await websocket.recv()
        logging.debug(f"< {msg}")
        app_handle = await open_app(websocket, sid := sid + 1, doc_id)
        if isinstance(app_handle, str):
            # Error message found, app_handle needs to be int
            msg = f"Application not found: {app_handle}"
            logging.critical(msg)
            return
        app_props = await get_app_properties(websocket, sid := sid + 1, app_handle)
        app_name = app_props['qTitle']
        fn = my_env.get_valid_path(os.getenv('MASTERDIR'), f"{app_name}.xlsx")
        xl = write2excel.Write2Excel()
        objects_handle = await create_master_objectlist(websocket, sid := sid + 1, app_handle)
        layout = await get_layout(websocket, sid := sid + 1, objects_handle)
        # Get variable list
        # variables = layout['qVariableList']['qItems']
        # print(json.dumps(variables, ensure_ascii=False, indent=2))
        # Collect master dimension information
        await dimensions(websocket, app_handle, layout['qDimensionList']['qItems'], xl)
        # Collect master measurement information
        await measurements(websocket, app_handle, layout['qMeasureList']['qItems'], xl)
        xl.close_workbook(fn)
    logging.info("End Application")
Ejemplo n.º 2
0
    # First get all field names for the table
    field_array = mdb.get_fields(table)
    # Drop fields from array
    field_array.remove("solId")
    # Then add table identifier on field name
    fields_str = ", ".join(["t1.{f}".format(f=f) for f in field_array])

    # Add (lookup) fields
    add_fields_array = ["sol.solId"]
    all_fields = ", ".join(add_fields_array)

    fields = fields_str + ", " + all_fields

    query = """
    SELECT {fields}
    FROM {table} t1
    INNER JOIN sol ON sol.id = t1.solId
    INNER JOIN client ON client.id=sol.clientId
    WHERE client.clientId="{clientId}";
    """.format(clientId=cfg["Murcs"]["clientId"], fields=fields, table=table)
    res = mdb.get_query(query)

    xl = write2excel.Write2Excel()
    xl.init_sheet(lbl)
    xl.write_content(res)

    fn = os.path.join(cfg["MurcsDump"]["dump_dir"],
                      "murcs_{lbl}.xlsx".format(lbl=lbl))
    xl.close_workbook(fn)
    mdb.close()
Ejemplo n.º 3
0
    # Then add wave information to application
    for rec in res:
        # Add wave to solution record
        try:
            rec["Wave"] = wave_d[str(rec["solId"])]
        except KeyError:
            logging.error("solId {solId} not in appslistconsolidated!".format(
                solId=rec["solId"]))
            rec["Wave"] = ""
        # Count servers per solution
        try:
            servercnt[str(rec["solId"])] += 1
        except KeyError:
            servercnt[str(rec["solId"])] = 1

    xls = write2excel.Write2Excel()
    xls.init_sheet(lbl)
    xls.write_content(res)

    # fn = os.path.join(cfg["MurcsDump"]["dump_dir"], "report_{lbl}.xlsx".format(lbl=lbl))
    # xls.close_workbook(fn)

    # Create list of records with servercount per solution
    apps_summ = []
    for row in df.iterrows():
        # Get excel row in dict format
        xl = row[1].to_dict()
        if pandas.notnull(xl["UniqueId"]):
            wave_d[str(xl["UniqueId"])] = xl["WAVE-GROUP"]
            params = dict(solId=xl["UniqueId"],
                          solName=xl["fullname"],