Exemple #1
0
 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
Exemple #2
0
 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
Exemple #3
0
 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)  
Exemple #4
0
 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)
Exemple #5
0
 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
Exemple #6
0
 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
Exemple #7
0
 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
Exemple #8
0
 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
Exemple #9
0
    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)
Exemple #10
0
    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