コード例 #1
0
ファイル: lookupSerial.py プロジェクト: WongTai/snippets
    def __init__(self, serialnumber):
        self.sn=serialnumber
        query="select * from tbl_hpidentification " \
            + " where serialnumber_pk = '" + serialnumber + "'"

        conn=getdb.getDBConn()
        st=conn.createStatement()
        rs=st.executeQuery(query)
        rsmd=rs.getMetaData()

        if not rs.next():
            raise "No results"

        self.__fields={}
        self.__columns=[]
        for i in range(rsmd.getColumnCount()):
            columnname=str(rsmd.getColumnName(i+1))
            self.__columns.append(columnname)
            self.__fields[columnname]=str(rs.getString(i+1))

        if rs.next():
            raise "Too many results"

        rs.close()
        st.close()
        conn.close()
コード例 #2
0
    def __init__(self, serialnumber):
        self.sn = serialnumber
        query="select * from tbl_hpidentification " \
            + " where serialnumber_pk = '" + serialnumber + "'"

        conn = getdb.getDBConn()
        st = conn.createStatement()
        rs = st.executeQuery(query)
        rsmd = rs.getMetaData()

        if not rs.next():
            raise "No results"

        self.__fields = {}
        self.__columns = []
        for i in range(rsmd.getColumnCount()):
            columnname = str(rsmd.getColumnName(i + 1))
            self.__columns.append(columnname)
            self.__fields[columnname] = str(rs.getString(i + 1))

        if rs.next():
            raise "Too many results"

        rs.close()
        st.close()
        conn.close()
コード例 #3
0
ファイル: matrix.py プロジェクト: WongTai/snippets
    def __initGroup(self, fileType, group):
        conn=getdb.getDBConn()
        pst=conn.prepareStatement(
            """select * from tbl_FileVersion_map_ref 
                where FileType_num_fk = ? and Group_idnum_fk = ?""")
        pst.setInt(1, fileType.getTypeId())
        pst.setInt(2, group.getId())

        matrix=com.twowire.compatibility.VersionMatrix()

        rs=pst.executeQuery()
        while rs.next():
            low=rs.getInt("CompatibilityFrom_num_fk")
            if rs.wasNull():
                low=None
            else:
                low=java.lang.Integer(low)
            high=rs.getInt("CompatibilityTo_num_fk")
            if rs.wasNull():
                high=None
            else:
                high=java.lang.Integer(high)
            vr=com.twowire.compatibility.VersionRange(
                low, high, java.lang.Integer(rs.getInt("FileVersion_num")))
            matrix.add(vr)
        rs.close()
        pst.close()
        conn.close()

        self.byGroup[(fileType, group)]=matrix
コード例 #4
0
ファイル: matrix.py プロジェクト: TaRiven/snippets
    def __initGroup(self, fileType, group):
        conn = getdb.getDBConn()
        pst = conn.prepareStatement("""select * from tbl_FileVersion_map_ref 
                where FileType_num_fk = ? and Group_idnum_fk = ?""")
        pst.setInt(1, fileType.getTypeId())
        pst.setInt(2, group.getId())

        matrix = com.twowire.compatibility.VersionMatrix()

        rs = pst.executeQuery()
        while rs.next():
            low = rs.getInt("CompatibilityFrom_num_fk")
            if rs.wasNull():
                low = None
            else:
                low = java.lang.Integer(low)
            high = rs.getInt("CompatibilityTo_num_fk")
            if rs.wasNull():
                high = None
            else:
                high = java.lang.Integer(high)
            vr = com.twowire.compatibility.VersionRange(
                low, high, java.lang.Integer(rs.getInt("FileVersion_num")))
            matrix.add(vr)
        rs.close()
        pst.close()
        conn.close()

        self.byGroup[(fileType, group)] = matrix
コード例 #5
0
    def go(self):
        gws = lookupSerial.GatewaySerial(myserialnumber)
        gwb = gws.getGatewayBean()

        db = getdb.getDBConn(db='Aztec6')

        query="select * from tbl_HP where HPBox_num_fk_pk=" \
            + `gwb.getHPBoxNum()`
        st = db.createStatement()
        rs = st.executeQuery(query)

        getdb.dumpResults(rs)
コード例 #6
0
ファイル: fwver.py プロジェクト: WongTai/snippets
    def go(self):
        gws=lookupSerial.GatewaySerial(myserialnumber)
        gwb=gws.getGatewayBean()

        db=getdb.getDBConn(db='Aztec6')

        query="select * from tbl_HP where HPBox_num_fk_pk=" \
            + `gwb.getHPBoxNum()`
        st=db.createStatement()
        rs=st.executeQuery(query)

        getdb.dumpResults(rs)
コード例 #7
0
ファイル: getipaddresses.py プロジェクト: ktosiu/snippets-2
#!/usr/bin/env jython

import getdb

query1="select sourceipaddress, hpipaddress from tbl_hpidentification " \
    + " where sourceipaddress is not null or hpipaddress is not null"

conn = getdb.getDBConn()
st = conn.createStatement()
rs = st.executeQuery(query1)

count = 0
diff = 0
empty = 0
while rs.next():
    s = rs.getString("sourceipaddress").rstrip()
    h = rs.getString("hpipaddress").rstrip()

    if s == '' and h == '':
        empty += 1
    else:
        if s != h:
            diff += 1

        count += 1

        print s + "\t" + h

print "# Total IP addresses: ", count
print "# Different IP addresses: ", diff
print "# Empty IP addresses: ", empty
コード例 #8
0
ファイル: getserialnum.py プロジェクト: WongTai/snippets
#!/usr/bin/env jython

import getdb

query="""
    select
            owner.firstname, owner.lastname,
            mfg.serialnumber
        from
            tbl_owner owner, tbl_hpmanufacturingdata mfg,
            tbl_hpowner_map map
        where
            owner.organization_num_fk = 74
            and owner.owner_idnum_pk = map.owner_idnum_fk
            and mfg.hpbox_num_pk = map.hpbox_num_fk
"""

conn=getdb.getDBConn()
st=conn.createStatement()
rs=st.executeQuery(query)
while rs.next():
    print rs.getString(1)
    print rs.getString(2)
    print rs.getString(3)
    print "--------"