mirror of
https://github.com/Dinnerbone/mcstatus.git
synced 2026-04-06 03:51:23 +08:00
@@ -3,8 +3,6 @@ import json
|
|||||||
import random
|
import random
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from six import string_types
|
|
||||||
|
|
||||||
from mcstatus.protocol.connection import Connection
|
from mcstatus.protocol.connection import Connection
|
||||||
|
|
||||||
COLOR_MAP = {
|
COLOR_MAP = {
|
||||||
@@ -89,8 +87,7 @@ class ServerPinger:
|
|||||||
)
|
)
|
||||||
|
|
||||||
delta = received - sent
|
delta = received - sent
|
||||||
# We have no trivial way of getting a time delta :(
|
return delta.total_seconds() * 1000
|
||||||
return (delta.days * 24 * 60 * 60 + delta.seconds) * 1000 + delta.microseconds / 1000.0
|
|
||||||
|
|
||||||
|
|
||||||
class AsyncServerPinger(ServerPinger):
|
class AsyncServerPinger(ServerPinger):
|
||||||
@@ -129,8 +126,7 @@ class AsyncServerPinger(ServerPinger):
|
|||||||
)
|
)
|
||||||
|
|
||||||
delta = received - sent
|
delta = received - sent
|
||||||
# We have no trivial way of getting a time delta :(
|
return delta.total_seconds() * 1000
|
||||||
return (delta.days * 24 * 60 * 60 + delta.seconds) * 1000 + delta.microseconds / 1000.0
|
|
||||||
|
|
||||||
|
|
||||||
class PingResponse:
|
class PingResponse:
|
||||||
@@ -147,13 +143,13 @@ class PingResponse:
|
|||||||
|
|
||||||
if "name" not in raw:
|
if "name" not in raw:
|
||||||
raise ValueError("Invalid player object (no 'name' value)")
|
raise ValueError("Invalid player object (no 'name' value)")
|
||||||
if not isinstance(raw["name"], string_types):
|
if not isinstance(raw["name"], str):
|
||||||
raise ValueError(f"Invalid player object (expected 'name' to be str, was {type(raw['name'])}")
|
raise ValueError(f"Invalid player object (expected 'name' to be str, was {type(raw['name'])}")
|
||||||
self.name = raw["name"]
|
self.name = raw["name"]
|
||||||
|
|
||||||
if "id" not in raw:
|
if "id" not in raw:
|
||||||
raise ValueError("Invalid player object (no 'id' value)")
|
raise ValueError("Invalid player object (no 'id' value)")
|
||||||
if not isinstance(raw["id"], string_types):
|
if not isinstance(raw["id"], str):
|
||||||
raise ValueError(f"Invalid player object (expected 'id' to be str, was {type(raw['id'])}")
|
raise ValueError(f"Invalid player object (expected 'id' to be str, was {type(raw['id'])}")
|
||||||
self.id = raw["id"]
|
self.id = raw["id"]
|
||||||
|
|
||||||
@@ -194,7 +190,7 @@ class PingResponse:
|
|||||||
|
|
||||||
if "name" not in raw:
|
if "name" not in raw:
|
||||||
raise ValueError("Invalid version object (no 'name' value)")
|
raise ValueError("Invalid version object (no 'name' value)")
|
||||||
if not isinstance(raw["name"], string_types):
|
if not isinstance(raw["name"], str):
|
||||||
raise ValueError(f"Invalid version object (expected 'name' to be str, was {type(raw['name'])})")
|
raise ValueError(f"Invalid version object (expected 'name' to be str, was {type(raw['name'])})")
|
||||||
self.name = raw["name"]
|
self.name = raw["name"]
|
||||||
|
|
||||||
|
|||||||
10
poetry.lock
generated
10
poetry.lock
generated
@@ -593,9 +593,9 @@ jeepney = ">=0.6"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "six"
|
name = "six"
|
||||||
version = "1.14.0"
|
version = "1.16.0"
|
||||||
description = "Python 2 and 3 compatibility utilities"
|
description = "Python 2 and 3 compatibility utilities"
|
||||||
category = "main"
|
category = "dev"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
|
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
|
||||||
|
|
||||||
@@ -783,7 +783,7 @@ testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytes
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "1.1"
|
lock-version = "1.1"
|
||||||
python-versions = ">=3.7,<3.10"
|
python-versions = ">=3.7,<3.10"
|
||||||
content-hash = "0a823ccda79fa01acc56a911a3b0a63e98b6d7b45fef2c62cafbb8a2d5839464"
|
content-hash = "fd8dd8e29049e857b7edf7da5803591d4eeb416e790e6eb5a9f3c9a1222de0e4"
|
||||||
|
|
||||||
[metadata.files]
|
[metadata.files]
|
||||||
asyncio-dgram = [
|
asyncio-dgram = [
|
||||||
@@ -1144,8 +1144,8 @@ secretstorage = [
|
|||||||
{file = "SecretStorage-3.3.1.tar.gz", hash = "sha256:fd666c51a6bf200643495a04abb261f83229dcb6fd8472ec393df7ffc8b6f195"},
|
{file = "SecretStorage-3.3.1.tar.gz", hash = "sha256:fd666c51a6bf200643495a04abb261f83229dcb6fd8472ec393df7ffc8b6f195"},
|
||||||
]
|
]
|
||||||
six = [
|
six = [
|
||||||
{file = "six-1.14.0-py2.py3-none-any.whl", hash = "sha256:8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c"},
|
{file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
|
||||||
{file = "six-1.14.0.tar.gz", hash = "sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a"},
|
{file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"},
|
||||||
]
|
]
|
||||||
tabulate = [
|
tabulate = [
|
||||||
{file = "tabulate-0.8.9-py3-none-any.whl", hash = "sha256:d7c013fe7abbc5e491394e10fa845f8f32fe54f8dc60c6622c6cf482d25d47e4"},
|
{file = "tabulate-0.8.9-py3-none-any.whl", hash = "sha256:d7c013fe7abbc5e491394e10fa845f8f32fe54f8dc60c6622c6cf482d25d47e4"},
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ python = ">=3.7,<3.10"
|
|||||||
asyncio-dgram = "1.2.0"
|
asyncio-dgram = "1.2.0"
|
||||||
click = "7.1.2"
|
click = "7.1.2"
|
||||||
dnspython = "2.1.0"
|
dnspython = "2.1.0"
|
||||||
six = "1.14.0"
|
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.dev-dependencies]
|
||||||
coverage = "^6.1.1"
|
coverage = "^6.1.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user