示例#1
0
 def add_member(self, e):
     """Add a new member to the conference"""
     self.last_event = e
     self.conf_size = int(getUnquotedHeader(e, 'Conference-Size')) # Adjust the conference size
     confObj = Session.query(Conference).get(getUnquotedHeader(self.last_event, 'Conference-Unique-ID'))
     if confObj is None:
         try:
             owner = Session.query(ModeratorPin).get(self.conf_name)
         except Exception, err:
             self.log.exception("Could not obtain owner.")
             Session.remove()
             return
         if owner is None:
             self.log.warning('Error because we could not get owner.')
             Session.remove()
             return
         self.log.debug('Conference does not exist, we must create one.')
         self.log.info('Creating a new conference for conference id: %s' % self.conf_uuid)
         confObj = Conference(self.conf_uuid, parseEventDate(e), unicode(self.conf_name), unicode(self.conf_profile))
         owner.conferences.append(confObj)
         Session.add(confObj)
         Session.commit()
         Session.remove()
         self.addAction(e)
         self.log.debug('Conference %s has been created. Assigning the pointer.' % self.conf_name)
         return
示例#2
0
 def del_member(self, e):
     """Remove members from the conference"""
     self.last_event = e
     self.conf_size = int(getUnquotedHeader(e, 'Conference-Size')) # Adjust the conference size
     self.addAction(e)
     confObj = Session.query(Conference).get(getUnquotedHeader(e, 'Conference-Unique-ID'))
     if confObj is None:
         self.log.debug('Conference does not exist on DB, we must create one.')
         owner = Session.query(ModeratorPin).get(getUnquotedHeader(e, 'Conference-Name'))
         if owner is None:
             self.log.warning('Error because we could not get owner.')
             Session.remove()
             return
         
         self.log.info('Creating a new conference for conference id: %s' % getUnquotedHeader(last_event, 'Conference-Unique-ID'))
         confObj = Conference(getUnquotedHeader(last_event, 'Conference-Unique-ID'), parseEventDate(last_event), unicode(getUnquotedHeader(last_event, 'Conference-Name')), unicode(getUnquotedHeader(last_event, 'Conference-Profile-Name')))
         owner.conferences.append(confObj)
         Session.add(confObj)
         Session.flush()
     if self.conf_size == 0:
         confObj.ended = parseEventDate(e)
         try:
             self.log.debug("Conference %s has ended. Removing session %s." % (self.conf_name, Session))
             Session.commit()
         except Exception, e:
             Session.rollback()
             Session.remove()
             self.log.exception('Could not commit to the DB.')
             return
示例#3
0
 def __init__(self, last_event, config):
     self.log = logging.getLogger('Conference')
     self.last_event = last_event
     self.config = config
     self.conf_size = getUnquotedHeader(self.last_event, 'Conference-Size')
     self.conf_name = getUnquotedHeader(self.last_event, 'Conference-Name')
     self.conf_profile = getUnquotedHeader(self.last_event, 'Conference-Profile-Name')
     self.conf_uuid = getUnquotedHeader(self.last_event, 'Conference-Unique-ID')
                 
     self.confObj = Session.query(Conference).get(getUnquotedHeader(self.last_event, 'Conference-Unique-ID'))
     if self.confObj is None:
         self.log.debug('Conference does not exist on DB, we must create one.')
         owner = Session.query(ModeratorPin).get(getUnquotedHeader(last_event, 'Conference-Name'))
         if owner is None:
             self.log.warning('Error because we could not get owner.')
             Session.remove()
             return
         
         self.log.info('Creating a new conference for conference id: %s' % getUnquotedHeader(last_event, 'Conference-Unique-ID'))
         confObj = Conference(getUnquotedHeader(last_event, 'Conference-Unique-ID'), parseEventDate(last_event), unicode(getUnquotedHeader(last_event, 'Conference-Name')), unicode(getUnquotedHeader(last_event, 'Conference-Profile-Name')))
         owner.conferences.append(confObj)
         Session.add(confObj)
         Session.flush()
     
     Session.remove()    
