Python exception and abnormal mac address
[Root @ pc0003 MySQL-python-1.2.5] # yum install MySQL-python #! /Usr/bin/python # coding = UTF-8 ''' dependent on MySQLdb python library depends on host = "192. 168. ****. * ** ", user =" ***** ", passwd =" ***** ", db =" ***** "depends on glpi. switch1119 table ''' import osimport MySQLdbos. mkdir (r 'tmp ') filedir = '. /tmp/6.exception.mac-wlan.onboard.mac.error.list.csv 'macfile = open (filedir, 'w') MacFile. write ("exception. mac \ nMAC address, user, device model, approval source \ n ") print (" contacting Database ") conn = MySQLdb. connect (host = "192. 168. ****. * *** ", user =" ***** ", passwd =" ***** ", db = "*****" Your curtailconn.cursor(your select‑cur.exe cute ("use *****;") print ("retrieving exceptions that do not match the wlan and glpi. mac "select0000cur.exe cute (" select mac from switch1119 where UPPER (switch1119.mac) not in (select upper (buffers) from UPPER, glpi_devicenetworkcards where buffers = upper); ") info = cur. fetchmany (sel Ect) for I in info: MacFile. write (str (I) [2:-3] + ", unknow \ n") print ("retrieving MAC of Ethernet-Onboard in glpi stored in MAC in wlan ") macFile. write ("\ n \ nonboard. mac? \ NMAC address, user, device model, approval source \ n ")select0000cur.exe cute (" select mac from switch1119 where UPPER (switch1119.mac) in (select upper (cursor) from glpi_items_devicenetworkcards, glpi_devicenetworkcards where region = glpi_devicenetworkcards.id and glpi_devicenetworkcards.designation = 'ethernet-onboard'); ") info = cur. fetchmany (select) for I in info: MacFile. write (str (I) [2:-3] + ", unknow \ n") cur. close () conn. commit () conn. close () MacFile. close () print ('file storage path: '+ filedir) [root @ pc0003 glpi_switch_ocs] # cat. /tmp/6.exception.mac-wlan.onboard.mac.error.list.csv exception. macMAC address, user, device model, approval Source: 20: 7C: 8F: 76: *****, unknow34: DE: 1A: 1B: *****, unknow onboard. mac? MAC address, user, device model, approval source C8: F7: 33: 15: *****, unknowC8: F7: 33: 18: *****, unknow