def _checkParams(self, params): base.RHProtected._checkParams(self, params) self._statusValue = "OK" self._message = "" try: self._title = params.get( "title", "" ).strip() self._startdate = params.get( "startdate", "" ).strip() self._enddate = params.get( "enddate", "" ).strip() self._place = params.get( "place", "" ).strip() self._room = params.get( "room", "" ).strip() self._accessPassword = params.get( "an", "" ).strip() self._modifyPassword = params.get( "mp", "" ).strip() self._style = params.get( "style", "" ).strip() self._fid = params.get( "fid", "" ).strip() self._description = params.get( "description", "" ).strip() self._stime = params.get( "stime", "" ).strip() self._etime = params.get( "etime", "" ).strip() self._speaker = params.get( "speaker", "" ).strip() self._speakeremail = params.get( "email", "" ).strip() self._speakeraffiliation = params.get( "affiliation", "" ).strip() if not self._title or not self._startdate or not self._enddate or not self._fid or not self._stime or not self._etime: raise MaKaCError( _("mandatory parameter missing")) ch = CategoryManager() try: self._cat = ch.getById(self._fid) except: raise MaKaCError( _("unknown category")) except MaKaCError, e: self._statusValue = "ERROR" self._message = e.getMsg()
def _checkParams(self, params): base.RHProtected._checkParams(self, params) self._statusValue = "OK" self._message = "" try: self._title = params.get("title", "").strip() self._startdate = params.get("startdate", "").strip() self._enddate = params.get("enddate", "").strip() self._place = params.get("place", "").strip() self._room = params.get("room", "").strip() self._accessPassword = params.get("an", "").strip() self._modifyPassword = params.get("mp", "").strip() self._style = params.get("style", "").strip() self._fid = params.get("fid", "").strip() self._description = params.get("description", "").strip() self._stime = params.get("stime", "").strip() self._etime = params.get("etime", "").strip() self._speaker = params.get("speaker", "").strip() self._speakeremail = params.get("email", "").strip() self._speakeraffiliation = params.get("affiliation", "").strip() if not self._title or not self._startdate or not self._enddate or not self._fid or not self._stime or not self._etime: raise MaKaCError(_("mandatory parameter missing")) ch = CategoryManager() try: self._cat = ch.getById(self._fid) except: raise MaKaCError(_("unknown category")) except MaKaCError, e: self._statusValue = "ERROR" self._message = e.getMsg()
def _process( self ): self._responseUtil.content_type = 'text/xml' cm = CategoryManager() try: XG = xmlGen.XMLGen() cat = cm.getById(self._id) self._getHeader(XG) self._getCategXML(cat, XG, self._fp) self._getFooter(XG) return XG.getXml() except: value = "ERROR" message = "Category does not exist" if value != "OK": return self._createResponse(value, message)
def _process(self): self._req.content_type = "text/xml" cm = CategoryManager() try: XG = xmlGen.XMLGen() cat = cm.getById(self._id) self._getHeader(XG) self._getCategXML(cat, XG, self._fp) self._getFooter(XG) return XG.getXml() except: value = "ERROR" message = "Category does not exist" if value != "OK": return self._createResponse(value, message)
def initialize_new_db(root): """ Initializes a new DB in debug mode """ # Reset everything for e in root.keys(): del root[e] # Delete whoosh indexes whoosh_dir = os.path.join(Config.getInstance().getArchiveDir(), 'whoosh') if os.path.exists(whoosh_dir): delete_recursively(whoosh_dir) # initialize db root cm = CategoryManager() cm.getRoot() return cm.getById('0')
def initialize_new_db(root): """ Initializes a new DB in debug mode """ # Reset everything for e in root.keys(): del root[e] # initialize db root cm = CategoryManager() cm.getRoot() home = cm.getById('0') # set debug mode on minfo = HelperMaKaCInfo.getMaKaCInfoInstance() minfo.setDebugActive(True) return home
def updateCategsAndEvents(): DBMgr.getInstance().startRequest() cm = CategoryManager() l = [cat.getId() for cat in cm.getList()] DBMgr.getInstance().endRequest() for id in l: DBMgr.getInstance().startRequest() cat = cm.getById(id) log("\nupdate category %s:%s"%(cat.getId(), cat.getName())) if cat.getId() in catTZMap.keys() and catTZMap[cat.getId()] : tz = catTZMap[cat.getId()] log(" found tz for this category: %s"%tz) else: tz = defTZ log(" use default tz: %s"%tz) cat.setTimezone(tz) updateCatTasks(cat) for conf in cat.getConferenceList(): updateEvent(conf, tz) log(" conf %s: %s updated with tz: %s"%(conf.getId(), conf.getTitle(), tz)) DBMgr.getInstance().endRequest()
## This file is part of Indico. ## Copyright (C) 2002 - 2012 European Organization for Nuclear Research (CERN). ## ## 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 <http://www.gnu.org/licenses/>. from MaKaC.common import DBMgr from MaKaC.conference import CategoryManager DBMgr.getInstance().startRequest() cm=CategoryManager() cat=cm.getById('2l76') conferences= cat.getAllConferenceList() f = open("statusProtection.txt","w") for conference in conferences: f.write(conference.getId() + " " + conference.getTitle() + " " + str(conference.isItselfProtected()) + " " + str(conference.isProtected()) + "\n") f.close() DBMgr.getInstance().endRequest()
def runTests(host='localhost', port=FAKE_SERVICE_PORT, scenarios=[(2, 10)]): execTimes = [] agent = InvenioBatchUploaderAgent('test1', 'test1', 'test', 0, 'http://%s:%s' \ % (host, port)) ph = PluginsHolder() ph.reloadAllPlugins() ph.getPluginType('livesync').toggleActive() do = DummyObservable() do._notify('updateDBStructures', 'indico.ext.livesync', None, None, None) sm = SyncManager.getDBInstance() sm.registerNewAgent(agent) cm = CategoryManager() avatar = user.Avatar() avatar.setName( "fake" ) avatar.setSurName( "fake" ) avatar.setOrganisation( "fake" ) avatar.setLang( "en_GB" ) avatar.setEmail( "*****@*****.**" ) #registering user ah = user.AvatarHolder() ah.add(avatar) #setting up the login info li = user.LoginInfo( "dummyuser", "dummyuser" ) ih = AuthenticatorMgr() userid = ih.createIdentity( li, avatar, "Local" ) ih.add( userid ) #activate the account avatar.activateAccount() #since the DB is empty, we have to add dummy user as admin minfo = HelperMaKaCInfo.getMaKaCInfoInstance() al = minfo.getAdminList() al.grant( avatar ) dummy = avatar ContextManager.destroy() HelperMaKaCInfo.getMaKaCInfoInstance().setDefaultConference(DefaultConference()) cm.getRoot() do._notify('requestStarted') home = cm.getById('0') # execute code for nconf in range(0, 1000): conf = home.newConference(dummy) conf.setTitle('Test Conference %s' % nconf) do._notify('requestFinished') time.sleep(1) # params won't be used task = LiveSyncUpdateTask(dateutil.rrule.MINUTELY) for scen in scenarios: print "Scenario %s workers, size = %s " % scen, # configure scenario InvenioBatchUploaderAgent.NUM_WORKERS = scen[0] InvenioBatchUploaderAgent.BATCH_SIZE = scen[1] ts = time.time() # just run it task.run() te = time.time() execTimes.append(te - ts) print "%s" % (te - ts) sm._track._pointers['test1'] = None for i in range(0, len(execTimes)): results[scenarios[i]] = execTimes[i]
## You should have received a copy of the GNU General Public License ## along with Indico;if not, see <http://www.gnu.org/licenses/>. from indico.core.db import DBMgr from MaKaC.user import Group from MaKaC.conference import CategoryManager DBMgr.getInstance().startRequest() cm=CategoryManager() catcounter = 0 mgrscounter = 0 notSendTo={} catList=[] rootCatList=[] rootCatList.append(cm.getById('1l28')) rootCatList.append(cm.getById('1l30')) for cat in rootCatList: for scat in cat.getSubCategoryList(): catList.append(scat) for cat in catList: ml = cat.getManagerList() if ml: l=[] for mng in ml: if isinstance(mng, Group): if notSendTo.has_key(cat.getId()): notSendTo[cat.getId()].append(mng.getName()) else: notSendTo[cat.getId()]=[]
def runTests(host='localhost', port=FAKE_SERVICE_PORT, scenarios=[(2, 10)]): execTimes = [] agent = InvenioBatchUploaderAgent('test1', 'test1', 'test', 0, 'http://%s:%s' \ % (host, port)) ph = PluginsHolder() ph.reloadAllPlugins() ph.getPluginType('livesync').toggleActive() do = DummyObservable() do._notify('updateDBStructures', 'indico.ext.livesync', None, None, None) sm = SyncManager.getDBInstance() sm.registerNewAgent(agent) cm = CategoryManager() avatar = user.Avatar() avatar.setName( "fake" ) avatar.setSurName( "fake" ) avatar.setOrganisation( "fake" ) avatar.setLang( "en_GB" ) avatar.setEmail( "*****@*****.**" ) #registering user ah = user.AvatarHolder() ah.add(avatar) #setting up the login info li = user.LoginInfo("dummyuser", None) am = AuthenticatorMgr() userid = am.createIdentity( li, avatar, "Local" ) am.add( userid ) #activate the account avatar.activateAccount() #since the DB is empty, we have to add dummy user as admin minfo = HelperMaKaCInfo.getMaKaCInfoInstance() al = minfo.getAdminList() al.grant( avatar ) dummy = avatar ContextManager.destroy() HelperMaKaCInfo.getMaKaCInfoInstance().setDefaultConference(DefaultConference()) cm.getRoot() do._notify('requestStarted') home = cm.getById('0') # execute code for nconf in range(0, 1000): conf = home.newConference(dummy) conf.setTitle('Test Conference %s' % nconf) do._notify('requestFinished') time.sleep(1) # params won't be used task = LiveSyncUpdateTask(dateutil.rrule.MINUTELY) for scen in scenarios: print "Scenario %s workers, size = %s " % scen, # configure scenario InvenioBatchUploaderAgent.NUM_WORKERS = scen[0] InvenioBatchUploaderAgent.BATCH_SIZE = scen[1] ts = time.time() # just run it task.run() te = time.time() execTimes.append(te - ts) print "%s" % (te - ts) sm._track._pointers['test1'] = None for i in range(0, len(execTimes)): results[scenarios[i]] = execTimes[i]
## You should have received a copy of the GNU General Public License ## along with Indico;if not, see <http://www.gnu.org/licenses/>. from MaKaC.common import DBMgr from MaKaC.user import Group from MaKaC.conference import CategoryManager DBMgr.getInstance().startRequest() cm = CategoryManager() catcounter = 0 mgrscounter = 0 notSendTo = {} catList = [] rootCatList = [] rootCatList.append(cm.getById("1l28")) rootCatList.append(cm.getById("1l30")) for cat in rootCatList: for scat in cat.getSubCategoryList(): catList.append(scat) for cat in catList: ml = cat.getManagerList() if ml: l = [] for mng in ml: if isinstance(mng, Group): if notSendTo.has_key(cat.getId()): notSendTo[cat.getId()].append(mng.getName()) else: notSendTo[cat.getId()] = []
from MaKaC.conference import CategoryManager from MaKaC.webinterface.urlHandlers import UHCategoryDisplay, UHConferenceDisplay def checkGroup (obj, group): ac = obj.getAccessController() if group in ac.allowed: return True return False def showSubCategory(cat, group): if checkGroup(cat, group): print "%s - %s"%(cat.getName(), UHCategoryDisplay.getURL(cat)) if cat.hasSubcategories(): for subcat in cat.getSubCategoryList(): showSubCategory(subcat,group) else: for conference in cat.getConferenceList(): if checkGroup(conference, group): print "%s - %s"%(conference.getName(), UHConferenceDisplay.getURL(conference)) DBMgr.getInstance().startRequest() cm=CategoryManager() cat=cm.getById("XXXX") group = GroupHolder().getById("YYYYY") showSubCategory(cat, group) DBMgr.getInstance().endRequest()
## You should have received a copy of the GNU General Public License ## along with Indico;if not, see <http://www.gnu.org/licenses/>. from indico.core.db import DBMgr from MaKaC.user import Group from MaKaC.conference import CategoryManager DBMgr.getInstance().startRequest() cm = CategoryManager() catcounter = 0 mgrscounter = 0 notSendTo = {} catList = [] rootCatList = [] rootCatList.append(cm.getById('1l28')) rootCatList.append(cm.getById('1l30')) for cat in rootCatList: for scat in cat.getSubCategoryList(): catList.append(scat) for cat in catList: ml = cat.getManagerList() if ml: l = [] for mng in ml: if isinstance(mng, Group): if notSendTo.has_key(cat.getId()): notSendTo[cat.getId()].append(mng.getName()) else: notSendTo[cat.getId()] = []
## Copyright (C) 2002 - 2013 European Organization for Nuclear Research (CERN). ## ## 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 <http://www.gnu.org/licenses/>. from MaKaC.common import DBMgr from MaKaC.conference import CategoryManager DBMgr.getInstance().startRequest() cm = CategoryManager() cat = cm.getById('2l76') conferences = cat.getAllConferenceList() f = open("statusProtection.txt", "w") for conference in conferences: f.write(conference.getId() + " " + conference.getTitle() + " " + str(conference.isItselfProtected()) + " " + str(conference.isProtected()) + "\n") f.close() DBMgr.getInstance().endRequest()