|
7 | 7 | from configparser import ConfigParser |
8 | 8 | from enum import Enum |
9 | 9 |
|
| 10 | +import aiohttp |
10 | 11 | import hid |
11 | 12 | from aiohttp import WSMsgType, web |
12 | 13 | from pyjoycon import ButtonEventJoyCon, JoyCon |
@@ -257,6 +258,26 @@ def save_config(parser): |
257 | 258 | parser.write(fp) |
258 | 259 |
|
259 | 260 |
|
| 261 | +async def on_startup(app): |
| 262 | + print(''' |
| 263 | + ░░ ░░░░░░ ░░ ░░ ░░░░░░ ░░░░░ ░░░ ░░ ░░░░░░ ░░░░░░░ |
| 264 | + ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒▒▒ ▒▒ ▒▒ ▒▒ |
| 265 | + ▒▒ ▒▒ ▒▒ ▒▒▒▒ ▒▒ ▒▒ ▒▒▒▒▒▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒▒▒▒ |
| 266 | +▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ |
| 267 | + █████ ██████ ██ ██████ ██ ██ ██ ████ ██████ ███████ |
| 268 | +
|
| 269 | +Open http://localhost:32623 in your browser.''') |
| 270 | + |
| 271 | + # Check for update |
| 272 | + async with aiohttp.ClientSession() as session: |
| 273 | + async with session.get('https://api.github.com/repos/redphx/joydance/releases/latest', ssl=False) as resp: |
| 274 | + json_body = await resp.json() |
| 275 | + latest_version = json_body['tag_name'][1:] |
| 276 | + print('Running version {}.'.format(JOYDANCE_VERSION)) |
| 277 | + if JOYDANCE_VERSION != latest_version: |
| 278 | + print('\033[93m{}\033[00m'.format('Version {} is available: https://github.com/redphx/joydance'.format(latest_version))) |
| 279 | + |
| 280 | + |
260 | 281 | async def html_handler(request): |
261 | 282 | config = dict((parse_config()).items('joydance')) |
262 | 283 | with open('static/index.html', 'r') as f: |
@@ -311,6 +332,7 @@ def favicon_handler(request): |
311 | 332 | app['joydance_connections'] = {} |
312 | 333 | app['joycons_info'] = {} |
313 | 334 |
|
| 335 | +app.on_startup.append(on_startup) |
314 | 336 | app.add_routes([ |
315 | 337 | web.get('/', html_handler), |
316 | 338 | web.get('/favicon.png', favicon_handler), |
|
0 commit comments