Example #1
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
Example #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
Example #3
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
Example #4
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()
Example #5
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()