From bb8a74cb4e4d3f6776993fb866d21b3db9340e05 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Fri, 11 Feb 2022 04:33:18 +0700 Subject: [PATCH] rmf --- driver/paste.py | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 driver/paste.py diff --git a/driver/paste.py b/driver/paste.py deleted file mode 100644 index 4f8671d..0000000 --- a/driver/paste.py +++ /dev/null @@ -1,42 +0,0 @@ -import socket -import asyncio - -from functools import partial -from asyncio import get_running_loop - -from driver.core import aiohttpsession as session - - -def _netcat(host, port, content): - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.connect((host, port)) - s.sendall(content.encode()) - s.shutdown(socket.SHUT_WR) - while True: - data = s.recv(4096).decode("utf-8").strip("\n\x00") - if not data: - break - return data - s.close() - - -async def paste_queue(content): - loop = get_running_loop() - link = await loop.run_in_executor( - None, partial(_netcat, "ezup.dev", 9999, content) - ) - return link - - -async def isPreviewUp(preview: str) -> bool: - for _ in range(7): - try: - async with session.head(preview, timeout=2) as resp: - status, size = resp.status, resp.content_length - except asyncio.exceptions.TimeoutError: - return False - if status == 404 or (status == 200 and size == 0): - await asyncio.sleep(0.4) - else: - return True if status == 200 else False - return False