コード例 #1
0
 def req_geocodes_list(self, request):
     data = obplayer.Config.setting('alerts_geocode', True)
     res = httpserver.Response()
     if data:
         res.send_content('text/plain', data)
         return res
     else:
         res.send_content('text/plain', '')
         return res
コード例 #2
0
 def req_stop_inter_station_ctrl(self, request):
     res = httpserver.Response()
     try:
         obplayer.LineinStreamer.quit()
     except Exception as e:
         res.send_content(500, 'text/plain', '500 error')
         return res
     res.send_content('text/plain', '')
     return res
コード例 #3
0
ファイル: httpadmin.py プロジェクト: rrymm/obplayer
    def req_export(self, request):
        settings = ''
        for (name, value) in sorted(obplayer.Config.list_settings(hidepasswords=True).items()):
            settings += "{0}:{1}\n".format(name, value if type(value) != bool else int(value))

        res = httpserver.Response()
        res.add_header('Content-Disposition', 'attachment; filename=obsettings.txt')
        res.send_content('text/plain', settings)
        return res
コード例 #4
0
 def req_indigenous_languages_list(self, request):
     data = obplayer.Config.setting('alerts_selected_indigenous_languages',
                                    True)
     res = httpserver.Response()
     if data:
         res.send_content('text/plain', data)
         return res
     else:
         res.send_content('text/plain', '')
         return res
コード例 #5
0
 def req_export_alert_log(self, request):
     output = []
     log_data = obplayer.Log.get_log()
     for line in log_data:
         if re.search('\[alerts\]', line):
             output.append(line)
     res = httpserver.Response()
     res.add_header('Content-Disposition',
                    'attachment; filename=obalerts.txt')
     res.send_content('text/plain', '\n'.join(output))
     #return '\n'.join(output)
     return res
コード例 #6
0
def inter_station_ctrl_is_live():
    res = httpserver.Response()
    try:
        if hasattr(obplayer, 'LineinStreamer'):
            res.send_content('text/plain', 'True')
            return res
        else:
            res.send_content('text/plain', 'False')
            return res
    except Exception as e:
        res.send_content('text/plain', '500 error')
        return res
コード例 #7
0
 def req_start_inter_station_ctrl(self, request):
     res = httpserver.Response()
     try:
         obplayer.LineinStreamer = ObLineinIcecastStreamer(
             obplayer.Config.setting('station_override_server_ip'),
             obplayer.Config.setting('station_override_server_port'),
             obplayer.Config.setting('station_override_server_password'),
             obplayer.Config.setting('station_override_server_mountpoint'),
             '', '', '', False, 128)
         obplayer.LineinStreamer.start()
     except Exception as e:
         raise e
     res.send_content('text/plain', '')
     return res
コード例 #8
0
def inter_station_ctrl_toggle(live):
    res = httpserver.Response()
    try:
        if live == False:
            obplayer.LineinStreamer.quit()
            del obplayer.LineinStreamer
        else:
            obplayer.LineinStreamer = ObLineinIcecastStreamer(
                obplayer.Config.setting('station_override_server_ip'),
                obplayer.Config.setting('station_override_server_port'),
                obplayer.Config.setting('station_override_server_password'),
                obplayer.Config.setting('station_override_server_mountpoint'),
                '', '', '', False, 128)
            obplayer.LineinStreamer.start()
    except Exception as e:
        res.send_content(500, 'text/plain', '500 error')
        return res
    res.send_content('text/plain', '')
    return res