def show_devices(self): res=self._cur.execute("select * from devices_table;") namelist=[] for line in res: #print line rowValue = SqlRowProxy(self, 'id', line, self._columns) namelist.append({'device':rowValue.getjsonvalue()}) return namelist
def show_devices(self): res = self._cur.execute("select * from devices_table;") namelist = [] for line in res: #print line rowValue = SqlRowProxy(self, 'id', line, self._columns) namelist.append({'device': rowValue.getjsonvalue()}) return namelist
def show_user(self): try: rows=self._cur.execute("select * from users_table;") rowsvalue = [] if (rows != None): for row in rows: row_value = SqlRowProxy(self, 'username', row) rowsvalue.append(row_value.getjsonvalue()) return rowsvalue except Exception as e: return None, str(e)
def show_user(self): try: rows = self._cur.execute("select * from users_table;") rowsvalue = [] if (rows != None): for row in rows: row_value = SqlRowProxy(self, 'username', row) rowsvalue.append(row_value.getjsonvalue()) return rowsvalue except Exception as e: return None, str(e)
def find_device(self, devicename): tcontent = (devicename, ) self._cur.execute("select * from devices_table where devicename=?;", tcontent) rowold = self._cur.fetchone() if (rowold != None): return SqlRowProxy(self, 'id', rowold, self._columns) return None
def get_subdevices(self, device_id): subdevicestmp = [] tcontent = (device_id, ) sql_state = "select id,sid, ip, port, username, passwd from subdevices_table where sid=?;" res = self._cur.execute(sql_state, tcontent) for row in res: onedevicestmp = SqlRowProxy(self, 'username', row, self._columns_subdevices) subdevicestmp.append(onedevicestmp) return subdevicestmp
def show_ipaddr(self): try: rows = self._cur.execute("select * from whitelist_table;") rowsvalue = [] if (rows != None): for row in rows: row_value = SqlRowProxy(self, 'ipaddress', row) rowsvalue.append(row_value) return rowsvalue except Exception as e: print 'error:%s' % e return None
def find_devicebynamenotid(self, device_name, device_id): tcontent = ( device_name, device_id, ) self._cur.execute( "select * from devices_table where devicename=? and id != ?;", tcontent) linebynamenotid = self._cur.fetchone() if (linebynamenotid != None): return SqlRowProxy(self, 'id', linebynamenotid, self._columns) return None
def find_user(self, username): try: tcontent = (username, ) self._cur.execute( "select username, passwd, role, desc,creation_date,last_login from users_table where username=? ;", tcontent) row = self._cur.fetchone() if (row != None and isinstance(row, tuple)): row_value = SqlRowProxy(self, 'username', row) return row_value except Exception as e: print 'error: %s' % e return None, str(e)
def find_ipaddr(self, ipaddress): try: tcontent = (ipaddress, ) self._cur.execute( "select ipaddress, desc from whitelist_table where ipaddress=? ;", tcontent) row = self._cur.fetchone() if (row != None and isinstance(row, tuple)): row_value = SqlRowProxy(self, 'ipaddress', row) return row_value except Exception as e: print 'error: %s' % e return None return None