<commit_before>from flask import Flask,request,jsonify
# from dbus import SystemBus,Interface
from pydbus import SystemBus
import types
app = Flask(__name__)
app.debug = True
from werkzeug.debug import DebuggedApplication
app.wsgi_app = DebuggedApplication(app.wsgi_app, True)

bus = SystemBus()
sysd = bus.get("org.freedesktop.systemd1")
sysd.get_unit = types.MethodType(lambda self,name: self._bus.get('.systemd1',self.LoadUnit(name)[0]), sysd)

@app.route("/dashboard")
def main():
    return "Hello World!"

@app.route("/dashboard/systemd")
def systemd_unit_list():
    units = sysd.ListUnits()[0]
    return jsonify({'data':units})

@app.route("/dashboard/service/<service_name>")
def service(service_name):
    return "Service: "+service_name

@app.route("/dashboard/systemd/<unit_name>/property/<property_>")
def systemd_property(unit_name,property_):
    return jsonify({'data':sysd.get_unit(unit_name).Get('org.freedesktop.systemd1.Unit',property_)[0]})
<commit_msg>Changed bus timeout because the raspberry is a little slow and was getting some timeouts. Set to infinite for now.<commit_after>from flask import Flask,request,jsonify
# from dbus import SystemBus,Interface
from pydbus import SystemBus
import types
app = Flask(__name__)
app.debug = True
from werkzeug.debug import DebuggedApplication
app.wsgi_app = DebuggedApplication(app.wsgi_app, True)

bus = SystemBus()
bus.timeout = -1
sysd = bus.get("org.freedesktop.systemd1")
sysd.get_unit = types.MethodType(lambda self,name: self._bus.get('.systemd1',self.LoadUnit(name)[0]), sysd)

@app.route("/dashboard")
def main():
    return "Hello World!"

@app.route("/dashboard/systemd")
def systemd_unit_list():
    units = sysd.ListUnits()[0]
    return jsonify({'data':units})

@app.route("/dashboard/service/<service_name>")
def service(service_name):
    return "Service: "+service_name

@app.route("/dashboard/systemd/<unit_name>/property/<property_>")
def systemd_property(unit_name,property_):
    return jsonify({'data':sysd.get_unit(unit_name).Get('org.freedesktop.systemd1.Unit',property_)[0]})

{'fraction_non_alphanumeric': 0.14361702127659576, 'fraction_numerical': 0.006286266924564797, 'mean_word_length': 6.469314079422382, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1124079', 'n_tokens_mistral': 693, 'n_tokens_neox': 695, 'n_words': 137}