コード例 #1
0
    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;
コード例 #2
0
    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 len(aoErrors) == 0:
                    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 len(asMessages) > 0 and not self.oConfig.fQuiet:
                    print '  %d messages:' % (len(asMessages),);
                    for sMsg in asMessages:
                        print '  ##%s' % (sMsg,);
        return iRc;
コード例 #3
0
ファイル: wuiadmin.py プロジェクト: susanych1234/virtualbox
    def _actionRegenQueuesCommon(self):
        """
        Common code for ksActionTestBoxesRegenQueues and ksActionTestCfgRegenQueues.

        Too lazy to put this in some separate place right now.
        """
        self._checkForUnknownParameters()
        ## @todo should also be changed to a POST with a confirmation dialog preceeding it.

        self._sPageTitle = 'Regenerate All Scheduling Queues'
        self._sPageBody = ''
        aoGroups = SchedGroupLogic(self._oDb).getAll()
        for oGroup in aoGroups:
            self._sPageBody += '<h3>%s (ID %#d)</h3>' % (webutils.escapeElem(
                oGroup.sName), oGroup.idSchedGroup)
            try:
                (aoErrors, asMessages) = SchedulerBase.recreateQueue(
                    self._oDb, self._oCurUser.uid, oGroup.idSchedGroup, 2)
            except Exception as oXcpt:
                self._oDb.rollback()
                self._sPageBody += '<p>SchedulerBase.recreateQueue threw an exception: %s</p>' \
                                % (webutils.escapeElem(str(oXcpt)),)
                self._sPageBody += cgitb.html(sys.exc_info())
            else:
                if len(aoErrors) == 0:
                    self._sPageBody += '<p>Successfully regenerated.</p>'
                else:
                    for oError in aoErrors:
                        if oError[1] is None:
                            self._sPageBody += '<p>%s.</p>' % (
                                webutils.escapeElem(oError[0]), )
                        ## @todo links.
                        #elif isinstance(oError[1], TestGroupData):
                        #    self._sPageBody += '<p>%s.</p>' % (webutils.escapeElem(oError[0]),);
                        #elif isinstance(oError[1], TestGroupCase):
                        #    self._sPageBody += '<p>%s.</p>' % (webutils.escapeElem(oError[0]),);
                        else:
                            self._sPageBody += '<p>%s. [Cannot link to %s]</p>' \
                                             % (webutils.escapeElem(oError[0]), webutils.escapeElem(str(oError[1])))
                for sMsg in asMessages:
                    self._sPageBody += '<p>%s<p>\n' % (
                        webutils.escapeElem(sMsg), )
        return True
コード例 #4
0
    def _actionRegenQueuesCommon(self):
        """
        Common code for ksActionTestBoxesRegenQueues and ksActionTestCfgRegenQueues.

        Too lazy to put this in some separate place right now.
        """
        self._checkForUnknownParameters();
        ## @todo should also be changed to a POST with a confirmation dialog preceeding it.

        self._sPageTitle = 'Regenerate All Scheduling Queues';
        self._sPageBody  = '';
        aoGroups = SchedGroupLogic(self._oDb).getAll();
        for oGroup in aoGroups:
            self._sPageBody += '<h3>%s (ID %#d)</h3>' % (webutils.escapeElem(oGroup.sName), oGroup.idSchedGroup);
            try:
                (aoErrors, asMessages) = SchedulerBase.recreateQueue(self._oDb, self._oCurUser.uid, oGroup.idSchedGroup, 2);
            except Exception as oXcpt:
                self._oDb.rollback();
                self._sPageBody += '<p>SchedulerBase.recreateQueue threw an exception: %s</p>' \
                                % (webutils.escapeElem(str(oXcpt)),);
                self._sPageBody += cgitb.html(sys.exc_info());
            else:
                if len(aoErrors) == 0:
                    self._sPageBody += '<p>Successfully regenerated.</p>';
                else:
                    for oError in aoErrors:
                        if oError[1] is None:
                            self._sPageBody += '<p>%s.</p>' % (webutils.escapeElem(oError[0]),);
                        ## @todo links.
                        #elif isinstance(oError[1], TestGroupData):
                        #    self._sPageBody += '<p>%s.</p>' % (webutils.escapeElem(oError[0]),);
                        #elif isinstance(oError[1], TestGroupCase):
                        #    self._sPageBody += '<p>%s.</p>' % (webutils.escapeElem(oError[0]),);
                        else:
                            self._sPageBody += '<p>%s. [Cannot link to %s]</p>' \
                                             % (webutils.escapeElem(oError[0]), webutils.escapeElem(str(oError[1])));
                for sMsg in asMessages:
                    self._sPageBody += '<p>%s<p>\n' % (webutils.escapeElem(sMsg),);
        return True;