Stop supporting starting without pyotherside

This commit is contained in:
miruka 2019-09-10 17:28:16 -04:00
parent 6da3e0ab87
commit b3135601ed
5 changed files with 11 additions and 58 deletions

View File

@ -10,8 +10,9 @@ from typing import Coroutine, Sequence
from appdirs import AppDirs from appdirs import AppDirs
import nio import nio
import pyotherside
from . import __about__, pyotherside from . import __about__
from .pyotherside_events import CoroutineDone from .pyotherside_events import CoroutineDone
log.getLogger().setLevel(log.INFO) log.getLogger().setLevel(log.INFO)
@ -42,27 +43,10 @@ class App:
self.loop = asyncio.get_event_loop() self.loop = asyncio.get_event_loop()
if not pyotherside.AVAILABLE:
self.set_debug(True, verbose=True)
self.loop_thread = Thread(target=self._loop_starter) self.loop_thread = Thread(target=self._loop_starter)
self.loop_thread.start() self.loop_thread.start()
def set_debug(self, enable: bool, verbose: bool = False) -> None:
if verbose:
log.getLogger().setLevel(log.DEBUG)
nio.logger_group.level = nio.log.logbook.DEBUGG
if enable:
log.info("Debug mode enabled.")
self.loop.set_debug(True)
self.debug = True
else:
self.loop.set_debug(False)
self.debug = False
def _loop_starter(self) -> None: def _loop_starter(self) -> None:
asyncio.set_event_loop(self.loop) asyncio.set_event_loop(self.loop)
@ -115,11 +99,6 @@ class App:
remote_pdb.RemotePdb("127.0.0.1", 4444).set_trace() remote_pdb.RemotePdb("127.0.0.1", 4444).set_trace()
def test_run(self) -> None:
self.call_backend_coro("load_settings", "")
self.call_backend_coro("load_saved_accounts", "")
# Make CTRL-C work again # Make CTRL-C work again
signal.signal(signal.SIGINT, signal.SIG_DFL) signal.signal(signal.SIGINT, signal.SIG_DFL)

View File

@ -1,13 +1,14 @@
import asyncio import asyncio
import json import json
import logging as log import logging as log
from dataclasses import dataclass, field
from pathlib import Path from pathlib import Path
from typing import Any, Dict from typing import Any, Dict
import aiofiles import aiofiles
from dataclasses import dataclass, field
from . import pyotherside import pyotherside
from .backend import Backend from .backend import Backend
from .theme_parser import convert_to_qml from .theme_parser import convert_to_qml
from .utils import dict_update_recursive from .utils import dict_update_recursive
@ -172,9 +173,6 @@ class Theme(ConfigFile):
async def read(self) -> str: async def read(self) -> str:
if not pyotherside.AVAILABLE:
return ""
if not self.path.exists(): if not self.path.exists():
await self.write(await self.default_data()) await self.write(await self.default_data())

View File

@ -12,12 +12,14 @@ import aiofiles
from PIL import Image as PILImage from PIL import Image as PILImage
import nio import nio
import pyotherside
from nio.api import ResizingMethod from nio.api import ResizingMethod
from . import pyotherside, utils from . import utils
from .pyotherside import ImageData, Size
POSFormat = int POSFormat = int
Size = Tuple[int, int]
ImageData = Tuple[bytearray, Size, int] # last int: pyotherside format enum
CONCURRENT_DOWNLOADS_LIMIT = asyncio.BoundedSemaphore(8) CONCURRENT_DOWNLOADS_LIMIT = asyncio.BoundedSemaphore(8)

View File

@ -1,27 +0,0 @@
import logging as log
from typing import Tuple, Callable
AVAILABLE = True
try:
import pyotherside
except ModuleNotFoundError:
log.warning("pyotherside module is unavailable.")
AVAILABLE = False
Size = Tuple[int, int]
ImageData = Tuple[bytearray, Size, int] # last int: pyotherside format enum
format_data: int = pyotherside.format_data if AVAILABLE else 0
format_svg_data: int = pyotherside.format_svg_data if AVAILABLE else 1
format_rgb888: int = pyotherside.format_rgb888 if AVAILABLE else 2
format_argb32: int = pyotherside.format_argb32 if AVAILABLE else 3
def send(event: str, *args) -> None:
if AVAILABLE:
pyotherside.send(event, *args)
def set_image_provider(provider: Callable[[str, Size], ImageData]) -> None:
if AVAILABLE:
pyotherside.set_image_provider(provider)

View File

@ -2,7 +2,8 @@ from dataclasses import dataclass, field
from enum import Enum from enum import Enum
from typing import Any, Dict, List, Union from typing import Any, Dict, List, Union
from . import pyotherside import pyotherside
from .models import SyncId from .models import SyncId