This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import platform | |
import subprocess | |
from typing import Dict, Iterable, List, Union | |
Windows = """wmic path CIM_LogicalDevice where "Description like 'USB Video%'" get /value""" | |
Darwin = "system_profiler SPCameraDataType" | |
Linux = "v4l2-ctl --list-devices" | |
def list_splitter(original_list: List[str], delimiter: str) -> List[List[str]]: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
pip install fastapi uvicorn aiofiles jinja2 | |
uvicorn video:app --reload | |
""" | |
import mimetypes | |
import logging | |
import os | |
import pathlib | |
from fastapi import FastAPI, Request, Response, Header |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
import logging | |
import random | |
from typing import Callable, Any | |
logging.root.setLevel(level=logging.DEBUG) | |
def retry(attempts: int = 3, exclude_exc=None) -> Callable: | |
"""Calls child func recursively. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mimetypes | |
import os | |
import wave | |
from threading import Thread | |
from typing import NoReturn, Union | |
import pyaudio | |
class PlayAudio(Thread): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install requests pandas lxml | |
import logging | |
import socket | |
from typing import Iterable, Optional, Union, Any | |
import pandas | |
import requests | |
from pandas import DataFrame | |
SOURCE = "http://{NETWORK_ID}.254/cgi-bin/devices.ha" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
import time | |
from threading import Thread | |
from typing import Union, Callable, NoReturn | |
def timeout(duration: Union[float, int]) -> Callable: | |
"""Timeout handler for Windows OS. | |
Args: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import multiprocessing | |
import time | |
from typing import Callable, Union | |
class TimeoutHandler: | |
"""Initiates TimeoutHandler object to run a function and terminate it after a given time limit. | |
>>> TimeoutHandler |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import signal | |
import time | |
from contextlib import contextmanager | |
from types import FrameType | |
from typing import Union, NoReturn | |
@contextmanager | |
def timeout(duration: Union[int, float]) -> NoReturn: | |
"""Creates a timeout handler. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import inspect | |
import os | |
from datetime import datetime | |
from typing import Any | |
class Format: | |
"""Initiates Format object to define variables that print the message in a certain format. | |
>>> Format |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import logging | |
import os | |
import shutil | |
import subprocess | |
logger = logging.getLogger(__name__) | |
logger.addHandler(hdlr=logging.StreamHandler()) | |
logger.setLevel(level=logging.DEBUG) |