Beispiel #1
0
 def bus_context(self):
     close_bus_at_end = self._bus is None
     try:
         if self._bus is None:
             bus = DBus()
             bus.open()
         else:
             bus = self._bus
         yield bus
     finally:
         if close_bus_at_end:
             bus.close()
Beispiel #2
0
from app.models import Image
from app.schemas import ImageSchema
from app.camera import Camera

CORS(app)

dbus = None
yolo_unit = None
camera = None
yolo_version = app.config['YOLO_VERSION']
if app.config['JETSON_PLATFORM'] == 'True':
    from pystemd.systemd1 import Unit
    from pystemd.dbuslib import DBus

    dbus = DBus(user_mode=True)
    dbus.open()

    yolo_unit = Unit(b'orninet-yolov5.service', bus=dbus, _autoload=True)
    # yolo_unit = Unit(bytes(f'orninet-yolov{yolo_version}.service', 'utf-8'), bus=dbus, _autoload=True)

else:

    class PlaceholderUnit(object):
        def __init__(self):
            self.ActiveState = 'inactive'

    class PlaceholderYoloUnit(object):
        def __init__(self):
            self.Unit = PlaceholderUnit()

    yolo_unit = PlaceholderYoloUnit()