本文整理汇总了Python中MaKaC.rb_location.CrossLocationQueries.getRooms方法的典型用法代码示例。如果您正苦于以下问题:Python CrossLocationQueries.getRooms方法的具体用法?Python CrossLocationQueries.getRooms怎么用?Python CrossLocationQueries.getRooms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MaKaC.rb_location.CrossLocationQueries
的用法示例。
在下文中一共展示了CrossLocationQueries.getRooms方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _getAnswer
# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getRooms [as 别名]
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)
示例2: _getParams
# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getRooms [as 别名]
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']))
示例3: _getAnswer
# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getRooms [as 别名]
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]
示例4: _getAnswer
# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getRooms [as 别名]
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)
示例5: getMapURL
# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getRooms [as 别名]
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 ""
示例6: search
# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getRooms [as 别名]
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()
示例7: getMapURL
# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getRooms [as 别名]
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 ""
示例8: room
# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getRooms [as 别名]
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()
示例9: getVars
# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getRooms [as 别名]
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))
示例10: getLinkRoomIp
# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getRooms [as 别名]
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))
示例11: getLinkRoomIp
# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getRooms [as 别名]
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)))
示例12: getRoomsByExampleDemo
# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getRooms [as 别名]
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()
示例13: getAverageOccupation
# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getRooms [as 别名]
def getAverageOccupation( **kwargs ):
"""
FINAL (not intented to be overriden)
Returns float <0, 1> representing how often - on the avarage -
the rooms are booked during the working hours. (1 == all the time, 0 == never).
"""
name = kwargs.get( 'location', Location.getDefaultLocation().friendlyName )
# Get active, publically reservable rooms
from MaKaC.rb_factory import Factory
roomEx = Factory.newRoom()
roomEx.isActive = True
roomEx.isReservable = True
rooms = CrossLocationQueries.getRooms( roomExample = roomEx, location = name )
# Find collisions with last month period
from MaKaC.rb_reservation import ReservationBase, RepeatabilityEnum
resvEx = ReservationBase()
now = datetime.now()
resvEx.endDT = datetime( now.year, now.month, now.day, 17, 30 )
resvEx.startDT = resvEx.endDT - timedelta( 30, 9 * 3600 ) # - 30 days and 9 hours
resvEx.repeatability = RepeatabilityEnum.daily
collisions = resvEx.getCollisions( rooms = rooms )
totalWorkingDays = 0
weekends = 0
for day in iterdays( resvEx.startDT, resvEx.endDT ):
if day.weekday() in [5,6]: # Skip Saturday and Sunday
weekends += 1
continue
# if c.startDT is CERN Holiday: continue
totalWorkingDays += 1
booked = timedelta( 0 )
for c in collisions:
if c.startDT.weekday() in [5,6]: # Skip Saturday and Sunday
continue
# if c.startDT is CERN Holiday: continue
booked = booked + ( c.endDT - c.startDT )
totalBookableTime = totalWorkingDays * 9 * len( rooms ) # Hours
bookedTime = booked.days * 24 + 1.0 * booked.seconds / 3600 # Hours
if totalBookableTime > 0:
return bookedTime / totalBookableTime
else:
return 0 # Error (no rooms in db)
示例14: play
# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getRooms [as 别名]
def play():
from MaKaC.rb_location import CrossLocationDB
from MaKaC.rb_room import RoomBase
from MaKaC.common.db import DBMgr
DBMgr.getInstance().startRequest()
CrossLocationDB.connect()
roomEx = RoomBase()
roomEx.isActive = False
rooms = CrossLocationQueries.getRooms( roomExample = roomEx )
for r in rooms:
print r
CrossLocationDB.commit()
CrossLocationDB.disconnect()
DBMgr.getInstance().endRequest()
示例15: pluginOptionsRoomGUIDs
# 需要导入模块: from MaKaC.rb_location import CrossLocationQueries [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationQueries import getRooms [as 别名]
def pluginOptionsRoomGUIDs(dbi, withRBDB, prevVersion):
"""
Modifying Room GUIDs
"""
if not withRBDB:
return
ph = PluginsHolder()
for pluginName, roomsOpt in [('WebcastRequest', 'webcastCapableRooms'),
('RecordingRequest', 'recordingCapableRooms')]:
opt = ph.getPluginType('Collaboration').getPlugin(pluginName).getOption(roomsOpt)
newValue = []
for name in opt.getValue():
loc, name = name.split(':')
room = CrossLocationQueries.getRooms(location=loc, roomName=name)
if room:
newValue.append(str(room.guid))
opt.setValue(newValue)