def markBuildsDeleted(): """ Marks the builds using the specified binaries as deleted. """ oParser = OptionParser() oParser.add_option('-q', '--quiet', dest='fQuiet', action='store_true', help='Quiet execution'); (oConfig, asArgs) = oParser.parse_args() if not asArgs: if not oConfig.fQuiet: sys.stderr.write('syntax error: No builds binaries specified\n'); return 1; oDb = TMDatabaseConnection() oLogic = BuildLogic(oDb) for sBuildBin in asArgs: try: cBuilds = oLogic.markDeletedByBinaries(sBuildBin, fCommit = True) except: if oConfig.fQuiet: sys.exit(1); raise; else: if not oConfig.fQuiet: print("del_build.py: Marked %u builds associated with '%s' as deleted." % (cBuilds, sBuildBin,)); oDb.close() return 0;
def add(self): """ Add build data record into database. """ oDb = TMDatabaseConnection() # Assemble the build data. oBuildData = BuildDataEx() oBuildData.idBuildCategory = None oBuildData.iRevision = self.oConfig.iRevision oBuildData.sVersion = self.oConfig.sProductVersion oBuildData.sLogUrl = self.oConfig.sBuildLogPath oBuildData.sBinaries = ','.join(self.oConfig.asFiles) oBuildData.oCat = BuildCategoryData().initFromValues( sProduct=self.oConfig.sProductName, sRepository=self.oConfig.sRepository, sBranch=self.oConfig.sBranch, sType=self.oConfig.sBuildType, asOsArches=self.oConfig.asTargetOsArches) # Add record to database try: BuildLogic(oDb).addEntry(oBuildData, fCommit=True) except: if self.oConfig.fQuiet: sys.exit(1) raise oDb.close() return 0
def add(self): """ Add build data record into database. """ oDb = TMDatabaseConnection() # Assemble the build data. oBuildData = BuildDataEx() oBuildData.idBuildCategory = None; oBuildData.iRevision = self.oConfig.iRevision oBuildData.sVersion = self.oConfig.sProductVersion oBuildData.sLogUrl = self.oConfig.sBuildLogPath oBuildData.sBinaries = ','.join(self.oConfig.asFiles); oBuildData.oCat = BuildCategoryData().initFromValues(sProduct = self.oConfig.sProductName, sRepository = self.oConfig.sRepository, sBranch = self.oConfig.sBranch, sType = self.oConfig.sBuildType, asOsArches = self.oConfig.asTargetOsArches); # Add record to database try: BuildLogic(oDb).addEntry(oBuildData, fCommit = True); except: if self.oConfig.fQuiet: sys.exit(1); raise; oDb.close(); return 0;
def markBuildsDeleted(): """ Marks the builds using the specified binaries as deleted. """ oParser = OptionParser() oParser.add_option('-q', '--quiet', dest='fQuiet', action='store_true', help='Quiet execution'); (oConfig, asArgs) = oParser.parse_args() if len(asArgs) == 0: if not oConfig.fQuiet: sys.stderr.write('syntax error: No builds binaries specified\n'); return 1; oDb = TMDatabaseConnection() oLogic = BuildLogic(oDb) for sBuildBin in asArgs: try: cBuilds = oLogic.markDeletedByBinaries(sBuildBin, fCommit = True) except: if oConfig.fQuiet: sys.exit(1); raise; else: if not oConfig.fQuiet: print "del_build.py: Marked %u builds associated with '%s' as deleted." % (cBuilds, sBuildBin,); oDb.close() return 0;
def main(self): """ Main function. """ oDb = TMDatabaseConnection() oLogic = VcsRevisionLogic(oDb) # Where to start. iStartRev = 0 if not self.oConfig.fFull: iStartRev = oLogic.getLastRevision(self.oConfig.sRepository) if iStartRev == 0: iStartRev = self.oConfig.iStartRevision # Construct a command line. os.environ['LC_ALL'] = 'en_US.utf-8' asArgs = [ 'svn', 'log', '--xml', '--revision', str(iStartRev) + ':HEAD', ] if self.oConfig.asExtraOptions is not None: asArgs.extend(self.oConfig.asExtraOptions) asArgs.append(self.oConfig.sUrl) if not self.oConfig.fQuiet: print('Executing: %s' % (asArgs, )) sLogXml = utils.processOutputChecked(asArgs) # Parse the XML and add the entries to the database. oParser = ET.XMLParser(target=ET.TreeBuilder(), encoding='utf-8') oParser.feed(sLogXml.encode('utf-8')) # does its own decoding and processOutputChecked always gives us decoded utf-8 now. oRoot = oParser.close() for oLogEntry in oRoot.findall('logentry'): iRevision = int(oLogEntry.get('revision')) sAuthor = oLogEntry.findtext('author').strip() sDate = oLogEntry.findtext('date').strip() sMessage = oLogEntry.findtext('msg', '').strip() if sMessage == '': sMessage = ' ' elif len(sMessage) > VcsRevisionData.kcchMax_sMessage: sMessage = sMessage[:VcsRevisionData.kcchMax_sMessage - 4] + ' ...' if not self.oConfig.fQuiet: utils.printOut(u'sDate=%s iRev=%u sAuthor=%s sMsg[%s]=%s' % (sDate, iRevision, sAuthor, type(sMessage).__name__, sMessage)) oData = VcsRevisionData().initFromValues(self.oConfig.sRepository, iRevision, sDate, sAuthor, sMessage) oLogic.addVcsRevision(oData) oDb.commit() oDb.close() return 0
def main(self): """ Main function. """ oDb = TMDatabaseConnection(); oLogic = VcsRevisionLogic(oDb); # Where to start. iStartRev = 0; if not self.oConfig.fFull: iStartRev = oLogic.getLastRevision(self.oConfig.sRepository); if iStartRev == 0: iStartRev = self.oConfig.iStartRevision; # Construct a command line. os.environ['LC_ALL'] = 'en_US.utf-8'; asArgs = [ 'svn', 'log', '--xml', '--revision', str(iStartRev) + ':HEAD', ]; if self.oConfig.asExtraOptions is not None: asArgs.extend(self.oConfig.asExtraOptions); asArgs.append(self.oConfig.sUrl); if not self.oConfig.fQuiet: print('Executing: %s' % (asArgs,)); sLogXml = utils.processOutputChecked(asArgs); # Parse the XML and add the entries to the database. oParser = ET.XMLParser(target = ET.TreeBuilder(), encoding = 'utf-8'); oParser.feed(sLogXml.encode('utf-8')); # does its own decoding and processOutputChecked always gives us decoded utf-8 now. oRoot = oParser.close(); for oLogEntry in oRoot.findall('logentry'): iRevision = int(oLogEntry.get('revision')); sAuthor = oLogEntry.findtext('author').strip(); sDate = oLogEntry.findtext('date').strip(); sMessage = oLogEntry.findtext('msg', '').strip(); if sMessage == '': sMessage = ' '; elif len(sMessage) > VcsRevisionData.kcchMax_sMessage: sMessage = sMessage[:VcsRevisionData.kcchMax_sMessage - 4] + ' ...'; if not self.oConfig.fQuiet: utils.printOut(u'sDate=%s iRev=%u sAuthor=%s sMsg[%s]=%s' % (sDate, iRevision, sAuthor, type(sMessage).__name__, sMessage)); oData = VcsRevisionData().initFromValues(self.oConfig.sRepository, iRevision, sDate, sAuthor, sMessage); oLogic.addVcsRevision(oData); oDb.commit(); oDb.close(); return 0;
def main(self): """ Main function. """ oDb = TMDatabaseConnection() if self.oConfig.fLoadDumpIntoDatabase is not True: rc = self._doDump(oDb) else: rc = self._doLoad(oDb) oDb.close() return 0
def checkBuilds(self): """ Add build data record into database. """ oDb = TMDatabaseConnection() oBuildLogic = BuildLogic(oDb) tsNow = oDb.getCurrentTimestamp() cMaxRows = 1024 iStart = 0 while True: aoBuilds = oBuildLogic.fetchForListing(iStart, cMaxRows, tsNow) if not self.oConfig.fQuiet and aoBuilds: print('Processing builds #%s thru #%s' % (aoBuilds[0].idBuild, aoBuilds[-1].idBuild)) for oBuild in aoBuilds: if oBuild.fBinariesDeleted is False: rc = oBuild.areFilesStillThere() if rc is False: if not self.oConfig.fQuiet: print( 'missing files for build #%s / r%s / %s / %s / %s / %s / %s' % ( oBuild.idBuild, oBuild.iRevision, oBuild.sVersion, oBuild.oCat.sType, oBuild.oCat.sBranch, oBuild.oCat.sProduct, oBuild.oCat.asOsArches, )) print(' %s' % (oBuild.sBinaries, )) if self.oConfig.fRealRun is True: oBuild.fBinariesDeleted = True oBuildLogic.editEntry(oBuild, fCommit=True) elif rc is True and not self.oConfig.fQuiet: print('build #%s still have its files' % (oBuild.idBuild, )) elif rc is None and not self.oConfig.fQuiet: print('Unable to determine state of build #%s' % (oBuild.idBuild, )) # advance if len(aoBuilds) < cMaxRows: break iStart += len(aoBuilds) oDb.close() return 0
def main(self): """ Main function. """ oDb = TMDatabaseConnection() oLogic = VcsRevisionLogic(oDb) # Where to start. iStartRev = 0 if not self.oConfig.fFull: iStartRev = oLogic.getLastRevision(self.oConfig.sRepository) if iStartRev == 0: iStartRev = self.oConfig.iStartRevision # Construct a command line. os.environ["LC_ALL"] = "en_US.utf-8" asArgs = ["svn", "log", "--xml", "--revision", str(iStartRev) + ":HEAD"] if self.oConfig.asExtraOptions is not None: asArgs.extend(self.oConfig.asExtraOptions) asArgs.append(self.oConfig.sUrl) if not self.oConfig.fQuiet: print "Executing: %s" % (asArgs,) sLogXml = utils.processOutputChecked(asArgs) # Parse the XML and add the entries to the database. oParser = ET.XMLParser(target=ET.TreeBuilder(), encoding="utf-8") oParser.feed(sLogXml) oRoot = oParser.close() for oLogEntry in oRoot.findall("logentry"): iRevision = int(oLogEntry.get("revision")) sAuthor = oLogEntry.findtext("author").strip() sDate = oLogEntry.findtext("date").strip() sMessage = oLogEntry.findtext("msg", "").strip() if sMessage == "": sMessage = " " if not self.oConfig.fQuiet: print "sDate=%s iRev=%u sAuthor=%s sMsg[%s]=%s" % ( sDate, iRevision, sAuthor, type(sMessage).__name__, sMessage, ) oData = VcsRevisionData().initFromValues(self.oConfig.sRepository, iRevision, sDate, sAuthor, sMessage) oLogic.addVcsRevision(oData) oDb.commit() oDb.close() return 0
def main(self): """ Main function. """ oDb = TMDatabaseConnection(); oLogic = VcsRevisionLogic(oDb); # Where to start. iStartRev = 0; if not self.oConfig.fFull: iStartRev = oLogic.getLastRevision(self.oConfig.sRepository); if iStartRev == 0: iStartRev = self.oConfig.iStartRevision; # Construct a command line. os.environ['LC_ALL'] = 'en_US.utf-8'; asArgs = [ 'svn', 'log', '--xml', '--revision', str(iStartRev) + ':HEAD', ]; if self.oConfig.asExtraOptions is not None: asArgs.extend(self.oConfig.asExtraOptions); asArgs.append(self.oConfig.sUrl); if not self.oConfig.fQuiet: print 'Executing: %s' % (asArgs,); sLogXml = utils.processOutputChecked(asArgs); # Parse the XML and add the entries to the database. oParser = ET.XMLParser(target = ET.TreeBuilder(), encoding = 'utf-8'); oParser.feed(sLogXml); oRoot = oParser.close(); for oLogEntry in oRoot.findall('logentry'): iRevision = int(oLogEntry.get('revision')); sAuthor = oLogEntry.findtext('author').strip(); sDate = oLogEntry.findtext('date').strip(); sMessage = oLogEntry.findtext('msg', '').strip(); if sMessage == '': sMessage = ' '; if not self.oConfig.fQuiet: print 'sDate=%s iRev=%u sAuthor=%s sMsg[%s]=%s' % (sDate, iRevision, sAuthor, type(sMessage).__name__, sMessage); oData = VcsRevisionData().initFromValues(self.oConfig.sRepository, iRevision, sDate, sAuthor, sMessage); oLogic.addVcsRevision(oData); oDb.commit(); oDb.close(); return 0;
def checkBuilds(self): """ Add build data record into database. """ oDb = TMDatabaseConnection(); oBuildLogic = BuildLogic(oDb); tsNow = oDb.getCurrentTimestamp(); cMaxRows = 1024; iStart = 0; while True: aoBuilds = oBuildLogic.fetchForListing(iStart, cMaxRows, tsNow); if not self.oConfig.fQuiet and len(aoBuilds) > 0: print 'Processing builds #%s thru #%s' % (aoBuilds[0].idBuild, aoBuilds[-1].idBuild); for oBuild in aoBuilds: if oBuild.fBinariesDeleted is False: rc = oBuild.areFilesStillThere(); if rc is False: if not self.oConfig.fQuiet: print 'missing files for build #%s / r%s / %s / %s / %s / %s / %s' \ % (oBuild.idBuild, oBuild.iRevision, oBuild.sVersion, oBuild.oCat.sType, oBuild.oCat.sBranch, oBuild.oCat.sProduct, oBuild.oCat.asOsArches,); print ' %s' % (oBuild.sBinaries,); if self.oConfig.fRealRun is True: oBuild.fBinariesDeleted = True; oBuildLogic.editEntry(oBuild, fCommit = True); elif rc is True and not self.oConfig.fQuiet: print 'build #%s still have its files' % (oBuild.idBuild,); elif rc is None and not self.oConfig.fQuiet: print 'Unable to determine state of build #%s' % (oBuild.idBuild,); # advance if len(aoBuilds) < cMaxRows: break; iStart += len(aoBuilds); oDb.close(); return 0;
def main(self): """ Main function. """ oDb = TMDatabaseConnection(); oLogic = VcsRevisionLogic(oDb); oBugLogic = VcsBugReferenceLogic(oDb); # Where to start. iStartRev = 0; if not self.oConfig.fFull: if not self.oConfig.fBugRefsOnly: iStartRev = oLogic.getLastRevision(self.oConfig.sRepository); else: iStartRev = oBugLogic.getLastRevision(self.oConfig.sRepository); if iStartRev == 0: iStartRev = self.oConfig.iStartRevision; # Construct a command line. os.environ['LC_ALL'] = 'en_US.utf-8'; asArgs = [ 'svn', 'log', '--xml', '--revision', str(iStartRev) + ':HEAD', ]; if self.oConfig.asExtraOptions is not None: asArgs.extend(self.oConfig.asExtraOptions); asArgs.append(self.oConfig.sUrl); if not self.oConfig.fQuiet: print('Executing: %s' % (asArgs,)); sLogXml = utils.processOutputChecked(asArgs); # Parse the XML and add the entries to the database. oParser = ET.XMLParser(target = ET.TreeBuilder(), encoding = 'utf-8'); oParser.feed(sLogXml.encode('utf-8')); # Does its own decoding; processOutputChecked always gives us decoded utf-8 now. oRoot = oParser.close(); for oLogEntry in oRoot.findall('logentry'): iRevision = int(oLogEntry.get('revision')); sAuthor = oLogEntry.findtext('author', 'unspecified').strip(); # cvs2svn entries doesn't have an author. sDate = oLogEntry.findtext('date').strip(); sRawMsg = oLogEntry.findtext('msg', '').strip(); sMessage = sRawMsg; if sMessage == '': sMessage = ' '; elif len(sMessage) > VcsRevisionData.kcchMax_sMessage: sMessage = sMessage[:VcsRevisionData.kcchMax_sMessage - 4] + ' ...'; if not self.oConfig.fQuiet: utils.printOut(u'sDate=%s iRev=%u sAuthor=%s sMsg[%s]=%s' % (sDate, iRevision, sAuthor, type(sMessage).__name__, sMessage)); if not self.oConfig.fBugRefsOnly: oData = VcsRevisionData().initFromValues(self.oConfig.sRepository, iRevision, sDate, sAuthor, sMessage); oLogic.addVcsRevision(oData); # Analyze the raw message looking for bug tracker references. for oBugTracker in g_kdBugTrackers.values(): for sTag in oBugTracker.asCommitTags: off = sRawMsg.find(sTag); while off >= 0: off += len(sTag); while off < len(sRawMsg) and sRawMsg[off].isspace(): off += 1; if off < len(sRawMsg) and sRawMsg[off].isdigit(): offNum = off; while off < len(sRawMsg) and sRawMsg[off].isdigit(): off += 1; try: iBugNo = long(sRawMsg[offNum:off]); except Exception as oXcpt: utils.printErr(u'error! exception(r%s,"%s"): -> %s' % (iRevision, sRawMsg[offNum:off], oXcpt,)); else: if not self.oConfig.fQuiet: utils.printOut(u' r%u -> sBugTracker=%s iBugNo=%s' % (iRevision, oBugTracker.sDbId, iBugNo,)); oBugData = VcsBugReferenceData().initFromValues(self.oConfig.sRepository, iRevision, oBugTracker.sDbId, iBugNo); oBugLogic.addVcsBugReference(oBugData); # next off = sRawMsg.find(sTag, off); oDb.commit(); oDb.close(); return 0;