本文整理汇总了Python中MaKaC.rb_location.CrossLocationQueries类的典型用法代码示例。如果您正苦于以下问题:Python CrossLocationQueries类的具体用法?Python CrossLocationQueries怎么用?Python CrossLocationQueries使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CrossLocationQueries类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rebuildRoomReservationsIndex
def rebuildRoomReservationsIndex():
from MaKaC.common.db import DBMgr
from MaKaC.rb_location import CrossLocationDB
from MaKaC.rb_room import RoomBase
from MaKaC.plugins.RoomBooking.default.dalManager import DALManager
from BTrees.OOBTree import OOBTree
DBMgr.getInstance().startRequest()
CrossLocationDB.connect()
root = DALManager.root
resvEx = ReservationBase()
resvEx.isConfirmed = None
allResvs = CrossLocationQueries.getReservations( resvExample = resvEx )
print "There are " + str( len( allResvs ) ) + " resvs and pre-resvs to index..."
c = 0
root[_ROOM_RESERVATIONS_INDEX] = OOBTree()
print "Room => Reservations Index branch created"
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()
示例2: _getAnswer
def _getAnswer( self ):
result = {}
locationNames = map(lambda l: l.friendlyName, Location.allLocations);
for loc in locationNames:
for room in CrossLocationQueries.getRooms( location = loc ):
result[loc +":" +room.name] = loc +":" +room.name;
return sorted(result)
示例3: _getParams
def _getParams(self):
super(BookRoomHook, self)._getParams()
username = get_query_parameter(self._queryParams, ['username'])
booked_for = AuthenticatorMgr().getAvatarByLogin(username).values()
if not booked_for:
raise HTTPAPIError('Username does not exist.')
self._params = {
'roomid': get_query_parameter(self._queryParams, ['roomid']),
'location': get_query_parameter(self._queryParams, ['location']),
'username': username,
'reason': get_query_parameter(self._queryParams, ['reason']),
'userBookedFor': booked_for[0],
'from': self._fromDT,
'to': self._toDT
}
# calculate missing arguments
missing = list(name for (name, value) in (self._params.iteritems()) if not value)
if missing:
raise HTTPAPIError('Argument(s) missing: {0}'.format(', '.join(missing)), apache.HTTP_BAD_REQUEST)
self._room = CrossLocationQueries.getRooms(location=self._params['location'], roomID=int(self._params['roomid']))
示例4: _getAnswer
def _getAnswer(self):
p = ReservationBase()
p.startDT = self._startDT
p.endDT = self._endDT
p.repeatability = self._repeatability
rooms = CrossLocationQueries.getRooms(location=self._location, resvExample=p, available=True)
return [room.id for room in rooms]
示例5: _getAnswer
def _getAnswer(self):
res = {}
minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
if minfo.getRoomBookingModuleActive():
if Location.parse(self._location):
for room in CrossLocationQueries.getRooms(location=self._location):
res[room.name] = room.name
return sorted(res)
示例6: getMapURL
def getMapURL(self, roomName):
if re.match("[0-9]+-([0-9]+|R)-[0-9]+", roomName):
return "%s%s"%(self.getBaseMapURL(), roomName[:roomName.find('-')])
else:
minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
if minfo.getRoomBookingModuleActive():
rooms = CrossLocationQueries.getRooms(roomName = roomName)
rooms = [r for r in rooms if r is not None]
if rooms and rooms[0]:
return "%s%s"%(self.getBaseMapURL(), str(rooms[0].building))
return ""
示例7: changeCreator
def changeCreator(oldUser, newUser):
dbi = DBMgr.getInstance()
dbi.startRequest()
Factory.getDALManager().connect()
# check if the users exist
if AvatarHolder().getById(oldUser) is None:
print "There is no user with id %s"%oldUser
return
if AvatarHolder().getById(newUser) is None:
print "There is no user with id %s"%newUser
return
resvEx = ReservationBase()
resvEx.createdBy = oldUser
allResv4OldUser = CrossLocationQueries.getReservations( resvExample = resvEx)
if allResv4OldUser == []:
print "No reservations for user %s"%oldUser
return
# resvs = ReservationBase.getReservations()
# allResv4OldUser = [x for x in allResv if x.createdBy == oldUser]
if type(allResv4OldUser) is not list:
allResv4OldUser = [allResv4OldUser]
# Modify reservations
for r in allResv4OldUser:
r.createdBy = newUser
#print r.createdBy, r.id
# Update index
userReservationsIndexBTree = Reservation.getUserReservationsIndexRoot()
newUserResvs = userReservationsIndexBTree.get( newUser )
if newUserResvs == None:
newUserResvs = [] # New list of reservations for this room
userReservationsIndexBTree.insert( newUser, newUserResvs )
newUserResvs.extend( allResv4OldUser )
userReservationsIndexBTree[newUser] = newUserResvs[:]
if userReservationsIndexBTree.has_key(oldUser):
userReservationsIndexBTree.pop(oldUser)
userReservationsIndexBTree._p_changed = 1
# close DB connection
Factory.getDALManager().commit()
Factory.getDALManager().disconnect()
dbi.endRequest()
print "%s reservations have moved from creator %s to creator %s" % (len(allResv4OldUser), oldUser, newUser)
示例8: search
def search(self, location, name):
Factory.getDALManager().connect()
rooms = CrossLocationQueries.getRooms(location=location)
def _search_rooms(name):
return (room for room in rooms if name in room.getFullName())
for obj in self._process(_search_rooms(name)):
yield obj
Factory.getDALManager().rollback()
Factory.getDALManager().disconnect()
示例9: getMapURL
def getMapURL(self, roomName):
groupdict = self.applyRegularExpressions(roomName)
if groupdict:
return self.getBaseMapURL().format(**groupdict)
minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
if minfo.getRoomBookingModuleActive():
rooms = CrossLocationQueries.getRooms(roomName = roomName)
rooms = [r for r in rooms if r is not None]
if rooms and rooms[0]:
if all(field in self.getBaseMapURL() for field in ['{building}','{floor}','{roomNr}']):
return self.getBaseMapURL().format(**{'building': str(rooms[0].building),'floor': rooms[0].floor,'roomNr': rooms[0].roomNr})
return ""
示例10: room
def room(self, location, idlist):
Factory.getDALManager().connect()
rooms = CrossLocationQueries.getRooms(location=location)
def _iterate_rooms(objIds):
objIds = map(int, objIds)
return (room for room in rooms if room.id in objIds)
for obj in self._process(_iterate_rooms(idlist)):
yield obj
Factory.getDALManager().rollback()
Factory.getDALManager().disconnect()
示例11: listResv4User
def listResv4User(user):
dbi = DBMgr.getInstance()
dbi.startRequest()
Factory.getDALManager().connect()
resvEx = ReservationBase()
resvEx.createdBy = user
allResv = CrossLocationQueries.getReservations( resvExample = resvEx)
print "User %s has %s resevations created by him/her"%(user, len(allResv))
Factory.getDALManager().disconnect()
dbi.endRequest()
示例12: getVars
def getVars(self):
vars = WJSBase.getVars( self )
roomsWithH323IP = []
if self._conf:
vars["ConferenceId"] = self._conf.getId()
# Code to get a list of H.323 Videoconference-able rooms
# by querying Indico's RB database
location = self._conf.getLocation()
if location and location.getName():
locationName = location.getName()
# TODO: get list of room from a plugin option instead of querying the RB DB everytime
try:
minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
if minfo.getRoomBookingModuleActive():
Logger.get("CERNMCU").info("Connecting with Room Booking DB to get the list of all rooms with a H323 IP")
CrossLocationDB.connect()
Logger.get("CERNMCU").info("Connection successful")
attName = getCERNMCUOptionValueByName("H323_IP_att_name")
try:
returnedRooms = CrossLocationQueries.getRooms( location = locationName,
customAtts = [{"name":attName, "allowEmpty":False,
"filter": (lambda ip: validIP(ip))}] )
if not isinstance(returnedRooms, list):
if returnedRooms:
returnedRooms = [returnedRooms]
else:
returnedRooms = []
for room in returnedRooms:
roomsWithH323IP.append(RoomWithH323(locationName, room.getFullName(), room.customAtts[attName]))
except AttributeError:
#CrossLocationQueries.getRooms fails because it does not handle location names that are not in the DB
pass
except Exception, e:
Logger.get("CERNMCU").warning("Location: " + locationName + "Problem with CrossLocationQueries when retrieving the list of all rooms with a H323 IP: " + str(e))
except MaKaCError, e:
Logger.get("CERNMCU").warning("Location: " + locationName + "MaKaCError when retrieving the list of all rooms with a H323 IP: " + e.getMsg())
except Exception, e:
Logger.get("CERNMCU").warning("Location: " + locationName + "Exception when retrieving the list of all rooms with a H323 IP: " + str(e))
示例13: getLinkRoomIp
def getLinkRoomIp(cls, linkVideo, ipAttName="H323 IP"):
if linkVideo is None:
return ""
location = linkVideo.getLocation()
room = linkVideo.getRoom()
roomIp = ""
if location and room and location.getName() and room.getName() and location.getName().strip() and room.getName().strip():
minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
if minfo.getRoomBookingModuleActive():
CrossLocationDB.connect()
try:
roomInfo = CrossLocationQueries.getRooms( location = location.getName(), roomName = room.getName())
roomIp = roomInfo.customAtts[ipAttName]
except Exception, e:
Logger.get("Vidyo").warning("Location: '%s' - Problem with CrossLocationQueries: '%s'" % (location.getName(), str(e)))
示例14: getLinkRoomIp
def getLinkRoomIp(cls, linkVideo):
if linkVideo is None:
return ""
location = linkVideo.getLocation()
room = linkVideo.getRoom()
roomIp = ""
if location and room and location.getName() and room.getName() and location.getName().strip() and room.getName().strip():
minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
if minfo.getRoomBookingModuleActive():
CrossLocationDB.connect()
try:
roomInfo = CrossLocationQueries.getRooms( location = location.getName(), roomName = room.getName())
roomIp = roomInfo.customAtts["H323 IP"]
except Exception, e:
Logger.get("Vidyo").warning("Location: " + location.getName() + "Problem with CrossLocationQueries when retrieving the list of all rooms with a H323 IP: " + str(e))
示例15: getRoomsByExampleDemo
def getRoomsByExampleDemo():
Test.dalManager.connect()
roomEx = Factory.newRoom()
roomEx.building = 513
roomEx.capacity = 20
rooms = CrossLocationQueries.getRooms( roomExample = roomEx )
for room in rooms:
print "============================="
print room
Test.dalManager.disconnect()