Skip to content

Commit d70de5c

Browse files
committed
Update 2.0.0
1 parent 8c0dcae commit d70de5c

File tree

5 files changed

+24
-59
lines changed

5 files changed

+24
-59
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# Installation
22
```cmd
3-
pip install https://github.com/RCR-OOP/pydustry.py/releases/download/v2.0/pydustry.py-2.0_release-py3-none-any.whl
3+
pip install -U pydustry.py
44
```
55

66
# Example
77
- `main.py`
88
```python
99
import pydustry
1010

11-
pydustry.Server("easyplay.su").get_status()
11+
status = pydustry.Server("easyplay.su").get_status()
12+
13+
print(status)
1214
```
1315

1416
- `Return`

pydustry/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
11
from .pydustry import Server, Status
2-
3-
__name__ = 'pydustry.py'
4-
__version__ = '2.0.0'
5-
__keywords__ = ['pydustry.py']

pydustry/pydustry.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
from socket import socket, create_connection, AF_INET, SOCK_DGRAM
2-
from struct import unpack
31
from time import time
2+
from struct import unpack
43
from dataclasses import dataclass
4+
from socket import socket, create_connection, AF_INET, SOCK_DGRAM
55
from typing import Tuple
66

7-
# * Dataclass
87
@dataclass
98
class Status:
109
name: str
@@ -15,7 +14,6 @@ class Status:
1514
vertype: str
1615
ping: float
1716

18-
# * Главный класс
1917
class Server:
2018
def __init__(
2119
self,
@@ -27,20 +25,14 @@ def __init__(
2725
self.input_server: Tuple[str, int] = (server_host, input_port)
2826

2927
def get_status(self, timeout: float=10.0) -> Status:
30-
# * Инициализация сервера
3128
s = socket(AF_INET, SOCK_DGRAM)
3229
s.connect(self.server)
3330
s.settimeout(timeout)
34-
35-
# * Создание и так понятно чего для чего
3631
info = {}
37-
38-
# * Получение данных и замер
3932
s_time = time()
4033
s.send(b"\xfe\x01")
4134
data = s.recv(1024)
4235
e_time = time()
43-
4436
# * Парсинг
4537
info["name"] = data[1:data[0]+1].decode("utf-8")
4638
data = data[data[0]+1:]
@@ -54,28 +46,19 @@ def get_status(self, timeout: float=10.0) -> Status:
5446
data = data[4:]
5547
info["vertype"] = data[1:data[0]+1].decode("utf-8")
5648
info["ping"] = round((e_time - s_time) * 1000)
57-
5849
return Status(**info)
5950

6051
def send_command(self, command: str) -> None:
6152
s = create_connection(self.input_server)
62-
s.sendall(
63-
bytes(
64-
command.encode(errors="ignore")
65-
)
66-
)
53+
s.sendall(command.encode(errors="ignore"))
6754
s.close()
6855

6956
def ping(self, timeout: float=10.0) -> int:
70-
# * Инициализация сервера
7157
s = socket(AF_INET, SOCK_DGRAM)
7258
s.connect(self.server)
7359
s.settimeout(timeout)
74-
75-
# * Получение данных и замер
7660
s_time = time()
7761
s.send(b"\xfe\x01")
7862
s.recv(1024)
7963
e_time = time()
80-
8164
return round((e_time - s_time) * 1000)

pyproject.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[tool.poetry]
2+
name = "pydustry.py"
3+
version = "2.0.1"
4+
description = "Module for server information in the game Mindustry."
5+
authors = ["Romanin <[email protected]>"]
6+
license = "MIT"
7+
readme = "README.md"
8+
packages = [{include = "pydustry"}]
9+
keywords = ["midnustry", "game", "server", "parser", "infomation"]
10+
11+
[tool.poetry.dependencies]
12+
python = "^3.9"
13+
14+
15+
[build-system]
16+
requires = ["poetry-core"]
17+
build-backend = "poetry.core.masonry.api"

setup.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)