diff --git a/main.py b/main.py index 05e5602..6594364 100644 --- a/main.py +++ b/main.py @@ -8,8 +8,8 @@ import os from PIL import Image -from client import PlaceClient -from constants import Environment +from place.client import PlaceClient +from place.constants import Environment # Start a websocket @@ -34,9 +34,11 @@ async def main(): client.current_target = original_image asyncio.create_task(client.receive()) - # await asyncio.sleep(2) - await client.complete(5) - + await asyncio.sleep(0.8) + async with client.lock(): + client.source.save("./x.png") + client.current_target.save("./target.png") + await client.complete(1) print('Complete.') return diff --git a/client.py b/place/client.py similarity index 94% rename from client.py rename to place/client.py index 363ab93..dc60f8a 100644 --- a/client.py +++ b/place/client.py @@ -6,10 +6,10 @@ from typing import Optional, List, Union import websockets from PIL import Image -from constants import Environment -from differencing import get_pixel_differences -from network import upload_pixels -from pixel_types import Pixel +from place.constants import Environment +from place.differencing import get_pixel_differences +from place.network import upload_pixels +from place.pixel_types import Pixel width, height = int(os.getenv(Environment.CANVAS_HEIGHT)), int(os.getenv(Environment.CANVAS_HEIGHT)) total_pixels = width * height diff --git a/constants.py b/place/constants.py similarity index 100% rename from constants.py rename to place/constants.py diff --git a/differencing.py b/place/differencing.py similarity index 92% rename from differencing.py rename to place/differencing.py index a0a69c0..141fd09 100644 --- a/differencing.py +++ b/place/differencing.py @@ -3,8 +3,8 @@ from typing import List, Union from PIL import Image -from constants import Environment -from pixel_types import Pixel, AlphaPixel +from place.constants import Environment +from place.pixel_types import Pixel, AlphaPixel def is_pixel_equal(a: Union[Pixel, AlphaPixel], b: Union[Pixel, AlphaPixel]) -> bool: diff --git a/network.py b/place/network.py similarity index 98% rename from network.py rename to place/network.py index 3b13e3f..539debb 100644 --- a/network.py +++ b/place/network.py @@ -2,7 +2,7 @@ from typing import Generator, Any, List, Tuple from multiping import multi_ping from progressbar import progressbar -from pixel_types import Pixel +from place.pixel_types import Pixel # The largest possible chunk that can be given to Multiping maximum_chunk = (2 ** 16) - 1 diff --git a/pixel_types.py b/place/pixel_types.py similarity index 100% rename from pixel_types.py rename to place/pixel_types.py