Beispiel #1
0
    def get_call_record_file(call_id, user):
        """
		Get call record file by call_id
		:param call_id: id of the call
		:param user: current user
		:return: call record File instance
		"""
        link = PBXDataService.get_call_record_download_link(call_id, user)
        if not link:
            return None

        disk_service = DiskService(user.userprofile.token)
        return disk_service.download_file(link)
	def get_call_record_file(call_id, user):
		"""
		Get call record file by call_id
		:param call_id: id of the call
		:param user: current user
		:return: call record File instance
		"""
		link = PBXDataService.get_call_record_download_link(call_id, user)
		if not link:
			return None

		disk_service = DiskService(user.userprofile.token)
		return disk_service.download_file(link)
Beispiel #3
0
    def get_call_record_download_link(call_id, user):
        """
		Get call record download link by call_id
		:param call_id: id of the call
		:param user: current user
		:return: call record download link
		"""
        filename = PBXDataService.get_call_record_filename(call_id, user)
        if not filename:
            return None

        # download file from disk
        disk_service = DiskService(user.userprofile.token)
        return disk_service.get_download_link(filename)
	def get_call_record_download_link(call_id, user):
		"""
		Get call record download link by call_id
		:param call_id: id of the call
		:param user: current user
		:return: call record download link
		"""
		filename = PBXDataService.get_call_record_filename(call_id, user)
		if not filename:
			return None

		# download file from disk
		disk_service = DiskService(user.userprofile.token)
		return disk_service.get_download_link(filename)
Beispiel #5
0
    def load_call_record_file(call, user):
        """
		Load audio, convert, upload to disk and update db with filename
		:param call: Call instance
		:param user: current user
		:return: File instance
		"""
        # get audio
        call_audio = PBXDataService.get_audio(call.call_id, user)
        if not call_audio:
            return None
        #
        # # convert audio
        # # write temp file
        # path = CommonService.write_temp_file(call_audio)
        # if not path:
        # 	return None
        #
        # call_audio.path = path
        #
        # # convert wav to mp3
        #
        # call_audio_mp3 = CommonService.convert_to_mp3(call_audio)
        # if not call_audio_mp3:
        # 	return None
        call_audio_mp3 = call_audio

        # upload new file to Disk
        disk_service = DiskService(user.userprofile.token)
        result = disk_service.upload_file(call_audio_mp3)
        if not result.is_success:
            return None

        filename = call_audio_mp3.filename
        # delete mp3 file form filesystem and save to db
        CommonService.delete_temp_file(filename)

        try:
            call.record_filename = filename
            call.save()
        except Exception as e:
            logger = LogService()
            logger.error(Code.UPDATE_CALL_ERR,
                         message=str(e),
                         call_id=call.pk,
                         filename=filename)
            return None

        return filename
	def load_call_record_file(call, user):
		"""
		Load audio, convert, upload to disk and update db with filename
		:param call: Call instance
		:param user: current user
		:return: File instance
		"""
		# get audio
		call_audio = PBXDataService.get_audio(call.call_id, user)
		if not call_audio:
			return None
		#
		# # convert audio
		# # write temp file
		# path = CommonService.write_temp_file(call_audio)
		# if not path:
		# 	return None
		#
		# call_audio.path = path
		#
		# # convert wav to mp3
		#
		# call_audio_mp3 = CommonService.convert_to_mp3(call_audio)
		# if not call_audio_mp3:
		# 	return None
		call_audio_mp3 = call_audio

		# upload new file to Disk
		disk_service = DiskService(user.userprofile.token)
		result = disk_service.upload_file(call_audio_mp3)
		if not result.is_success:
			return None

		filename = call_audio_mp3.filename
		# delete mp3 file form filesystem and save to db
		CommonService.delete_temp_file(filename)

		try:
			call.record_filename = filename
			call.save()
		except Exception as e:
			logger = LogService()
			logger.error(Code.UPDATE_CALL_ERR, message=str(e), call_id=call.pk, filename=filename)
			return None

		return filename