def __init__(self, epochs=2000, *, cuda: bool or int or str = False, work_dir='.', verbose=True, describe=None): self._epochs = epochs if isinstance(cuda, bool): self._device = torch.device('cuda') if cuda else torch.device( 'cpu') elif isinstance(cuda, int): self._device = torch.device('cuda', cuda) else: self._device = torch.device(cuda) if not Path(work_dir).exists(): Path(work_dir).mkdir() self._verbose = verbose self._work_dir = work_dir self._model = None self._model_name = None self._checker = None self._logs = [] self._describe = describe or dict(python=py_ver, system=sys_ver(), numpy=np.__version__, torch=torch.__version__, xenonpy=__version__, workspace=work_dir)
def before_proc(self, trainer: Trainer) -> None: self._checker = Checker(self._path, increment=self._increment) if self._model_class is not None: self._checker(model_class=self._model_class) if self._model_params is not None: self._checker(model_params=self._model_params) self._checker.model = trainer.model self._describe_ = dict( python=py_ver, system=sys_ver(), numpy=np.__version__, torch=torch.__version__, xenonpy=__version__, device=str(trainer.device), start=datetime.now().strftime('%Y/%m/%d %H:%M:%S'), finish='N/A', time_elapsed='N/A', **self._describe, ) self._checker(describe=self._describe_)
def kill(self, pid: int) -> list: if sys_ver() == 'Windows': return f'taskkill /PID {pid} /F'.split(' ') else: return f'kill -9 {pid}'.split(' ')
import asyncio from asyncio import create_subprocess_exec as run from asyncio.subprocess import DEVNULL from collections.abc import AsyncGenerator from platform import system as sys_ver from aiofiles import open as afile from async_timeout import timeout as ftime # OS Detect if sys_ver() == 'Windows': APP = 'wfreerdp.exe' else: APP = 'xfreerdp' class RDP_Checker: __slots__ = ('good', 'total', 'threads', 'port', 'timeout') def __init__(self): self.good = 0 self.total = 0 self.threads = int(input('Threads: ') or 1) self.port = int(input('Port: ') or 3309) self.timeout = int(input('Timeout: ') or 10) print('PWNED | TOTAL') def __stats__(self, last: bool = False) -> None: print(f'{self.good} | {self.total}', end='\n' if last else '\r')