Esempio n. 1
0
def getCompNamefromTrc_Flowcfg(resname, flowsn):
    session = settings.DB_SESSION()
    compname = session.execute(
        """select COMPNAME from trc_flowcfg where resname = '%s' and flowsn = %d"""
        % (resname, flowsn))
    if compname.fetchone():
        return compname.fetchone()[0].strip()
    else:
        return "pub_error"
Esempio n. 2
0
def getNamefromTable(table, name, **kwargs):
    where = '1 = 1'
    for k in kwargs:
        if type(kwargs[k]) == int:
            where = where + "and %s=%d" % (k, kwargs[k])
        else:
            where = where + "and %s='%s'" % (k, kwargs[k])
    sql = """select %s from %s where %s""" % (name, table, where)
    session = settings.DB_SESSION()
    compname = session.execute(sql).fetchone()
    if compname:
        return compname[0].strip()
    else:
        return "null"
Esempio n. 3
0
def getNameListfromTable(table, *args, **kwargs):
    name = ','.join(args)
    where = '1 = 1'
    for k in kwargs:
        if type(kwargs[k]) == int:
            where = where + "and %s=%d" % (k, kwargs[k])
        else:
            where = where + "and %s='%s'" % (k, kwargs[k])
    sql = """select %s from %s where %s""" % (name, table, where)
    session = settings.DB_SESSION()
    compname = session.execute(sql).fetchall()
    if compname:
        return compname
    else:
        return []
Esempio n. 4
0
def createxmlp(resname):
    session = settings.DB_SESSION()
    conut = session.execute(
        """select count(1) from trc_xmlpcfg where resname = '%s'""" %
        resname).fetchone()
    root = {}
    for i in range(int(conut[0])):
        h = session.execute(
            """select trim(nodename),trim(nodetype),trim(fnodename),trim(inodexp) from trc_xmlpcfg where resname = '%s' and fldsn ='%d' """
            % (resname, i))
        h = h.fetchone()
        nodename, nodetype, fnodename, inodexp = h
        if fnodename and nodetype != '1':
            deepdict(fnodename, root, nodename, inodexp)
    open(resname + '.json', 'w').write(str(root).replace("'", '"'))
    return root
Esempio n. 5
0
def getnods_list(resname):
    session = settings.DB_SESSION()
    jd_list = session.execute(
        """select * from trc_flowcfg where resname = '%s'""" % resname)
    rest = []
    for jd in jd_list:
        d_tmp = {}
        d_tmp_rets = {}
        d_tmp['rank'] = 999
        d_tmp['id'] = jd.compname.strip()
        d_tmp['type'] = 'py'
        d_tmp['desc'] = jd.snote.strip() if jd.snote else jd.snote
        h = session.execute(
            """select * from trc_fcompstatcfg where resname = '%s' and flowsn = %d"""
            % (resname, jd.flowsn))
        h = h.fetchall()
        for i in h:
            d_tmp_rets[i.compstatus] = i.nextflowsn
        d_tmp['rets'] = d_tmp_rets
        print d_tmp
        rest.append(d_tmp)
    return rest
Esempio n. 6
0
def getnods_list(resname):
    session = settings.DB_SESSION()
    jd_list = session.execute(
        """select * from trc_flowcfg where resname = '%s'""" % resname)
    rest = []
    for jd in jd_list:
        d_tmp = {}
        d_tmp_rets = {}
        d_tmp['rank'] = 999
        d_tmp['idname'] = jd.compname.strip()
        d_tmp['id'] = jd.flowsn
        d_tmp['type'] = 'py'
        d_tmp['desc'] = jd.snote.strip() if jd.snote else jd.snote
        input_list = getNameListfromTable('trc_fcompparacfg',
                                          'paracont',
                                          'parasn',
                                          resname=resname,
                                          flowsn=jd.flowsn)
        if len(input_list) > 1:
            d_tmp['input'] = {}
        for para in input_list:
            d_tmp['input']['_%d' %
                           para[1]] = para[0].strip() if para[0] else para[0]
        h = session.execute(
            """select * from trc_fcompstatcfg where resname = '%s' and flowsn = %d"""
            % (resname, jd.flowsn))
        h = h.fetchall()
        for i in h:
            print jd.compname.strip()
            if jd.compname.strip() == 'END':
                d_tmp_rets['0'] = 'end'
            #d_tmp_rets[i.compstatus] = getCompNamefromTrc_Flowcfg(resname,i.nextflowsn)
            d_tmp_rets[i.compstatus] = i.nextflowsn
        d_tmp['rets'] = d_tmp_rets
        rest.append(d_tmp)
    return rest