Example #1
0
    def delete_channel(cls, client, channel_id):
        """returns true or raises exception.

        param: channel_id: number id of channel to be deleted
            note that this returns success if the channel was inexistent.
        """

        def check_success_message(tag):
            return 'successfully deleted' in tag.text

        # best guess if channel_id refers to a recorder
        recorder_id = None
        try:
            if channel_id.startswith('m'):
                r = channel_id.split('m')
                recorder_id = r[1]
        except IndexError:
            # will not guess and use channel_id as is
            pass

        params = {
                'deleteid': channel_id,
                'deletemode': 'trash'}

        path = '/admin/channel%s/status' % channel_id
        if recorder_id:
            path = '/admin/recorder%s/archive' % recorder_id

        check_success = [
                {
                    'emsg': 'successful deletion message not found',
                    'func': check_success_message}]

        return WebUiConfig.configuration(
                client=client,
                params=params,
                path=path,
                check_success=check_success)
Example #2
0
    def set_recorder_channels(cls, client, recorder_id, channel_list):
        """returns true or raise exception."""

        # note in this case, checks won't catch channels that are _not_
        # supposed to be configured, if the ones that are supposed to be
        # configured are correct.
        check_success = []
        for i in channel_list:
            check_success.append({
                'emsg': 'channel(%s) missing for recorder(%s) config' %
                        (i, recorder_id),
                'func': WebUiConfig.check_multivalue_select(
                    name='rc[]', value=i)})

        channel_list_param = [('rc[]', x) for x in channel_list]
        params = [('pfd_form_id', 'recorder_channels')] + channel_list_param
        path = '/admin/recorder%s/archive' % recorder_id

        return WebUiConfig.configuration(
                client=client,
                params=params,
                path=path,
                check_success=check_success)
Example #3
0
    def set_channel_rtmp(
            cls, client, channel_id,
            rtmp_url, rtmp_stream, rtmp_usr, rtmp_pwd):
        """returns true or raises exception."""

        params = {
                'rtmp_url': rtmp_url,
                'rtmp_stream': rtmp_stream,
                'rtmp_username': rtmp_usr,
                'rtmp_password': rtmp_pwd}

        path = '/admin/channel%s/streamsetup' % channel_id

        check_success = [
                {
                    'emsg': 'rtmp_usr expected(%s)' % rtmp_usr,
                    'func': WebUiConfig.check_input_id_value(
                        tag_id='rtmp_username', value=rtmp_usr)},
                {
                    'emsg': 'rtmp_url expected(%s)' % rtmp_url,
                    'func': WebUiConfig.check_input_id_value(
                        tag_id='rtmp_url', value=rtmp_url)},
                {
                    'emsg': 'rtmp_stream expected(%s)' % rtmp_stream,
                    'func': WebUiConfig.check_input_id_value(
                        tag_id='rtmp_stream', value=rtmp_stream)},
                {
                    'emsg': 'not the rtmp_pwd expected',
                    'func': WebUiConfig.check_input_id_value(
                        tag_id='rtmp_password', value=rtmp_pwd)}]

        return WebUiConfig.configuration(
                client=client,
                params=params,
                path=path,
                check_success=check_success)
Example #4
0
    def set_recorder_settings(
            cls, client,
            recorder_id,  # number id (without usual prefix 'm')
            recording_timelimit_in_minutes=360,      # 6h
            recording_sizelimit_in_kbytes=64000000,  # 64G
            output_format='avi',  # or mov, mp4, ts(mpeg-ts)
            user_prefix='',       # prefix for recording file
            afu_enabled='on',     # this means auto-upload disabled!
            upnp_enabled=''):

        #
        # 06jun16 naomi: upnp and afu(automatic file upload) have dependencies
        # that are not treated by this api call (these features must be
        # enabled for the device and configured in 'automatic file upload' and
        # 'UPnP' webui calls)
        # -- to be implemented in epipearl.endpoints.webui_config.
        #

        timelimit = '%d:%02d:00' % (
                recording_timelimit_in_minutes / 60,
                recording_timelimit_in_minutes % 60)

        check_success = [
                {
                    'emsg': 'timelimit expected(%s)' % timelimit,
                    'func': WebUiConfig.check_singlevalue_select(
                        value=timelimit)},
                {
                    'emsg': 'sizelimit expected(%s)' %
                            recording_sizelimit_in_kbytes,
                    'func': WebUiConfig.check_singlevalue_select(
                        value=str(recording_sizelimit_in_kbytes))},
                {
                    'emsg': 'output_format expected(%s)' % output_format,
                    'func': WebUiConfig.check_singlevalue_select(
                        value=output_format)},
                {
                    'emsg': 'user_prefix expected(%s)' % user_prefix,
                    'func': WebUiConfig.check_input_id_value(
                        tag_id='user_prefix', value=user_prefix)}]
        if afu_enabled == 'on':
            check_success.append(
                {
                    'emsg': 'auto file upload expected(OFF)',
                    'func': WebUiConfig.check_singlevalue_checkbox_disabled(
                                tag_id='afu_enabled')})
        else:
            check_success.append(
                {
                    'emsg': 'auto file upload expected(ON)',
                    'func': WebUiConfig.check_singlevalue_checkbox(
                                tag_id='afu_enabled')})
        if upnp_enabled == 'on':
            check_success.append(
                {
                    'emsg': 'share via UPnP expected(ON)',
                    'func': WebUiConfig.check_singlevalue_checkbox(
                                tag_id='upnp_enabled')})
        else:
            check_success.append(
                {
                    'emsg': 'share via UPnP expected(OFF)',
                    'func': WebUiConfig.check_singlevalue_checkbox_disabled(
                                tag_id='upnp_enabled')})
        params = {
                'pfd_form_id': 'rec_settings',
                'timelimit': timelimit,
                'sizelimit': recording_sizelimit_in_kbytes,
                'output_format': output_format,
                'user_prefix': user_prefix,
                'afu_enabled': afu_enabled,
                'upnp_enabled': upnp_enabled}
        path = '/admin/recorder%s/archive' % recorder_id


        assert upnp_enabled == ''

        return WebUiConfig.configuration(
                client=client,
                params=params,
                path=path,
                check_success=check_success)
