Skip to content

Commit b33b260

Browse files
committed
fix version conflict
2 parents 638f0f5 + 66c93e7 commit b33b260

File tree

7 files changed

+26
-28
lines changed

7 files changed

+26
-28
lines changed

hassio/__main__.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
# pylint: disable=invalid-name
1414
if __name__ == "__main__":
1515
bootstrap.initialize_logging()
16+
loop = asyncio.get_event_loop()
1617

1718
if not bootstrap.check_environment():
18-
exit(1)
19+
sys.exit(1)
1920

20-
loop = asyncio.get_event_loop()
21+
# init executor pool
2122
executor = ThreadPoolExecutor(thread_name_prefix="SyncWorker")
2223
loop.set_default_executor(executor)
2324

@@ -27,19 +28,20 @@
2728

2829
bootstrap.migrate_system_env(config)
2930

30-
_LOGGER.info("Run Hassio setup")
31+
_LOGGER.info("Setup HassIO")
3132
loop.run_until_complete(hassio.setup())
3233

33-
_LOGGER.info("Start Hassio")
3434
loop.call_soon_threadsafe(loop.create_task, hassio.start())
35-
loop.call_soon_threadsafe(bootstrap.reg_signal, loop, hassio)
36-
37-
_LOGGER.info("Run Hassio loop")
38-
loop.run_forever()
35+
loop.call_soon_threadsafe(bootstrap.reg_signal, loop)
3936

40-
_LOGGER.info("Cleanup system")
41-
executor.shutdown(wait=False)
42-
loop.close()
37+
try:
38+
_LOGGER.info("Run HassIO")
39+
loop.run_forever()
40+
finally:
41+
_LOGGER.info("Stopping HassIO")
42+
loop.run_until_complete(hassio.stop())
43+
executor.shutdown(wait=False)
44+
loop.close()
4345

4446
_LOGGER.info("Close Hassio")
45-
sys.exit(hassio.exit_code)
47+
sys.exit(0)

hassio/addons/validate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def _simple_startup(value):
113113
vol.Coerce(str): vol.Any(SCHEMA_ELEMENT, [SCHEMA_ELEMENT])
114114
}))
115115
}), False),
116-
vol.Optional(ATTR_IMAGE): vol.Match(r"^[\-\w{}]+/[\-\w{}]+$"),
116+
vol.Optional(ATTR_IMAGE): vol.Match(r"^[\w{}]+/[\-\w{}]+$"),
117117
vol.Optional(ATTR_TIMEOUT, default=10):
118118
vol.All(vol.Coerce(int), vol.Range(min=10, max=120))
119119
}, extra=vol.REMOVE_EXTRA)
@@ -130,7 +130,7 @@ def _simple_startup(value):
130130
# pylint: disable=no-value-for-parameter
131131
SCHEMA_BUILD_CONFIG = vol.Schema({
132132
vol.Optional(ATTR_BUILD_FROM, default=BASE_IMAGE): vol.Schema({
133-
vol.In(ARCH_ALL): vol.Match(r"^[\-\w{}]+/[\-\w{}]+:[\-\w{}]+$"),
133+
vol.In(ARCH_ALL): vol.Match(r"(?:^[\w{}]+/)?[\-\w{}]+:[\.\-\w{}]+$"),
134134
}),
135135
vol.Optional(ATTR_SQUASH, default=False): vol.Boolean(),
136136
vol.Optional(ATTR_ARGS, default={}): vol.Schema({

hassio/bootstrap.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,22 +123,22 @@ def check_environment():
123123
return True
124124

125125

126-
def reg_signal(loop, hassio):
126+
def reg_signal(loop):
127127
"""Register SIGTERM, SIGKILL to stop system."""
128128
try:
129129
loop.add_signal_handler(
130-
signal.SIGTERM, lambda: loop.create_task(hassio.stop()))
130+
signal.SIGTERM, lambda: loop.call_soon(loop.stop))
131131
except (ValueError, RuntimeError):
132132
_LOGGER.warning("Could not bind to SIGTERM")
133133

134134
try:
135135
loop.add_signal_handler(
136-
signal.SIGHUP, lambda: loop.create_task(hassio.stop()))
136+
signal.SIGHUP, lambda: loop.call_soon(loop.stop))
137137
except (ValueError, RuntimeError):
138138
_LOGGER.warning("Could not bind to SIGHUP")
139139

140140
try:
141141
loop.add_signal_handler(
142-
signal.SIGINT, lambda: loop.create_task(hassio.stop()))
142+
signal.SIGINT, lambda: loop.call_soon(loop.stop))
143143
except (ValueError, RuntimeError):
144144
_LOGGER.warning("Could not bind to SIGINT")

hassio/const.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from pathlib import Path
33
from ipaddress import ip_network
44

5-
HASSIO_VERSION = '0.71'
5+
HASSIO_VERSION = '0.72'
66

77
URL_HASSIO_VERSION = ('https://raw.githubusercontent.com/home-assistant/'
88
'hassio/{}/version.json')
@@ -20,8 +20,6 @@
2020
RUN_WATCHDOG_HOMEASSISTANT_API = 300
2121
RUN_CLEANUP_API_SESSIONS = 900
2222

23-
RESTART_EXIT_CODE = 100
24-
2523
FILE_HASSIO_ADDONS = Path(HASSIO_DATA, "addons.json")
2624
FILE_HASSIO_CONFIG = Path(HASSIO_DATA, "config.json")
2725
FILE_HASSIO_HOMEASSISTANT = Path(HASSIO_DATA, "homeassistant.json")

hassio/core.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,14 @@ async def start(self):
177177
if self.homeassistant.version == 'landingpage':
178178
self.loop.create_task(self.homeassistant.install())
179179

180-
async def stop(self, exit_code=0):
180+
async def stop(self):
181181
"""Stop a running orchestration."""
182182
# don't process scheduler anymore
183183
self.scheduler.suspend = True
184184

185185
# process stop tasks
186186
self.websession.close()
187187
self.homeassistant.websession.close()
188-
await asyncio.wait([self.api.stop(), self.dns.stop()], loop=self.loop)
189188

190-
self.exit_code = exit_code
191-
self.loop.stop()
189+
# process async stop tasks
190+
await asyncio.wait([self.api.stop(), self.dns.stop()], loop=self.loop)

hassio/dock/supervisor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
from .interface import DockerInterface
88
from .util import docker_process
9-
from ..const import RESTART_EXIT_CODE
109

1110
_LOGGER = logging.getLogger(__name__)
1211

@@ -52,7 +51,7 @@ async def update(self, tag):
5251
_LOGGER.info("Update supervisor docker to %s:%s", self.image, tag)
5352

5453
if await self.loop.run_in_executor(None, self._install, tag):
55-
self.loop.create_task(self.stop_callback(RESTART_EXIT_CODE))
54+
self.loop.call_later(1, self.loop.stop)
5655
return True
5756

5857
return False

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"hassio": "0.71",
2+
"hassio": "0.72",
33
"homeassistant": "0.55.2",
44
"resinos": "1.1",
55
"resinhup": "0.3",

0 commit comments

Comments
 (0)