def __init__(self, oOptions): """ Parse command line """ self.fVerbose = oOptions.fVerbose self.sSrcDir = config.g_ksFileAreaRootDir self.sDstDir = config.g_ksZipFileAreaRootDir #self.oTestSetLogic = TestSetLogic(TMDatabaseConnection(self.dprint if self.fVerbose else None)); self.oTestSetLogic = TestSetLogic(TMDatabaseConnection(None)) self.fDryRun = oOptions.fDryRun
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.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 _formatListEntry(self, iEntry): from testmanager.webui.wuiadmin import WuiAdmin oEntry = self._aoEntries[iEntry] sShortFailReason = FailureReasonLogic(TMDatabaseConnection()).getById( oEntry.idFailureReason).sShort aoActions = [ WuiTmLink( 'Details', WuiAdmin.ksScriptName, { WuiAdmin.ksParamAction: WuiAdmin.ksActionBuildBlacklistDetails, BuildBlacklistData.ksParam_idBlacklisting: oEntry.idBlacklisting }), ] if self._oDisp is None or not self._oDisp.isReadOnlyUser(): aoActions += [ WuiTmLink( 'Edit', WuiAdmin.ksScriptName, { WuiAdmin.ksParamAction: WuiAdmin.ksActionBuildBlacklistEdit, BuildBlacklistData.ksParam_idBlacklisting: oEntry.idBlacklisting }), WuiTmLink( 'Clone', WuiAdmin.ksScriptName, { WuiAdmin.ksParamAction: WuiAdmin.ksActionBuildBlacklistClone, BuildBlacklistData.ksParam_idBlacklisting: oEntry.idBlacklisting, WuiAdmin.ksParamEffectiveDate: oEntry.tsEffective, }), WuiTmLink( 'Remove', WuiAdmin.ksScriptName, { WuiAdmin.ksParamAction: WuiAdmin.ksActionBuildBlacklistDoRemove, BuildBlacklistData.ksParam_idBlacklisting: oEntry.idBlacklisting }, sConfirm= 'Are you sure you want to remove black list entry #%d?' % (oEntry.idBlacklisting, )), ] return [ oEntry.idBlacklisting, sShortFailReason, oEntry.sProduct, oEntry.sBranch, oEntry.asTypes, oEntry.asOsArches, oEntry.iFirstRevision, oEntry.iLastRevision, aoActions ]
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 _populateForm(self, oForm, oData): oForm.addIntRO(TestBoxData.ksParam_idTestBox, oData.idTestBox, 'TestBox ID') oForm.addIntRO(TestBoxData.ksParam_idGenTestBox, oData.idGenTestBox, 'TestBox generation ID') oForm.addTimestampRO(TestBoxData.ksParam_tsEffective, oData.tsEffective, 'Last changed') oForm.addTimestampRO(TestBoxData.ksParam_tsExpire, oData.tsExpire, 'Expires (excl)') oForm.addIntRO(TestBoxData.ksParam_uidAuthor, oData.uidAuthor, 'Changed by UID') oForm.addText(TestBoxData.ksParam_ip, oData.ip, 'TestBox IP Address') ## make read only?? oForm.addUuid(TestBoxData.ksParam_uuidSystem, oData.uuidSystem, 'TestBox System/Firmware UUID') oForm.addText(TestBoxData.ksParam_sName, oData.sName, 'TestBox Name') oForm.addText(TestBoxData.ksParam_sDescription, oData.sDescription, 'TestBox Description') oForm.addCheckBox(TestBoxData.ksParam_fEnabled, oData.fEnabled, 'Enabled') oForm.addComboBox(TestBoxData.ksParam_enmLomKind, oData.enmLomKind, 'Lights-out-management', TestBoxData.kaoLomKindDescs) oForm.addText(TestBoxData.ksParam_ipLom, oData.ipLom, 'Lights-out-management IP Address') oForm.addInt(TestBoxData.ksParam_pctScaleTimeout, oData.pctScaleTimeout, 'Timeout scale factor (%)') oForm.addListOfSchedGroupsForTestBox( TestBoxDataEx.ksParam_aoInSchedGroups, oData.aoInSchedGroups, SchedGroupLogic(TMDatabaseConnection()).fetchOrderedByName(), 'Scheduling Group') # Command, comment and submit button. if self._sMode == WuiFormContentBase.ksMode_Edit: oForm.addComboBox(TestBoxData.ksParam_enmPendingCmd, oData.enmPendingCmd, 'Pending command', TestBoxData.kaoTestBoxCmdDescs) else: oForm.addComboBoxRO(TestBoxData.ksParam_enmPendingCmd, oData.enmPendingCmd, 'Pending command', TestBoxData.kaoTestBoxCmdDescs) oForm.addMultilineText(TestBoxData.ksParam_sComment, oData.sComment, 'Comment') if self._sMode != WuiFormContentBase.ksMode_Show: oForm.addSubmit( 'Create TestBox' if self._sMode == WuiFormContentBase.ksMode_Add else 'Change TestBox') return True
def __init__(self, oSrvGlue, sScriptName): self._oSrvGlue = oSrvGlue self._oDb = TMDatabaseConnection( self.dprint if config.g_kfWebUiSqlDebug else None, oSrvGlue=oSrvGlue) self._tsNow = None # Set by getEffectiveDateParam. self._asCheckedParams = [] self._dParams = None # Set by dispatchRequest. self._sAction = None # Set by dispatchRequest. self._dDispatch = { self.ksActionDefault: self._actionDefault, } # Template bits. self._sTemplate = 'template-default.html' self._sPageTitle = '$$TODO$$' # The page title. self._aaoMenus = [] # List of [sName, sLink, [ [sSideName, sLink], .. ] tuples. self._sPageBody = '$$TODO$$' # The body text. self._sRedirectTo = None self._sDebug = '' # Debugger bits. self._fDbgSqlTrace = False self._fDbgSqlExplain = False self._dDbgParams = dict() for sKey, sValue in oSrvGlue.getParameters().iteritems(): if sKey in self.kasDbgParams: self._dDbgParams[sKey] = sValue if len(self._dDbgParams) > 0: from testmanager.webui.wuicontentbase import WuiTmLink WuiTmLink.kdDbgParams = self._dDbgParams # Determine currently logged in user credentials self._oCurUser = UserAccountLogic( self._oDb).tryFetchAccountByLoginName(oSrvGlue.getLoginName()) # Calc a couple of URL base strings for this dispatcher. self._sUrlBase = sScriptName + '?' if len(self._dDbgParams) > 0: self._sUrlBase += webutils.encodeUrlParams(self._dDbgParams) + '&' self._sActionUrlBase = self._sUrlBase + self.ksParamAction + '='
def _connectToDbAndValidateTb(self, asValidStates = None): """ Connects to the database and validates the testbox. Returns (TMDatabaseConnection, TestBoxStatusData, TestBoxData) on success. Returns (None, None, None) on failure after sending the box an appropriate response. May raise exception on DB error. """ oDb = TMDatabaseConnection(self._oSrvGlue.dprint); oLogic = TestBoxStatusLogic(oDb); (oStatusData, oTestBoxData) = oLogic.tryFetchStatusAndConfig(self._idTestBox, self._sTestBoxUuid, self._sTestBoxAddr); if oStatusData is None: self._resultResponse(constants.tbresp.STATUS_DEAD); elif asValidStates is not None and oStatusData.enmState not in asValidStates: self._resultResponse(constants.tbresp.STATUS_NACK); elif self._idTestSet is not None and self._idTestSet != oStatusData.idTestSet: self._resultResponse(constants.tbresp.STATUS_NACK); else: return (oDb, oStatusData, oTestBoxData); return (None, None, None);
def _populateForm(self, oForm, oData): """ Construct an HTML form """ aoFailureCategories = FailureCategoryLogic( TMDatabaseConnection()).getFailureCategoriesForCombo() if not aoFailureCategories: from testmanager.webui.wuiadmin import WuiAdmin sExceptionMsg = 'Please <a href="%s?%s=%s">add</a> Failure Category first.' % \ (WuiAdmin.ksScriptName, WuiAdmin.ksParamAction, WuiAdmin.ksActionFailureCategoryAdd) raise WuiException(sExceptionMsg) oForm.addIntRO(FailureReasonData.ksParam_idFailureReason, oData.idFailureReason, 'Failure Reason ID') oForm.addTimestampRO(FailureReasonData.ksParam_tsEffective, oData.tsEffective, 'Last changed') oForm.addTimestampRO(FailureReasonData.ksParam_tsExpire, oData.tsExpire, 'Expires (excl)') oForm.addIntRO(FailureReasonData.ksParam_uidAuthor, oData.uidAuthor, 'Changed by UID') oForm.addComboBox(FailureReasonData.ksParam_idFailureCategory, oData.idFailureCategory, 'Failure Category', aoFailureCategories) oForm.addText(FailureReasonData.ksParam_sShort, oData.sShort, 'Short Description') oForm.addText(FailureReasonData.ksParam_sFull, oData.sFull, 'Full Description') oForm.addInt(FailureReasonData.ksParam_iTicket, oData.iTicket, 'Ticket Number') oForm.addMultilineText( FailureReasonData.ksParam_asUrls, oData.asUrls, 'Other URLs to reports ' 'or discussions of the ' 'observed symptoms') oForm.addSubmit() return True
def doIt(self): """ Does the job. """ oDb = TMDatabaseConnection() aoGroups = SchedGroupLogic(oDb).getAll() iRc = 0 for oGroup in aoGroups: if not self.oConfig.fQuiet: print('%s (ID %#d):' % ( oGroup.sName, oGroup.idSchedGroup, )) try: (aoErrors, asMessages) = SchedulerBase.recreateQueue( oDb, self.oConfig.uid, oGroup.idSchedGroup, 2) except Exception as oXcpt: oDb.rollback() print(' !!Hit exception processing "%s": %s' % ( oGroup.sName, oXcpt, )) else: if not aoErrors: if not self.oConfig.fQuiet: print(' Successfully regenerated.') else: iRc = 1 print(' %d errors:' % (len(aoErrors, ))) for oError in aoErrors: if oError[1] is None: print(' !!%s' % (oError[0], )) else: print(' !!%s (%s)' % (oError[0], oError[1])) if asMessages and not self.oConfig.fQuiet: print(' %d messages:' % (len(asMessages), )) for sMsg in asMessages: print(' ##%s' % (sMsg, )) return iRc
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 __init__(self, oSrvGlue): self._oSrvGlue = oSrvGlue self._oDb = TMDatabaseConnection(oSrvGlue.dprint) self._iFirstHandlerPath = 0 self._iNextHandlerPath = 0 self._sPath = None # _getStandardParams / dispatchRequest sets this later on. self._asPath = None # _getStandardParams / dispatchRequest sets this later on. self._sMethod = None # _getStandardParams / dispatchRequest sets this later on. self._dParams = None # _getStandardParams / dispatchRequest sets this later on. self._asCheckedParams = [] self._dGetTree = { 'vcs': { 'changelog': self._handleVcsChangelog_Get, 'bugreferences': self._handleVcsBugReferences_Get, }, } self._dMethodTrees = { 'GET': self._dGetTree, }
def _actionSignOn(self): # pylint: disable=R0914 """ Implement sign-on """ # # Validate parameters (raises exception on failure). # sOs = self._getStringParam(constants.tbreq.SIGNON_PARAM_OS, coreconsts.g_kasOses) sOsVersion = self._getStringParam( constants.tbreq.SIGNON_PARAM_OS_VERSION) sCpuVendor = self._getStringParam( constants.tbreq.SIGNON_PARAM_CPU_VENDOR) sCpuArch = self._getStringParam(constants.tbreq.SIGNON_PARAM_CPU_ARCH, coreconsts.g_kasCpuArches) sCpuName = self._getStringParam(constants.tbreq.SIGNON_PARAM_CPU_NAME, fStrip=True, sDefValue='') # new lCpuRevision = self._getLongParam( constants.tbreq.SIGNON_PARAM_CPU_REVISION, lMin=0, lDefValue=0) # new cCpus = self._getIntParam(constants.tbreq.SIGNON_PARAM_CPU_COUNT, 1, 16384) fCpuHwVirt = self._getBoolParam( constants.tbreq.SIGNON_PARAM_HAS_HW_VIRT) fCpuNestedPaging = self._getBoolParam( constants.tbreq.SIGNON_PARAM_HAS_NESTED_PAGING) fCpu64BitGuest = self._getBoolParam( constants.tbreq.SIGNON_PARAM_HAS_64_BIT_GUEST, fDefValue=True) fChipsetIoMmu = self._getBoolParam( constants.tbreq.SIGNON_PARAM_HAS_IOMMU) fRawMode = self._getBoolParam( constants.tbreq.SIGNON_PARAM_WITH_RAW_MODE, fDefValue=None) cMbMemory = self._getLongParam(constants.tbreq.SIGNON_PARAM_MEM_SIZE, 8, 1073741823) # 8MB..1PB cMbScratch = self._getLongParam( constants.tbreq.SIGNON_PARAM_SCRATCH_SIZE, 0, 1073741823) # 0..1PB sReport = self._getStringParam(constants.tbreq.SIGNON_PARAM_REPORT, fStrip=True, sDefValue='') # new iTestBoxScriptRev = self._getIntParam( constants.tbreq.SIGNON_PARAM_SCRIPT_REV, 1, 100000000) iPythonHexVersion = self._getIntParam( constants.tbreq.SIGNON_PARAM_PYTHON_VERSION, 0x020300f0, 0x030f00f0) self._checkForUnknownParameters() # Null conversions for new parameters. if not sReport: sReport = None if not sCpuName: sCpuName = None if lCpuRevision <= 0: lCpuRevision = None # # Connect to the database and validate the testbox. # oDb = TMDatabaseConnection(self._oSrvGlue.dprint) oTestBoxLogic = TestBoxLogic(oDb) oTestBox = oTestBoxLogic.tryFetchTestBoxByUuid(self._sTestBoxUuid) if oTestBox is None: oSystemLogLogic = SystemLogLogic(oDb) oSystemLogLogic.addEntry(SystemLogData.ksEvent_TestBoxUnknown, 'addr=%s uuid=%s os=%s %d cpus' \ % (self._sTestBoxAddr, self._sTestBoxUuid, sOs, cCpus), 24, fCommit = True) return self._resultResponse(constants.tbresp.STATUS_NACK) # # Update the row in TestBoxes if something changed. # if oTestBox.cMbScratch is not None and oTestBox.cMbScratch != 0: cPctScratchDiff = (cMbScratch - oTestBox.cMbScratch) * 100 / oTestBox.cMbScratch else: cPctScratchDiff = 100 # pylint: disable=R0916 if self._sTestBoxAddr != oTestBox.ip \ or sOs != oTestBox.sOs \ or sOsVersion != oTestBox.sOsVersion \ or sCpuVendor != oTestBox.sCpuVendor \ or sCpuArch != oTestBox.sCpuArch \ or sCpuName != oTestBox.sCpuName \ or lCpuRevision != oTestBox.lCpuRevision \ or cCpus != oTestBox.cCpus \ or fCpuHwVirt != oTestBox.fCpuHwVirt \ or fCpuNestedPaging != oTestBox.fCpuNestedPaging \ or fCpu64BitGuest != oTestBox.fCpu64BitGuest \ or fChipsetIoMmu != oTestBox.fChipsetIoMmu \ or fRawMode != oTestBox.fRawMode \ or cMbMemory != oTestBox.cMbMemory \ or abs(cPctScratchDiff) >= min(4 + cMbScratch / 10240, 12) \ or sReport != oTestBox.sReport \ or iTestBoxScriptRev != oTestBox.iTestBoxScriptRev \ or iPythonHexVersion != oTestBox.iPythonHexVersion: oTestBoxLogic.updateOnSignOn(oTestBox.idTestBox, oTestBox.idGenTestBox, sTestBoxAddr=self._sTestBoxAddr, sOs=sOs, sOsVersion=sOsVersion, sCpuVendor=sCpuVendor, sCpuArch=sCpuArch, sCpuName=sCpuName, lCpuRevision=lCpuRevision, cCpus=cCpus, fCpuHwVirt=fCpuHwVirt, fCpuNestedPaging=fCpuNestedPaging, fCpu64BitGuest=fCpu64BitGuest, fChipsetIoMmu=fChipsetIoMmu, fRawMode=fRawMode, cMbMemory=cMbMemory, cMbScratch=cMbScratch, sReport=sReport, iTestBoxScriptRev=iTestBoxScriptRev, iPythonHexVersion=iPythonHexVersion) # # Update the testbox status, making sure there is a status. # oStatusLogic = TestBoxStatusLogic(oDb) oStatusData = oStatusLogic.tryFetchStatus(oTestBox.idTestBox) if oStatusData is not None: self._cleanupOldTest(oDb, oStatusData) else: oStatusLogic.insertIdleStatus(oTestBox.idTestBox, oTestBox.idGenTestBox, fCommit=True) # # ACK the request. # dResponse = \ { constants.tbresp.ALL_PARAM_RESULT: constants.tbresp.STATUS_ACK, constants.tbresp.SIGNON_PARAM_ID: oTestBox.idTestBox, constants.tbresp.SIGNON_PARAM_NAME: oTestBox.sName, } return self._writeResponse(dResponse)
def _populateForm(self, oForm, oData): oForm.addIntRO(TestBoxData.ksParam_idTestBox, oData.idTestBox, 'TestBox ID') oForm.addIntRO(TestBoxData.ksParam_idGenTestBox, oData.idGenTestBox, 'TestBox generation ID') oForm.addTimestampRO(TestBoxData.ksParam_tsEffective, oData.tsEffective, 'Last changed') oForm.addTimestampRO(TestBoxData.ksParam_tsExpire, oData.tsExpire, 'Expires (excl)') oForm.addIntRO(TestBoxData.ksParam_uidAuthor, oData.uidAuthor, 'Changed by UID') oForm.addText(TestBoxData.ksParam_ip, oData.ip, 'TestBox IP Address') oForm.addUuid(TestBoxData.ksParam_uuidSystem, oData.uuidSystem, 'TestBox System/Firmware UUID') oForm.addText(TestBoxData.ksParam_sName, oData.sName, 'TestBox Name') oForm.addText(TestBoxData.ksParam_sDescription, oData.sDescription, 'TestBox Description') oForm.addComboBox( TestBoxData.ksParam_idSchedGroup, oData.idSchedGroup, 'Scheduling Group', SchedGroupLogic(TMDatabaseConnection()).getSchedGroupsForCombo()) oForm.addCheckBox(TestBoxData.ksParam_fEnabled, oData.fEnabled, 'Enabled') oForm.addComboBox(TestBoxData.ksParam_enmLomKind, oData.enmLomKind, 'Lights-out-management', TestBoxData.kaoLomKindDescs) oForm.addText(TestBoxData.ksParam_ipLom, oData.ipLom, 'Lights-out-management IP Address') oForm.addInt(TestBoxData.ksParam_pctScaleTimeout, oData.pctScaleTimeout, 'Timeout scale factor (%)') ## @todo Pretty format the read-only fields and use hidden fields for # passing the actual values. (Yes, we need the values so we can # display the form correctly on input error.) oForm.addTextRO(TestBoxData.ksParam_sOs, oData.sOs, 'TestBox OS') oForm.addTextRO(TestBoxData.ksParam_sOsVersion, oData.sOsVersion, 'TestBox OS version') oForm.addTextRO(TestBoxData.ksParam_sCpuArch, oData.sCpuArch, 'TestBox OS kernel architecture') oForm.addTextRO(TestBoxData.ksParam_sCpuVendor, oData.sCpuVendor, 'TestBox CPU vendor') oForm.addTextRO(TestBoxData.ksParam_sCpuName, oData.sCpuName, 'TestBox CPU name') if oData.lCpuRevision: oForm.addTextRO(TestBoxData.ksParam_lCpuRevision, '%#x' % (oData.lCpuRevision, ), 'TestBox CPU revision', sPostHtml=' (family=%#x model=%#x stepping=%#x)' % ( oData.getCpuFamily(), oData.getCpuModel(), oData.getCpuStepping(), ), sSubClass='long') else: oForm.addLongRO(TestBoxData.ksParam_lCpuRevision, oData.lCpuRevision, 'TestBox CPU revision') oForm.addIntRO(TestBoxData.ksParam_cCpus, oData.cCpus, 'Number of CPUs, cores and threads') oForm.addCheckBoxRO(TestBoxData.ksParam_fCpuHwVirt, oData.fCpuHwVirt, 'VT-x or AMD-V supported') oForm.addCheckBoxRO(TestBoxData.ksParam_fCpuNestedPaging, oData.fCpuNestedPaging, 'Nested paging supported') oForm.addCheckBoxRO(TestBoxData.ksParam_fCpu64BitGuest, oData.fCpu64BitGuest, '64-bit guest supported') oForm.addCheckBoxRO(TestBoxData.ksParam_fChipsetIoMmu, oData.fChipsetIoMmu, 'I/O MMU supported') oForm.addMultilineTextRO(TestBoxData.ksParam_sReport, oData.sReport, 'Hardware/software report') oForm.addLongRO(TestBoxData.ksParam_cMbMemory, oData.cMbMemory, 'Installed RAM size (MB)') oForm.addLongRO(TestBoxData.ksParam_cMbScratch, oData.cMbScratch, 'Available scratch space (MB)') oForm.addIntRO(TestBoxData.ksParam_iTestBoxScriptRev, oData.iTestBoxScriptRev, 'TestBox Script SVN revision') # Later: #if not self.isAttributeNull(''): # sHexVer = '%s.%s.%.%s' % (oData.iPythonHexVersion >> 24, (oData.iPythonHexVersion >> 16) & 0xff, # (oData.iPythonHexVersion >> 8) & 0xff, oData.iPythonHexVersion & 0xff); #else: # sHexVer = str(oData.iPythonHexVersion); oForm.addIntRO(TestBoxData.ksParam_iPythonHexVersion, oData.iPythonHexVersion, 'Python version (hex)') if self._sMode == WuiFormContentBase.ksMode_Edit: oForm.addComboBox(TestBoxData.ksParam_enmPendingCmd, oData.enmPendingCmd, 'Pending command', TestBoxData.kaoTestBoxCmdDescs) else: oForm.addComboBoxRO(TestBoxData.ksParam_enmPendingCmd, oData.enmPendingCmd, 'Pending command', TestBoxData.kaoTestBoxCmdDescs) if self._sMode != WuiFormContentBase.ksMode_Show: oForm.addSubmit( 'Create TestBox' if self._sMode == WuiFormContentBase.ksMode_Add else 'Change TestBox') return True
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;