Beispiel #1
0
 def remove(self):
     server = get_first_user_server(current_user)
     if server:
         sid = request.form['sid']
         server.remove_stream(sid)
         return jsonify(status='ok'), 200
     return jsonify(status='failed'), 404
Beispiel #2
0
    def activate(self):
        form = ActivateForm()
        if request.method == 'POST':
            server = get_first_user_server(current_user)
            if server:
                return _activate_server(server, form)

        return render_template('user/activate.html', form=form)
Beispiel #3
0
    def dashboard(self):
        server = get_first_user_server(current_user)
        if server:
            streams = server.get_streams()
            front_streams = []
            for stream in streams:
                front_streams.append(stream.to_front())
            service = server.to_front()
            return render_template('user/dashboard.html',
                                   streams=front_streams,
                                   service=service)

        return redirect(url_for('UserView:settings'))
Beispiel #4
0
    def view_log(self):
        server = get_first_user_server(current_user)
        if server:
            path = os.path.join(get_runtime_folder(), server.id)
            try:
                with open(path, "r") as f:
                    content = f.read()

                return content
            except OSError as e:
                print('Caught exception OSError : {0}'.format(e))
                return '''<pre>Not found, please use get log button firstly.</pre>'''
        return '''<pre>Not found, please create server firstly.</pre>'''
Beispiel #5
0
    def edit(self, sid):
        server = get_first_user_server(current_user)
        if server:
            stream = server.find_stream_by_id(sid)
            if stream:
                type = stream.get_type()
                if type == StreamType.RELAY:
                    return _edit_relay_stream(server, request.method, stream)
                elif type == StreamType.ENCODE:
                    return _edit_encode_stream(server, request.method, stream)
                elif type == StreamType.TIMESHIFT_RECORDER:
                    return _edit_timeshift_recorder_stream(
                        server, request.method, stream)
                elif type == StreamType.CATCHUP:
                    return _edit_catchup_stream(server, request.method, stream)
                elif type == StreamType.TIMESHIFT_PLAYER:
                    return _edit_timeshift_player_stream(
                        server, request.method, stream)
                elif type == StreamType.TEST_LIFE:
                    return _edit_test_life_stream(server, request.method,
                                                  stream)

        return jsonify(status='failed'), 404
Beispiel #6
0
 def get_log(self):
     server = get_first_user_server(current_user)
     if server:
         server.get_log_service()
     return redirect(url_for('UserView:dashboard'))
Beispiel #7
0
 def ping(self):
     server = get_first_user_server(current_user)
     if server:
         server.ping()
     return redirect(url_for('UserView:dashboard'))
Beispiel #8
0
 def add_timeshift_player(self):
     server = get_first_user_server(current_user)
     if server:
         return _add_timeshift_player_stream(server, request.method)
     return jsonify(status='failed'), 404
Beispiel #9
0
 def add_catchup(self):
     server = get_first_user_server(current_user)
     if server:
         return _add_catchup_stream(server, request.method)
     return jsonify(status='failed'), 404