def post_request_(self, command, xml_string):
     try:
         auth_string = "Basic " + base64.b64encode(self.user_name_ + ":" +
                                                   self.password_)
         headers = {
             "Content-type": "application/x-www-form-urlencoded",
             "Accept": "text/plain",
             "Authorization": auth_string
         }
         connection = httplib.HTTPConnection(self.address_ + ":" +
                                             str(self.port_))
         post_request = urllib.urlencode({
             self.CMD_PARAM_: command,
             self.XML_PARAM_: xml_string
         })
         connection.request(self.METHOD_POST_, self.URL_SUFFIX_,
                            post_request, headers)
         response = connection.getresponse()
         if self.STATUS_UNAUTHORISED_ == response.status:
             helper.log_error(
                 'HttpDataProvider.post_request_. Unauthorized error')
             raise DVBLinkError(DVBLinkStatus.STATUS_UNAUTHORISED)
         data = response.read()
         connection.close()
         return data
     except socket.error, error:
         helper.log_error('HttpDataProvider.post_request_. Socket error')
         raise DVBLinkError(DVBLinkStatus.STATUS_CONNECTION_ERROR)
	def cancel_recording(self, recording_id):
		try:
			data_provider.remove_recording(RecordingRemover(recording_id))
			if None != self.do_callback_func_:
				self.do_callback_func_()
			return True
		except common.DVBLinkError, error:
			helper.log_error('ControlRecorder.cancel_recording. ' + str(error))
	def cancel_series(self, schedule_id):
		try:
			data_provider.remove_schedule(ScheduleRemover(schedule_id))
			if None != self.do_callback_func_:
				self.do_callback_func_()
			return True
		except common.DVBLinkError, error:
			helper.log_error('ControlRecorder.cancel_series. ' + str(error))
	def add_recording_(self, channel_id, program_id, is_repeat=False):
		try:
			data_provider.add_schedule(Schedule(by_epg=ByEpgSchedule(channel_id, program_id, is_repeat)))
			if None != self.do_callback_func_:
				self.do_callback_func_()
			return True
		except common.DVBLinkError, error:
			helper.log_error('ControlRecorder.add_recording_. ' + str(error))
示例#5
0
 def cancel_series(self, schedule_id):
     try:
         data_provider.remove_schedule(ScheduleRemover(schedule_id))
         if None != self.do_callback_func_:
             self.do_callback_func_()
         return True
     except common.DVBLinkError, error:
         helper.log_error('ControlRecorder.cancel_series. ' + str(error))
示例#6
0
 def cancel_recording(self, recording_id):
     try:
         data_provider.remove_recording(RecordingRemover(recording_id))
         if None != self.do_callback_func_:
             self.do_callback_func_()
         return True
     except common.DVBLinkError, error:
         helper.log_error('ControlRecorder.cancel_recording. ' + str(error))
 def get_xml_string_(self, response):
     status = DVBLinkStatus.STATUS_INVALID_DATA
     try:
         document = parseString(response)
         status = int(document.getElementsByTagName(STATUS_CODE_NODE)[0].firstChild.data)
     except Exception, error:
         helper.log_error('HttpDataProvider.get_xml_string_. %s' % str(error))
         raise DVBLinkError(DVBLinkStatus.STATUS_INVALID_DATA)
示例#8
0
 def add_recording_(self, channel_id, program_id, is_repeat=False):
     try:
         data_provider.add_schedule(
             Schedule(
                 by_epg=ByEpgSchedule(channel_id, program_id, is_repeat)))
         if None != self.do_callback_func_:
             self.do_callback_func_()
         return True
     except common.DVBLinkError, error:
         helper.log_error('ControlRecorder.add_recording_. ' + str(error))
 def get_xml_string_(self, response):
     status = DVBLinkStatus.STATUS_INVALID_DATA
     try:
         document = parseString(response)
         status = int(
             document.getElementsByTagName(STATUS_CODE_NODE)
             [0].firstChild.data)
     except Exception, error:
         helper.log_error('HttpDataProvider.get_xml_string_. %s' %
                          str(error))
         raise DVBLinkError(DVBLinkStatus.STATUS_INVALID_DATA)
	def schedule_update(self, schedule_id, is_new_only, is_record_series_anytime, recordings_to_keep):
		try:
			data_provider.update_schedule(ScheduleUpdater(
				schedule_id = schedule_id,
				new_only = is_new_only, 
				record_series_anytime = is_record_series_anytime,
				recordings_to_keep = recordings_to_keep))
			if None != self.do_callback_func_:
				self.do_callback_func_()
			return True
		except common.DVBLinkError, error:
			helper.log_error('ControlRecorder.schedule_update. ' + str(error))
