How to use the indico.core.db.DBMgr.getInstance function in indico

To help you get started, weโ€™ve selected a few indico examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github indico / indico / bin / migration / TZMigration.py View on Github external
except Exception,e:
                    log("%s"%e)
                    log("calindex: exception indexing [%s] sd:%s, ed:%s"%(conf.getId(),conf.getStartDate(), conf.getEndDate()))
            try:
                DBMgr.getInstance().commit()
                committed = True
            except:
                DBMgr.getInstance().abort()
                log("retry %s" % cat.getId())
        curnum += 1
        per = int(float(curnum)/float(totnum)*100)
        if per != curper:
            curper = per
            if per in [0,10,20,30,40,50,60,70,80,90,100]:
                log("done %s%%" % per)
    DBMgr.getInstance().endRequest()
github indico / indico / indico / modules / scheduler / daemon_script.py View on Github external
if not args.quiet:
            print >>sys.stderr, 'Database status: running={1}, host={0[hostname]}, pid={0[pid]}'.format(
                status, db_running)
            print >>sys.stderr, 'Process status:  running={0}'.format(os_running)

        if db_running and os_running:
            print status['pid']
            sys.exit(0)
        elif not db_running and not os_running:
            sys.exit(1)
        elif db_running and not os_running:
            if not args.quiet:
                print >>sys.stderr, 'Marking dead scheduler as not running'
            SchedulerModule.getDBInstance().setSchedulerRunningStatus(False)
            DBMgr.getInstance().commit()
            sys.exit(1)
        else:
            print >>sys.stderr, 'Unexpected state! Process is running, but scheduler is not marked as running'
            sys.exit(2)
github indico / indico / indico / MaKaC / plugins / RoomBooking / default / reservation.py View on Github external
for resv in allResvs:
            roomReservationsIndexBTree = root[_ROOM_RESERVATIONS_INDEX]
            resvs = roomReservationsIndexBTree.get( resv.room.id )
            if resvs == None:
                resvs = [] # New list of reservations for this room
                roomReservationsIndexBTree.insert( resv.room.id, resvs )
            resvs.append( resv )
            roomReservationsIndexBTree[resv.room.id] = resvs
            c += 1
            if c % 100 == 0:
                print c

        CrossLocationDB.commit()
        CrossLocationDB.disconnect()
        DBMgr.getInstance().endRequest()
github indico / indico / indico / MaKaC / webinterface / rh / CFADisplay.py View on Github external
if errors:
            p = abstracts.WPAbstractSubmission( self, self._target )
            pars = self._abstractData.toDict()
            pars["action"] = self._action
            pars["attachments"] = []

            for error in errors:
                flash(error, 'error')
            return p.display( **pars )
        #Then, we create the abstract object and set its data to the one
        #   received
        cfaMgr = self._target.getAbstractMgr()
        abstract = cfaMgr.newAbstract( self._getUser() )
        self._abstractData.setAbstractData(abstract)
        #The commit must be forced before sending the confirmation
        DBMgr.getInstance().commit()
        #Email confirmation about the submission
        mail.Mailer.send( _AbstractSubmissionNotification( abstract ), self._conf.getSupportInfo().getEmail(returnNoReply=True) )
        #Email confirmation about the submission to coordinators
        if cfaMgr.getSubmissionNotification().hasDestination():
            asn=_AbstractSubmissionNotification( abstract )
            asn.setSubject(_("[Indico] New abstract submission: %s")%asn.getDestination().getFullName())
            mail.GenericMailer.send( asn )
        #We must perform some actions: email warning to the authors
        #Finally, we display a confirmation form
        self._redirect( urlHandlers.UHAbstractSubmissionConfirmation.getURL( abstract ) )
