Changeset 505


Ignore:
Timestamp:
05/31/10 18:17:55 (7 years ago)
Author:
jjr8
Message:

Fixed misc bugs in installation status reporting system.

Location:
Statistics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Statistics/MGETStatsServer.py

    r459 r505  
    3838import xmlrpclib 
    3939 
    40 class InstallationReportV1(object): 
    41     def __init__(self, ipAddr, clientID, shortcuts, arcToolbox, comClasses, mgetVer, pyVer, arcVer, rVer): 
    42         self.DateTime = datetime.datetime.now() 
     40class InstallationReportV2(object): 
     41    def __init__(self, ipAddr, clientID, shortcuts, arcToolbox, comClasses, mgetVer, pyVer, arcVer, rVer, iniFileError): 
     42        self.DateTime = datetime.datetime.utcnow() 
    4343        self.IPAddr = ipAddr 
    4444        self.ClientID = clientID 
     
    5050        self.ArcVer = arcVer 
    5151        self.RVer = rVer 
     52        self.IniFileError = iniFileError 
    5253 
    5354    def __str__(self): 
    54         return '%s: DateTime=%s.%s, IPAddr=%s, ClientID=%s, Shortcuts=%s, ArcToolbox=%s, COMClasses=%s, MGETVer=%s, PyVer=%s, ArcVer=%s, RVer=%s' % (self.__class__.__name__, self.DateTime.strftime('%Y-%m-%d %H:%M:%S'), self.DateTime.microsecond, self.IPAddr, self.ClientID, self.Shortcuts, self.ArcToolbox, self.COMClasses, self.MGETVer, self.PyVer, self.ArcVer, self.RVer) 
     55        return '%s: DateTime=%s.%s, IPAddr=%s, ClientID=%s, Shortcuts=%s, ArcToolbox=%s, COMClasses=%s, MGETVer=%s, PyVer=%s, ArcVer=%s, RVer=%s, IniFileError=%s' % (self.__class__.__name__, self.DateTime.strftime('%Y-%m-%d %H:%M:%S'), self.DateTime.microsecond, self.IPAddr, self.ClientID, self.Shortcuts, self.ArcToolbox, self.COMClasses, self.MGETVer, self.PyVer, self.ArcVer, self.RVer, self.IniFileError) 
    5556 
    5657    def AsList(self): 
    57         return [self.DateTime, self.IPAddr, self.ClientID, self.Shortcuts, self.ArcToolbox, self.COMClasses, self.MGETVer, self.PyVer, self.ArcVer, self.RVer] 
     58        return [self.DateTime, self.IPAddr, self.ClientID, self.Shortcuts, self.ArcToolbox, self.COMClasses, self.MGETVer, self.PyVer, self.ArcVer, self.RVer, self.IniFileError] 
    5859 
    5960class StatsProcessor(object):       # WARNING: Not fully thread safe; do not use with SocketServer threading mixin 
     
    7879 
    7980    def _dispatch(self, method, params): 
    80         if method not in ['ReportMGETInstallationV1', 'DoNothing']: 
     81        if method not in ['ReportMGETInstallationV1', 'ReportMGETInstallationV2', 'DoNothing']: 
    8182            logging.warning('%s attempted to call non-existing method %s.' % (self._ClientAddress, method)) 
    8283            raise RuntimeError('The method %s does not exist.' % method) 
     
    9495 
    9596    def ReportMGETInstallationV1(self, clientID, shortcuts, arcToolbox, comClasses, mgetVer, pyVer, arcVer, rVer): 
    96         item = InstallationReportV1(self._ClientAddress, clientID, shortcuts, arcToolbox, comClasses, mgetVer, pyVer, arcVer, rVer) 
     97        item = InstallationReportV2(self._ClientAddress, clientID, shortcuts, arcToolbox, comClasses, mgetVer, pyVer, arcVer, rVer, None) 
     98        self._Queue.put(item, block=False) 
     99 
     100    def ReportMGETInstallationV2(self, clientID, shortcuts, arcToolbox, comClasses, mgetVer, pyVer, arcVer, rVer, iniFileError): 
     101        item = InstallationReportV2(self._ClientAddress, clientID, shortcuts, arcToolbox, comClasses, mgetVer, pyVer, arcVer, rVer, iniFileError) 
    97102        self._Queue.put(item, block=False) 
    98103 
  • Statistics/MGETStatsSummarizer.py

    r460 r505  
    5959                        d[fieldNames[i]].append(None) 
    6060                    elif fieldTypes[i] == types.StringType: 
    61                         d[fieldNames[i]].append(row[i]) 
     61                        d[fieldNames[i]].append(row[i].strip()) 
    6262                    elif fieldTypes[i] == types.BooleanType: 
    6363                        assert row[i].lower() in ['false', 'true'] 
     
    237237                        ipToCountryCode[ip] = None 
    238238                     
    239                     asNumber = response.answers[0]['data'][0].split(' | ')[0] 
     239                    asNumber = response.answers[0]['data'][0].split(' | ')[0].split()[-1]       # If multiple AS numbers, use the last one, which is likely to be the most specific 
    240240                    try: 
    241241                        try: 
     
    268268                if ipToASName[ip].lower().find('janet ip service') > 0: 
    269269                    ipToCountryCode[ip] = 'UK' 
     270                elif ipToASName[ip].lower().find('uiversitaet fuer bodenkultur') > 0: 
     271                    ipToCountryCode[ip] = 'AT' 
     272                elif ipToASName[ip].lower().find('garr italian academic and research network') > 0: 
     273                    ipToCountryCode[ip] = 'IT' 
     274                elif ipToASName[ip].lower().find('cesca - anella cientifica') > 0: 
     275                    ipToCountryCode[ip] = 'ES' 
     276                elif ipToASName[ip].lower().find('dfn-ip service') > 0: 
     277                    ipToCountryCode[ip] = 'DE' 
     278                elif ipToASName[ip].lower().find('jrc joint research center') > 0: 
     279                    ipToCountryCode[ip] = 'IT' 
    270280 
    271281            # Append the country code, country name, and AS name. 
     
    404414    r('y <- cumsum(h$counts)') 
    405415    r('options(warn=-1)')   # So the following statement does not erroneously issue warnings for the format argument 
    406     r('plot(x, y, type="s", ylab="Cumulative Count of Computers with MGET Installed", format="%b-%y")') 
     416    r('plot(x, y, type="s", ylab="Cumulative Count of Computers with MGET Installed", xaxt="n")') 
     417    r('text(x[length(x)-1] + as.double(difftime(x[length(x)], x[length(x)-1], units="secs"))/2, y[length(y)]*1.02, y[length(y)])') 
     418    r('axis(1, x[seq(1, length(x), 2)], labels=format(x[seq(1, length(x), 2)], "%b-%y"))') 
    407419    r('options(warn=0)') 
    408420    r('dev.off()') 
     
    414426    r('a <- aggregate(clientStatus, list(MGETVer=clientStatus$MGETVer), length)') 
    415427    r('clientStatus$MGETVer[clientStatus$MGETVer == "0.7f"] <- "0.7"') 
    416     r('png("%s", width=480, height=480)' % os.path.join(dbDir, 'Plots', 'MGETVersions.png').replace('\\', '\\\\')) 
     428    r('png("%s", width=640, height=480)' % os.path.join(dbDir, 'Plots', 'MGETVersions.png').replace('\\', '\\\\')) 
    417429    r('par(mar=c(5.1, 4.1, 1, 0))') 
    418430    r('midpoints <- barplot(a[[2]], ylab="Computers with MGET Installed", xaxt="n")') 
    419431    r('title(xlab="MGET Version", mgp=c(3.5, 1, 0))') 
    420432    r('text(midpoints[,1], par("usr")[3] - 3, labels=sub("[abf].*","", a[[1]]), xpd=TRUE)') 
    421     r('text(midpoints[,1], par("usr")[3] - 8, labels=sub("b", " Beta ", sub("a", " Alpha ", sub("f", "", sub("[^abf]+","", a[[1]])))), xpd=TRUE)') 
     433    r('text(midpoints[,1], par("usr")[3] - 14, labels=sub("b", " Beta ", sub("a", " Alpha ", sub("f", "", sub("[^abf]+","", a[[1]])))), xpd=TRUE)') 
    422434    r('dev.off()') 
    423435 
    424436    r('a <- aggregate(clientStatus, list(RVer=clientStatus$ArcVer), length)') 
    425     r('png("%s", width=480, height=480)' % os.path.join(dbDir, 'Plots', 'ArcGISVersions.png').replace('\\', '\\\\')) 
     437    r('png("%s", width=640, height=480)' % os.path.join(dbDir, 'Plots', 'ArcGISVersions.png').replace('\\', '\\\\')) 
    426438    r('par(mar=c(5.1, 4.1, 1, 0))') 
    427439    r('midpoints <- barplot(a[[2]], names.arg=a[[1]], ylab="Computers with MGET Installed", xaxt="n")') 
    428440    r('title(xlab="ArcGIS Version at MGET Installation Time", mgp=c(3.5, 1, 0))') 
    429441    r('text(midpoints[,1], par("usr")[3] - 3, labels=sub(" .*","", a[[1]]), xpd=TRUE)') 
    430     r('text(midpoints[,1], par("usr")[3] - 7, labels=sub("[^ ]+ ?","", a[[1]]), xpd=TRUE)') 
     442    r('text(midpoints[,1], par("usr")[3] - 12, labels=sub("[^ ]+ ?","", a[[1]]), xpd=TRUE)') 
    431443    r('dev.off()') 
    432444 
     
    438450 
    439451    r('a <- aggregate(clientStatus, list(RVer=clientStatus$RVer), length)') 
    440     r('png("%s", width=480, height=480)' % os.path.join(dbDir, 'Plots', 'RVersions.png').replace('\\', '\\\\')) 
     452    rVer2 = r('a[[1]]') 
     453    rVer2[-1] = '99.99.99' 
     454    r['RVer2'] = map(lambda s: '%02i%02i%02i' % tuple(map(int, s.split('.'))), rVer2) 
     455    r('a <- data.frame(RVer=a[[1]], Count=a[[2]], RVer2=RVer2)') 
     456    r('a <- a[order(as.character(a[[3]])),]') 
     457    r('png("%s", width=960, height=480)' % os.path.join(dbDir, 'Plots', 'RVersions.png').replace('\\', '\\\\')) 
    441458    r('par(mar=c(4.6, 4.1, 1, 0))') 
    442459    r('barplot(a[[2]], names.arg=a[[1]], xlab="R Version at MGET Installation Time", ylab="Computers with MGET Installed")') 
     
    447464 
    448465    r('a <- aggregate(clientStatus, list(CountryName=clientStatus$CountryName), length)') 
    449     r('png("%s", width=768, height=480)' % os.path.join(dbDir, 'Plots', 'InstallationsByCountry.png').replace('\\', '\\\\')) 
    450     r('par(mar=c(8.1, 4.1, 2, 0)); midpoints <- my.barplot(a[[2]], names.arg=a[[1]], ylab="Computers with MGET Installed", xaxt="n", ylim=c(0,10)); text(midpoints[,1], par("usr")[3] - 0.25, srt=45, adj=1, labels=a[[1]], xpd=TRUE)') 
     466    r('png("%s", width=1024, height=480)' % os.path.join(dbDir, 'Plots', 'InstallationsByCountry.png').replace('\\', '\\\\')) 
     467    r('par(mar=c(8.1, 4.1, 2, 0)); midpoints <- my.barplot(a[[2]], names.arg=a[[1]], ylab="Computers with MGET Installed", xaxt="n", ylim=c(0,25)); text(midpoints[,1], par("usr")[3] - 0.25, srt=45, adj=1, labels=a[[1]], xpd=TRUE)') 
    451468    r('dev.off()') 
    452469 
Note: See TracChangeset for help on using the changeset viewer.