示例#4
0
 def stop_recording(e, config):
     """Process the process of recording being stopped"""
     log = logging.getLogger('Conference')
     
     owner = Session.query(ModeratorPin).get(getUnquotedHeader(e, 'Conference-Name'))
     if owner is None:
         log.warning('Error because we could not get owner.')
         Session.remove()
         return
     
     confObj = Session.query(Conference).get(getUnquotedHeader(e, 'Conference-Unique-ID'))
     if confObj is None:
         log.info('Creating a new conference for conference id: %s' % getUnquotedHeader(e, 'Conference-Unique-ID'))
         confObj = Conference(getUnquotedHeader(e, 'Conference-Unique-ID'), parseEventDate(e), unicode(getUnquotedHeader(e, 'Conference-Name')), unicode(getUnquotedHeader(e, 'Conference-Profile-Name')))
         owner.conferences.append(confObj)
         Session.add(confObj)
         Session.flush()
         actionObj = ConferenceAction(unicode(getUnquotedHeader(e, 'Action')), 
                                     unicode(getUnquotedHeader(e, 'Caller-Caller-ID-Name')),
                                     unicode(getUnquotedHeader(e, 'Caller-Caller-ID-Number')),
                                     unicode(getUnquotedHeader(e, 'Conference-Size')),
                                     unicode(getUnquotedHeader(e, 'Member-Type')),
                                     parseEventDate(e),
                                     confObj.id)
         confObj.actions.append(actionObj)
         Session.add(actionObj)
         log.debug('Conference %s has been created. Assigning the pointer.' % getUnquotedHeader(e, 'Conference-Name'))
         
     confObj.recording = os.path.join(config.get('mp3', 'store_to'), getUnquotedHeader(e, 'Path').split('/').pop()[:-3] + 'mp3')
     host = unicode(getUnquotedHeader(e, 'FreeSWITCH-IPv4'))
         
     try:
         try:
             t = Thread(target=postRecordingThread, args=(config, getUnquotedHeader(e, 'Path'), confObj, host, owner))
             t.start()
         except:
             log.exception('Could not run thread and commit to database!')
             Session.remove()
             return
     finally:
         try:
             sendEmail(config, getUnquotedHeader(e, 'Path'), confObj, owner)
             Session.commit()
             Session.remove()
         except Exception, e:
             log.exception('Could not commit to database!')
             Session.rollback()
             Session.remove()
             return
示例#5
0
    def new_pin(self):
        """Request a new PIN"""
        if len(request.params.get('participant_pin', '')) < 7 or len(request.params.get('moderator_pin', '')) < 7:
            h.flash("Your PINs need to be 7 numbers.")
            redirect(url('/main/new_pin/new_pin_form'))
        
        if Session.query(ModeratorPin).filter(ModeratorPin.username == session.get('username')).count() >= 5:
            redirect(url('/main/conferences/index'))

        mPin = ModeratorPin(session.get('username'), session.get('domain'))
        mPin.pin = request.params.get('moderator_pin')
        try:
            Session.query(ModeratorPin).filter(or_(ModeratorPin.pin == mPin.pin, ParticipantPin.pin == mPin.pin)).one()
            h.flash('Moderator PIN was taken.')
            redirect(url('/main/new_pin/new_pin_form'))
        except NoResultFound, e:
            Session.add(mPin)
示例#6
0
 def addAction(self, e):
     """Create and add a new action to the DB"""
     self.log.debug('Action taken on %s. %s' % (self.conf_name, getUnquotedHeader(e, 'Action')))
     confObj = Session.query(Conference).get(getUnquotedHeader(self.last_event, 'Conference-Unique-ID'))
     if confObj is None:
         self.log.warning("Conference does not exist, so we can't add this action to the DB.")
         return
         
     actionObj = ConferenceAction(getUnquotedHeader(e, 'Action'), 
                                 getUnquotedHeader(e, 'Caller-Caller-ID-Name'),
                                 getUnquotedHeader(e, 'Caller-Caller-ID-Number'),
                                 self.conf_size,
                                 getUnquotedHeader(e, 'Member-Type'),
                                 parseEventDate(e),
                                 self.conf_uuid)
     confObj.actions.append(actionObj)
     Session.add(actionObj)
     Session.commit()
     Session.remove()
示例#7
0
            Session.query(ModeratorPin).filter(or_(ModeratorPin.pin == mPin.pin, ParticipantPin.pin == mPin.pin)).one()
            h.flash('Moderator PIN was taken.')
            redirect(url('/main/new_pin/new_pin_form'))
        except NoResultFound, e:
            Session.add(mPin)


        pPin = ParticipantPin(session.get('username'))
        pPin.pin = request.params.get('participant_pin')
        try:
            Session.query(ModeratorPin).filter(or_(ModeratorPin.pin == pPin.pin, ParticipantPin.pin == pPin.pin)).one()
            h.flash('Participant PIN was taken.')
            redirect(url('/main/new_pin/new_pin_form'))
        except NoResultFound, e:
            mPin.participant_pin = pPin
            Session.add(pPin)
            Session.commit()
        
        redirect(url('/main/new_pin/index'))
        
    def generatePin(self):
        """Generate a new available PIN"""
        while True:
            mPin = ModeratorPin(session.get('username'), session.get('domain'))
            try:
                Session.query(ModeratorPin, ParticipantPin).filter(or_(ModeratorPin.pin == mPin.pin, ParticipantPin.pin == mPin.pin)).one()
            except NoResultFound, e:
                break
            except Exception, e:
                log.critical('We generated more then one PIN? %s' % e)