示例#11
0
 def schedule_update(self, schedule_id, is_new_only,
                     is_record_series_anytime, recordings_to_keep):
     try:
         data_provider.update_schedule(
             ScheduleUpdater(schedule_id=schedule_id,
                             new_only=is_new_only,
                             record_series_anytime=is_record_series_anytime,
                             recordings_to_keep=recordings_to_keep))
         if None != self.do_callback_func_:
             self.do_callback_func_()
         return True
     except common.DVBLinkError, error:
         helper.log_error('ControlRecorder.schedule_update. ' + str(error))
 def post_request_(self, command, xml_string):
     try:
         auth_string = "Basic " + base64.b64encode(self.user_name_ + ":" + self.password_)
         headers = {"Content-type": "application/x-www-form-urlencoded",
                    "Accept": "text/plain",
                    "Authorization": auth_string}
         connection = httplib.HTTPConnection(self.address_ + ":" + str(self.port_))
         post_request = urllib.urlencode({self.CMD_PARAM_: command, self.XML_PARAM_: xml_string})
         connection.request(self.METHOD_POST_, self.URL_SUFFIX_, post_request, headers)
         response = connection.getresponse()
         if self.STATUS_UNAUTHORISED_ == response.status:
             helper.log_error('HttpDataProvider.post_request_. Unauthorized error')
             raise DVBLinkError(DVBLinkStatus.STATUS_UNAUTHORISED)
         data = response.read()
         connection.close()
         return data
     except socket.error, error:
         helper.log_error('HttpDataProvider.post_request_. Socket error')
         raise DVBLinkError(DVBLinkStatus.STATUS_CONNECTION_ERROR)
示例#13
0
class ControlRecorder(object):
    def __init__(self, callback_func=None):
        self.do_callback_func_ = callback_func

    def set_callback(self, callback_func):
        self.do_callback_func_ = callback_func

    def add_recording(self, channel_id, program_id):
        return self.add_recording_(channel_id, program_id)

    def cancel_recording(self, recording_id):
        try:
            data_provider.remove_recording(RecordingRemover(recording_id))
            if None != self.do_callback_func_:
                self.do_callback_func_()
            return True
        except common.DVBLinkError, error:
            helper.log_error('ControlRecorder.cancel_recording. ' + str(error))
        except Exception, error:
            helper.log_error('ControlRecorder.cancel_recording. ' + str(error))
示例#14
0
            helper.log_error('ControlRecorder.cancel_recording. ' + str(error))
        return False

    def add_series(self, channel_id, program_id):
        return self.add_recording_(channel_id, program_id, True)

    def cancel_series(self, schedule_id):
        try:
            data_provider.remove_schedule(ScheduleRemover(schedule_id))
            if None != self.do_callback_func_:
                self.do_callback_func_()
            return True
        except common.DVBLinkError, error:
            helper.log_error('ControlRecorder.cancel_series. ' + str(error))
        except Exception, error:
            helper.log_error('ControlRecorder.cancel_series. ' + str(error))
        return False

    def schedule_update(self, schedule_id, is_new_only,
                        is_record_series_anytime, recordings_to_keep):
        try:
            data_provider.update_schedule(
                ScheduleUpdater(schedule_id=schedule_id,
                                new_only=is_new_only,
                                record_series_anytime=is_record_series_anytime,
                                recordings_to_keep=recordings_to_keep))
            if None != self.do_callback_func_:
                self.do_callback_func_()
            return True
        except common.DVBLinkError, error:
            helper.log_error('ControlRecorder.schedule_update. ' + str(error))
 def get_data_(self, command, xml_string):
     response = self.post_request_(command, xml_string)
     if len(response) == 0:
         helper.log_error('HttpDataProvider.get_data_. Response is empty')
         raise DVBLinkError(DVBLinkStatus.STATUS_CONNECTION_ERROR)
     return self.get_xml_string_(response)
 def get_data_(self, command, xml_string):
     response = self.post_request_(command, xml_string)
     if len(response) == 0:
         helper.log_error('HttpDataProvider.get_data_. Response is empty')
         raise DVBLinkError(DVBLinkStatus.STATUS_CONNECTION_ERROR)
     return self.get_xml_string_(response)
			helper.log_error('ControlRecorder.cancel_recording. ' + str(error))
		return False
    
	def add_series(self, channel_id, program_id):
		return self.add_recording_(channel_id, program_id, True)
    
	def cancel_series(self, schedule_id):
		try:
			data_provider.remove_schedule(ScheduleRemover(schedule_id))
			if None != self.do_callback_func_:
				self.do_callback_func_()
			return True
		except common.DVBLinkError, error:
			helper.log_error('ControlRecorder.cancel_series. ' + str(error))
		except Exception, error:
			helper.log_error('ControlRecorder.cancel_series. ' + str(error))
		return False
	
	def schedule_update(self, schedule_id, is_new_only, is_record_series_anytime, recordings_to_keep):
		try:
			data_provider.update_schedule(ScheduleUpdater(
				schedule_id = schedule_id,
				new_only = is_new_only, 
				record_series_anytime = is_record_series_anytime,
				recordings_to_keep = recordings_to_keep))
			if None != self.do_callback_func_:
				self.do_callback_func_()
			return True
		except common.DVBLinkError, error:
			helper.log_error('ControlRecorder.schedule_update. ' + str(error))
		except Exception, error: