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
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
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
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()
def toggle(self, id): """Toggle secure or record for a conference""" f = request.params.get('f') self.is_my_pin(id) pin = Session.query(ModeratorPin).get(id) if pin: if f == 'record': if pin.record: pin.record = False else: pin.record = True if f == 'secure': if pin.secure: pin.secure = False else: pin.secure = True if f == 'userRecord': if pin.userRecord: pin.userRecord = False else: pin.userRecord = True if f == 'mute_on_entry': if pin.mute_entry: pin.mute_entry = False else: pin.mute_entry = True if f == 'beeps': if pin.beeps: pin.beeps = False else: pin.beeps = True if app_globals.confMonitor.conferences.has_key(pin.pin): app_globals.confMonitor.conferences[pin.pin].toggleSilence() Session.commit() redirect(request.headers.get('REFERER', url(controller='main/conferences', action='index')))
def toggle(self, id): """Toggle secure or record for a conference""" f = request.params.get('f') self.is_my_pin(id) pin = Session.query(ModeratorPin).get(id) if pin: if f == 'record': if pin.record: pin.record = False else: pin.record = True if f == 'secure': if pin.secure: pin.secure = False else: pin.secure = True Session.commit() redirect(request.headers.get('REFERER', url(controller='main/conferences', action='index')))
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) return str(mPin.pin)