This repository has been archived by the owner on Jul 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add rcon.py * Skip doctest from example in rcon.py * Fix ImportError raised by Django when generating docs * Add forgotten __init__.py file in /lib * Synchronise pyproject.toml and docs/requirements.txt * Remove __slots__ from rcon.py * Upgrade RCON system
- Loading branch information
1 parent
493551e
commit 179a6a5
Showing
6 changed files
with
155 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"""Module for manage RCON connection.""" | ||
|
||
from mcrcon_ipv6 import MCRcon | ||
from django.conf import settings | ||
from autodonate.lib.utils.logger import get_logger | ||
|
||
connection: MCRcon = MCRcon( | ||
settings.CONFIG["RCON_HOST"], | ||
settings.CONFIG["RCON_PASSWORD"], | ||
settings.CONFIG.get("RCON_PORT", 25575), | ||
) | ||
log = get_logger(__name__) | ||
|
||
|
||
class Rcon: | ||
"""Class for manage RCON connection. | ||
Example: | ||
In[1]: Rcon.run("whitelist add Bob") | ||
Out[2]: 'Added Bob to whitelist' | ||
""" | ||
|
||
@staticmethod | ||
def run(command: str) -> str: | ||
"""Run command in RCON. | ||
Args: | ||
command: Command which to run. | ||
Returns: | ||
Server answer. | ||
""" | ||
global connection | ||
|
||
# noinspection PyBroadException | ||
try: | ||
return str(connection.command(command)) | ||
except Exception: | ||
try: | ||
connection.connect() | ||
except Exception as exc: | ||
log.warning("RCON connection unavailable! Is server offline?") | ||
raise exc | ||
return str(connection.command(command)) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
SECRET_KEY = "supersecretrandomstring" | ||
SECRET_KEY = "Sup3rsecr33tranDomstr1ng" | ||
DEBUG = true | ||
ALLOWED_HOSTS = ["host1.ru", "host2.com", "*.something.info"] | ||
|
||
# RCON settings | ||
RCON_HOST = "localhost" | ||
RCON_PASSWORD = "Sup3rsecr33tranDomstr1ng" | ||
RCON_PORT = 25575 # optional | ||
|
||
# Change this to your db config or path | ||
DATABASE = {"ENGINE" = "django.db.backends.sqlite3", "NAME" = "db.sqlite3"} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
# This file is used to setup env | ||
# to generate documentation. | ||
|
||
sphinx==4.4.0 | ||
sphinx-autodoc-typehints==1.17.0 | ||
sphinx>=4.4.0,<4.5.0 | ||
sphinx-autodoc-typehints>=1.17.0,<1.18.0 | ||
sphinxcontrib-apidoc>=0.3.0 | ||
furo>=2022.1.2 | ||
m2r2==0.3.2 | ||
tomlkit==0.9.2 | ||
toml==0.10.2 | ||
m2r2>=0.3.0,<0.4.0 | ||
tomlkit>=0.10.0,<0.11.0 | ||
|
||
# Dependencies of our project: | ||
Django>=3.2.12,<5.0.0 | ||
Django>=4.0.2,<4.1.0 | ||
requests>=2.27.1 | ||
toml>=0.10.2,<0.11.0 | ||
mcrcon-ipv6>=0.1.2 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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