github indico / indico / bin / maintenance / indexes / reindexusers.py View on Github external
except:
      pass
    try:
      del DBMgr.getInstance().getDBConnection().root()['indexes']['name']
    except:
      pass
    try:
      del DBMgr.getInstance().getDBConnection().root()['indexes']['surName']
    except:
      pass
    try:
      del DBMgr.getInstance().getDBConnection().root()['indexes']['organisation']
    except:
      pass
    try:
      del DBMgr.getInstance().getDBConnection().root()['indexes']['status']
    except:
      pass
    ah = user.AvatarHolder()
    ih = indexes.IndexesHolder()
    emailindex = ih.getById( 'email' )
    nameindex = ih.getById( 'name' )
    surNameindex = ih.getById( 'surName' )
    orgindex = ih.getById( 'organisation' )
    statindex = ih.getById( 'status' )
    users = ah.getList()
    for us in users:
    	emailindex.indexUser(us)
    	nameindex.indexUser(us)
    	surNameindex.indexUser(us)
    	orgindex.indexUser(us)
    	statindex.indexUser(us)
github indico / indico / bin / migration / Migration0.8.14To0.90.0.py View on Github external
##
## Indico is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 3 of the
## License, or (at your option) any later version.
##
## Indico is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Indico;if not, see .

from indico.core.db import DBMgr
DBMgr.getInstance().startRequest()

from MaKaC.user import AvatarHolder

ah = AvatarHolder()
#migrate dict to list
for av in ah.getValuesToList():
    if not isinstance(av.identities, list):
        av.identities = av.identities.values()

from MaKaC.authentication.NiceAuthentication import NiceAuthenticator, NiceIdentity
na = NiceAuthenticator()
from MaKaC.authentication.LocalAuthentication import LocalAuthenticator
la = LocalAuthenticator()


#sync authenticators identities to avatars identity list
github indico / indico / bin / migration / check_conflict_description_content.py View on Github external
for cont in conf.getContributionList():
                        #if not isinstance(cont, AcceptedContribution):
                            if "content" in cont.getFields().keys():
                                if cont.getFields()["content"]:
                                    if cont.getFields()["content"] != cont.description:
                                        log("  contribution %s : content field no empty and diffrent from description"%cont.getId())
                                else:
                                    #cont.setField("content",cont.description)
                                    cont.getFields()["content"] = cont.description
                                    cont._p_changed = 1
                            else:
                                #cont.setField("content",cont.description)
                                cont.getFields()["content"] = cont.description
                                cont._p_changed = 1
                    i += 1
                DBMgr.getInstance().endRequest()
                print "wait 0.5s..."
                sleep(0.5)
                break
            except Exception, e:
                cErrorList.append(conf)
                i-=N_CONF
                log("error %s, retry %d time(s)"%(e,int(10-j)))
                sleep(int(j))
                DBMgr.getInstance().abort()
    logFile.append("ERROR Confs: %s"%", ".join(cErrorList))
    f = file(LOG_FILENAME, "w")
    f.write("\n".join(logFile))
    f.close()
if __name__ == "__main__":
github indico / indico / indico / MaKaC / plugins / RoomBooking / default / dalManager.py View on Github external
def connect(self):
        if not self.isConnected():
            if DALManager.usesMainIndicoDB():
                self.connection = DBMgr.getInstance().getDBConnection()
            else:
                self.connection = self.db.open()
            self.root = self.connection.root()
github indico / indico / bin / recovery / restore_meeting.py View on Github external
# Remove meeting from the TrashCanManager
                t.remove(conf)
                # Attach meeting to desired category
                cat = CategoryManager().getById(category)
                ConferenceHolder().add(conf)
                cat._addConference(conf)

                # Add Evaluation
                c = ConferenceHolder().getById(meeting)
                from MaKaC.evaluation import Evaluation
                c.setEvaluations([Evaluation(c)])
        else:
            print "not found!"

        DBMgr.getInstance().endRequest()

    ContextManager.destroy()
github indico / indico / indico / MaKaC / rb_location.py View on Github external
def disconnectFromIndicoDB():
    from MaKaC.plugins.RoomBooking.CERN.dalManagerCERN import DALManagerCERN
    from indico.core.db import DBMgr
    DALManagerCERN.disconnect()
    DBMgr.getInstance().endRequest()