Changeset 6420 for hwdetector


Ignore:
Timestamp:
Dec 1, 2017, 11:38:50 AM (22 months ago)
Author:
mabarracus
Message:

Fix type checks with unicode vars

Location:
hwdetector/trunk/fuentes
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • hwdetector/trunk/fuentes/debian/changelog

    r6413 r6420  
     1hwdetector (0.1.6) xenial; urgency=medium
     2
     3  * Fix type checks with unicode vars
     4
     5 -- M.Angel Juan <m.angel.juan@gmail.com>  Fri, 01 Dec 2017 11:37:58 +0100
     6
    17hwdetector (0.1.5) xenial; urgency=medium
    28
  • hwdetector/trunk/fuentes/hwdetector.install/hwdetector/modules/llxhelpers.py

    r6413 r6420  
    5757
    5858        else:
    59             if type(args[0]) == type(list()):
     59            if isinstance(args[0],list):
    6060                string = ''.join(str(args[0]))
    6161            else:
     
    211211            return None
    212212        else:
    213             if type(kwargs['run']) != type(list()):
     213            if not isinstance(kwargs['run'],list):
    214214                runlist=kwargs['run'].split(' ')
    215215            else:
  • hwdetector/trunk/fuentes/hwdetector.install/hwdetector/modules/llxldap.py

    r6399 r6420  
    8686
    8787    def parse_tree(self,*args,**kwargs):
    88         if type(args[0]) != type(str()):
     88        if not (isinstance(args[0],str) or isinstance(args[0],unicode)):
    8989            return None
    9090        output = {}
     
    127127            out = args[1]
    128128        for k in d.keys():
    129             if type(d[k]) == type(dict()):
     129            if isinstance(d[k],dict):
    130130                split = k.split('=')
    131131                if len(split) > 1:
     
    267267                netinfo=kwargs['NETINFO']
    268268                if netinfo:
    269                     aliased_interfaces = [ k for k in netinfo if type(netinfo[k]) == type(dict()) and 'nalias' in netinfo[k] and netinfo[k]['nalias'] > 0 ]
     269                    aliased_interfaces = [ k for k in netinfo if isinstance(netinfo[k],dict) and 'nalias' in netinfo[k] and netinfo[k]['nalias'] > 0 ]
    270270                    for i in aliased_interfaces:
    271271                        for n in range(netinfo[i]['nalias']):
  • hwdetector/trunk/fuentes/hwdetector.install/hwdetector/modules/llxprocess.py

    r6399 r6420  
    3535        l=[]
    3636        for x in args[1:]:
    37             if type(x) == type(list()):
     37            if isinstance(x,list):
    3838                l.extend(x)
    3939            else:
     
    5252
    5353        psout=self.execute(run='ps --no-headers -Awwo pid,euid,egid,args')
    54         regexp=re.compile(r'(?P<PID>\d+)\s+(?P<EUID>\d+)\s+(?P<EGID>\d+)\s+(?P<FULL_CMD>.*)$')
     54        regexp=re.compile(r'(?P<PID>\d+)\s+(?P<EUID>\d+)\s+(?P<EGID>\d+)\s+(?P<FULL_CMD>.*)$',re.UNICODE)
    5555        for line in psout.split("\n"):
    5656            m=re.search(regexp,line)
  • hwdetector/trunk/fuentes/hwdetector.install/hwdetector/modules/llxsystemtest.py

    r6399 r6420  
    1313        if not ('result' in kwargs and 'msg' in kwargs):
    1414            return
    15         if type(kwargs['result']) == type(list()):
     15        if isinstance(kwargs['result'],list):
    1616            result=kwargs['result']
    1717        else:
  • hwdetector/trunk/fuentes/hwdetector.install/hwdetector/modules/llxusers.py

    r6399 r6420  
    113113        try:
    114114            people=LDAP_INFO['CONFIG']['DB']['net']['lliurex']['ma5']['People']
    115             users=[(x,people['Students'][x]) for x in people['Students'].keys() if type(people['Students'][x]) == type(dict())]
    116             admins=[(x,people['Admins'][x]) for x in people['Admins'].keys() if type(people['Admins'][x]) == type(dict())]
    117             teachers=[(x,people['Teachers'][x]) for x in people['Teachers'].keys() if type(people['Teachers'][x]) == type(dict())]
     115            users=[(x,people['Students'][x]) for x in people['Students'].keys() if isinstance(people['Students'][x],dict)]
     116            admins=[(x,people['Admins'][x]) for x in people['Admins'].keys() if isinstance(people['Admins'][x],dict)]
     117            teachers=[(x,people['Teachers'][x]) for x in people['Teachers'].keys() if isinstance(people['Teachers'][x],dict)]
    118118        except Exception as e:
    119119            log.warning('Fail getting needed ldap information, using fake information only for current user')
  • hwdetector/trunk/fuentes/hwdetector.install/hwdetector/modules/llxuserstest.py

    r6399 r6420  
    1313        if not ('result' in kwargs and 'msg' in kwargs):
    1414            return
    15         if type(kwargs['result']) == type(list()):
     15        if isinstance(kwargs['result'],list):
    1616            result=kwargs['result']
    1717        else:
Note: See TracChangeset for help on using the changeset viewer.