当前位置: 首页>>代码示例>>Python>>正文


Python Factory.newRoom方法代码示例

本文整理汇总了Python中MaKaC.rb_factory.Factory.newRoom方法的典型用法代码示例。如果您正苦于以下问题:Python Factory.newRoom方法的具体用法?Python Factory.newRoom怎么用?Python Factory.newRoom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MaKaC.rb_factory.Factory的用法示例。


在下文中一共展示了Factory.newRoom方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _getAnswer

# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import newRoom [as 别名]
 def _getAnswer( self ):
     minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
     result = {}
     if minfo.getRoomBookingModuleActive():
         locationNames = map(lambda l: l.friendlyName, Location.allLocations)
         for loc in locationNames:
             roomEx = Factory.newRoom()
             roomEx.isActive = self._isActive
             for room in CrossLocationQueries.getRooms( location = loc, roomExample=roomEx ):
                 result[str(room.guid)] = "%s: %s" % (loc, room.getFullName())
     return result
开发者ID:aninhalacerda,项目名称:indico,代码行数:13,代码来源:roomBooking.py

示例2: getAverageOccupation

# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import newRoom [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)
开发者ID:vstitches,项目名称:indico,代码行数:49,代码来源:rb_room.py

示例3: getReservations

# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import newRoom [as 别名]
    def getReservations():
        from MaKaC.rb_room import RoomBase
        
        Test.dalManager.connect()

        roomEx = Factory.newRoom()
        roomEx.name = 'TH AMPHITHEATRE'
        
        resvEx = Factory.newReservation()
        resvEx.startDT = datetime( 2006, 12, 01, 10 )
        resvEx.endDT = datetime( 2006, 12, 14, 15 )
        #resvEx.bookedForName = 'Jean-Jacques Blais'
        resvs = ReservationBase.getReservations( resvExample = resvEx, rooms = [roomEx] )

        for resv in resvs:
            print "============================="
            print resv
        
        Test.dalManager.disconnect()
开发者ID:davidmorrison,项目名称:indico,代码行数:21,代码来源:reservation.py

示例4: getAverageOccupation

# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import newRoom [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()
        resvEx.endDT = datetime.combine(date.today(), time(17, 30))
        resvEx.startDT = resvEx.endDT.replace(hour=8) - timedelta(days=30)
        resvEx.repeatability = RepeatabilityEnum.daily
        collisions = resvEx.getCollisions(rooms=rooms)

        totalWorkingDays = sum(1 for day in iterdays(resvEx.startDT, resvEx.endDT) if day.weekday() not in (5, 6))
        booked = timedelta()
        for c in collisions:
            if c.startDT.weekday() in (5, 6):  # skip Saturday and Sunday
                continue
            booked += c.endDT - c.startDT
        totalBookableTime = totalWorkingDays * 9 * len(rooms)  # Hours
        bookedTime = (booked.days * 86400 + booked.seconds) / 3600.0
        if totalBookableTime > 0:
            return bookedTime / totalBookableTime
        else:
            return 0
开发者ID:arescope,项目名称:indico,代码行数:41,代码来源:rb_room.py

示例5: getRooms

# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import newRoom [as 别名]
    def getRooms( *args, **kwargs ):
        """
        Returns list of rooms meeting specified conditions.

        It is 'query by example'. You specify conditions by creating
        the object and passing it to the method.

        All arguments are optional:

        roomID - just a shortcut. Will return ONE room (not a list) or None.
        roomName - just a shortcut. Will return ONE room (not a list) or None.
        roomExample - example RoomBase object.
        reservationExample - example ReservationBase object. Represents reservation period.
        available - Bool, true if room must be available, false if must be booked, None if do not care
        freeText - str, room will be found if this string will be found anywhere in the object
            i.e. in equipment list, comments, responsible etc.
        minCapacity - Bool, defaults to False. If True, then rooms of capacity >= will be found.
            Otherwise capacity it looks for rooms with capacity within 20% range.
        allFast - Bool, defaults to False. If True, ALL active rooms will be returned
            in ultra fast way, REGARDLESS of all other options.
        ownedBy - Avatar
        customAtts - for rooms with custom attributes.
                     rooms with no .customAtts attributes will be filtered out if this parameter is present
                     The customAtts attribute should be a list of dictionaries with the attributes "name", "allowEmpty", "filter".
                     "name" -> the name of the custom attribute
                     "allowEmpty" -> if we allow the custom attribute to be empty or not (empty = "" or string with only whitespaces)
                     "filter" -> a function to which we will pass the value of the custom attribute and has to return True or False.
                     If there is more than 1 dictionary in the list, it will be like doing an AND of the conditions they represent.
                     (see example 6)

        Examples:

        # 1. Get all rooms
        rooms = RoomBase.getRooms()

        # 2. Get all rooms with capacity about 30
        r = Factory.newRoom()
        r.capacity = 30
        rooms = RoomBase.getRooms( roomExample = r )

        # 3. Get all rooms reserved on the New Year 2007,
        # which have capacity about 30, are at Meyrin site and have 'jean' in comments.

        r = Factory.newRoom()
        r.capacity = 30
        r.site = 'Meyrin'
        r.comments = 'jean'
        p = ReservationBase()
        p.startDT = datetime.datetime( 2007, 01, 01 )
        p.endDT = datetime.datetime( 2007, 01, 01 )
        p.repeatability = None

        rooms = RoomBase.getRooms( roomExample = r, reservationExample = p, available = False )

        # 4. Get all rooms containing "sex" in their attributes

        rooms = RoomBase.getRooms( freeText = 'sex' )

        # 5. Get room 'AT AMPHITHEATRE'

        oneRoom = RoomBase.getRooms( roomName = 'AT AMPHITHEATRE' )

        #6. Get rooms with a H.323 IP defined
        rooms = RoomBase.getRooms ( customAtts = [{"name":'H323 IP', "allowEmpty":False,
                                                   "filter": (lambda ip: validIP(ip))}])
        """
        # Simply redirect to the plugin
        from MaKaC.rb_factory import Factory
        return Factory.newRoom().getRooms( **kwargs )
开发者ID:vstitches,项目名称:indico,代码行数:71,代码来源:rb_room.py

示例6: specified

# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import newRoom [as 别名]

    roomIDs = params.get("r").strip().split(",")
    if roomIDs == "":
        return """At least one roomID must be specified (http://....?r=1,42,14,...)"""
    try:
        roomIDs = map(lambda x: int(x), roomIDs)
    except ValueError:
        return """Room IDs must be integers separated by commas (http://....?r=1,42,14,...)"""
    if len(roomIDs) > 10:
        return "One can only export 10 rooms at most"

    #################### process ###################
    rooms = []
    for roomID in roomIDs:
        roomEx = Factory.newRoom()
        roomEx.id = roomID
        rooms.append(roomEx)

    resvEx = Factory.newReservation()
    resvEx.isCancelled = False
    resvEx.isRejected = False
    resvEx.startDT = datetime(sd.year, sd.month, sd.day, 0, 0)
    resvEx.endDT = datetime(ed.year, ed.month, ed.day, 23, 59)
    resvs = CrossLocationQueries.getReservations(location="CERN", resvExample=resvEx, rooms=rooms)
    collisions = []
    for resv in resvs:
        for p in resv.splitToPeriods(endDT=resvEx.endDT, startDT=resvEx.startDT):
            collisions.append(Collision( ( p.startDT, p.endDT ), resv ))

    of = params.get("of", "csv")
开发者ID:arturodr,项目名称:indico,代码行数:32,代码来源:exportReservations.py


注:本文中的MaKaC.rb_factory.Factory.newRoom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。