def parse(self,results):
     """
     Read command output with each software package on line and
     convert into list of software dictionaries.
     """
     sw=[]
     t=time.localtime()
     for n in results.splitlines():
         sw.append(utils.createSoftwareDict(n,self.vendor,n,t))
     return sw
Beispiel #2
0
 def process(self, device, results, log):
     """
     Return a ReltionshipMap with the installed software.
     """
     log.info("Collecting installed software for host %s." % device.id)
     softwareDicts = self.parseResultsFunc(results)
     
     log.debug("First three software dictionaries:\n%s" % (
             pformat(softwareDicts[:3])),)
             
     return utils.createSoftwareRelationshipMap(softwareDicts)
def parseRpmResults(results, softwareDicts):
    """
    Parse the results of the rpm command to create a dictionary of installed
    software.
    """
    for line in results.splitlines():
        fields = dict(zip(FIELDS, line.split(FIELD_DELIMETER)))
        if isCompleteLine(fields):
            softwareDicts.append(utils.createSoftwareDict(
                    "%(NAME)s %(VERSION)s-%(RELEASE)s" % fields,
                    fields["VENDOR"],
                    fields["SUMMARY"],
                    gmtime(int(fields["INSTALLTIME"]))))
    return softwareDicts
Beispiel #4
0
def parseRpmResults(results, softwareDicts):
    """
    Parse the results of the rpm command to create a dictionary of installed
    software.
    """
    for line in results.splitlines():
        fields = dict(zip(FIELDS, line.split(FIELD_DELIMETER)))
        if isCompleteLine(fields):
            softwareDicts.append(
                utils.createSoftwareDict(
                    "%(NAME)s %(VERSION)s-%(RELEASE)s" % fields,
                    fields["VENDOR"], fields["SUMMARY"],
                    gmtime(int(fields["INSTALLTIME"]))))
    return softwareDicts
Beispiel #5
0
def parseDpkgResults(results, softwareDicts):
    """
    Parse the results of the dpkg command to create a dictionary of installed
    software.
    """
    timeDict = {}
    for line in results.splitlines():
        line = line.split('_field:')[1:]
        if len(line) == 2:
            timeDict[line[0].rsplit(':', 1)[0]] = gmtime(int(line[1]))
        elif line and '' not in line and line[0] in timeDict:
            softwareDicts.append(
                utils.createSoftwareDict(line[0] + ' ' + line[1],
                                         getVendor(line[2]), line[3],
                                         timeDict[line[0]]))
    return softwareDicts
def parseDpkgResults(results, softwareDicts):
    """
    Parse the results of the dpkg command to create a dictionary of installed
    software.
    """
    timeDict = {}
    for line in results.splitlines():
        line = line.split('_field:')[1:]
        if len(line) == 2:
            timeDict[line[0].rsplit(':',1)[0]] = gmtime(int(line[1]))
        elif line and '' not in line and line[0] in timeDict:
            softwareDicts.append(utils.createSoftwareDict(
                    line[0] + ' ' + line[1],
                    getVendor(line[2]),
                    line[3],
                    timeDict[line[0]]))
    return softwareDicts