Browse Source

Fix incorrect merge.

develop
Sam Black 3 years ago
parent
commit
01d56ee093
  1. 8
      services/libexec/sponson-build
  2. 43
      services/sponson-build
  3. 8
      services/sponson-build.service
  4. 76
      sponson/builder/dbus.py
  5. 1
      sponson/cli.py

8
services/libexec/sponson-build

@ -1,8 +1,8 @@
#!/usr/bin/env python3
# coding=utf8
#
# sponson-build: Image builder DBUS service
# Copyright (C) 2017 Sam Black <samwwwblack@lapwing.org>
# sponson-build: Builder DBUS service
# Copyright (C) 2018 Sam Black <samwwwblack@lapwing.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -20,7 +20,7 @@
from gi.repository import GLib
from pydbus import SystemBus
from sponson.builder.dbus import BuilderDbus
from sponson.builder.dbus.manager import Manager
if __name__ == "__main__":
@ -28,7 +28,7 @@ if __name__ == "__main__":
bus = SystemBus()
manager = BuilderDbus(bus)
manager = Manager(bus)
bus.publish(manager.BUS_NAME,
(manager.OBJECT_NAME, manager))

43
services/sponson-build

@ -1,43 +0,0 @@
#!/usr/bin/env python3
# coding=utf8
#
# sponson-build: Builder DBUS service
# Copyright (C) 2018 Sam Black <samwwwblack@lapwing.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from gi.repository import GLib
from pydbus import SystemBus
from sponson.builder.dbus.manager import Manager
if __name__ == "__main__":
loop = GLib.MainLoop()
bus = SystemBus()
manager = Manager(bus)
bus.publish(manager.BUS_NAME,
(manager.OBJECT_NAME, manager))
try:
loop.run()
except KeyboardInterrupt:
print("Keyboard interrupt received")
except Exception as e:
print("Unexpected exception occurred: '{}'".format(str(e)))
finally:
loop.quit()

8
services/sponson-build.service

@ -1,8 +0,0 @@
[Unit]
Description=Daemon for Sponson image building
[Service]
Type=dbus
BusName=org.lapwing.sponson.Build
ExecStart=/usr/libexec/sponson/sponson-build
Restart=on-failure

76
sponson/builder/dbus.py

@ -1,76 +0,0 @@
# coding=utf8
#
# dbus.py: DBUS service for building images
# Copyright (C) 2017 Sam Black <samwwwblack@lapwing.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from pydbus.generic import signal
from pydbus.strong_typing import typed_method
from pydbus.xml_generator import attach_introspection_xml
from sponson.builder.build import Builder
from sponson.builder.build import BuilderError
from sponson.configfile import get_runtime_config
from sponson.configfile import read_config_file
@attach_introspection_xml
class BuilderDbus(object):
BUS_NAME = "org.lapwing.sponson.Build"
INTERFACE_NAME = BUS_NAME
OBJECT_PREFIX = "/org/lapwing/sponson/Build"
OBJECT_NAME = OBJECT_PREFIX
def __init__(self, system_bus):
self.system_bus = system_bus
self.runtime_config = get_runtime_config()
self.build_lock = False
@signal
@typed_method(("s",), None)
def BuildStarted(self, build_name):
pass
@signal
@typed_method(("s",), None)
def BuildFinished(self, build_name):
pass
@typed_method(("h", "s", "s"), None)
def Build(self, config_path, working_dir, remote):
if self.build_lock:
raise BuilderError("Image builder is already running")
if not working_dir:
working_dir = None
if not remote or remote == "local":
remote = None
config = read_config_file(config_path)
builder = Builder(config, self.runtime_config, remote)
self.build_lock = True
self.BuildStarted(builder.name)
try:
builder.start(working_dir)
except BuilderError:
self.build_lock = False
finally:
self.build_lock = False
self.BuildFinished(builder.name)

1
sponson/cli.py

@ -17,6 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import click
import os
from pydbus import SystemBus

Loading…
Cancel
Save