Example #5
0
    def set_mhpearl_settings(
            cls, client,
            device_name='',       # device name for mh admin
            device_channel='',    # vod recorder id number
            file_search_range_in_seconds='',    # range within which it must
                                                # locate a recording
            admin_server_url='',  # mh admin url
            admin_server_usr='',  # mh digest user
            admin_server_pwd='',  # mh digest pwd
            update_frequency_in_seconds='120',  # freq to poll for schedule
            backup_agent=False):    # if True, does not upload recording to
                                    # mh when done

        check_success = [
                {
                    'emsg': 'device_name expected(%s)' % device_name,
                    'func': WebUiConfig.check_input_id_value(
                        tag_id='ca_name', value=device_name)},
                {
                    'emsg': 'device_username expected(%s)' % client.user,
                    'func': WebUiConfig.check_input_id_value(
                        tag_id='ca_user', value=client.user)},
                {
                    'emsg': 'not the device_password expected',
                    'func': WebUiConfig.check_input_id_value(
                        tag_id='ca_pass', value=client.passwd)},
                {
                    'emsg': 'device_channel expected(%s)' % device_channel,
                    'func': WebUiConfig.check_input_id_value(
                        tag_id='ca_chan', value=device_channel)},
                {
                    'emsg': 'file_search_range expected(%s)' %
                            file_search_range_in_seconds,
                    'func': WebUiConfig.check_input_id_value(
                        tag_id='ca_range',
                        value=str(file_search_range_in_seconds))},
                {
                    'emsg': 'admin_server_url expected(%s)' % admin_server_url,
                    'func': WebUiConfig.check_input_id_value(
                        tag_id='mh_host', value=admin_server_url)},
                {
                    'emsg': 'admin_server_user expected(%s)' %
                            admin_server_usr,
                    'func': WebUiConfig.check_input_id_value(
                        tag_id='mh_user', value=admin_server_usr)},
                {
                    'emsg': 'not the admin_server_passwd expected',
                    'func': WebUiConfig.check_input_id_value(
                        tag_id='mh_pass', value=admin_server_pwd)},
                {
                    'emsg': 'update_frequency expected(%s)' %
                            update_frequency_in_seconds,
                    'func': WebUiConfig.check_input_id_value(
                        tag_id='mh_freq',
                        value=str(update_frequency_in_seconds))}]

        params = {
                'DEVICE_NAME': device_name,
                'DEVICE_USERNAME': client.user,
                'DEVICE_PASSWORD': client.passwd,
                'DEVICE_CHANNEL': device_channel,
                'FILE_SEARCH_RANGE': file_search_range_in_seconds,
                'ADMIN_SERVER_URL': admin_server_url,
                'ADMIN_SERVER_USER': admin_server_usr,
                'ADMIN_SERVER_PASSWD': admin_server_pwd,
                'UPDATE_FREQUENCY': update_frequency_in_seconds}

        if backup_agent:
            params['BACKUP_AGENT'] = 'on'
            check_success.append({
                'emsg': 'backup_agent expected("ON")',
                'func': WebUiConfig.check_singlevalue_checkbox(
                    tag_id='mh_backup')})
        else:
            check_success.append({
                'emsg': 'backup_agent expected("ON")',
                'func': WebUiConfig.
                        check_singlevalue_checkbox_disabled(
                            tag_id='mh_backup')})

        path = '/admin/mhcfg'
        return WebUiConfig.configuration(
                client=client,
                params=params,
                path=path,
                check_success=check_success)