mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-30 19:18:13 +08:00
Make blessed optional (#20)
This commit is contained in:
@@ -195,6 +195,7 @@ Testing
|
||||
Running tests is easy with docker compose, it will also start the necessary databases. Just run:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
docker-compose -f test-services-docker-compose.yaml run --rm django-q2 poetry run pytest
|
||||
|
||||
Locale
|
||||
|
||||
+23
-6
@@ -1,8 +1,5 @@
|
||||
from datetime import timedelta
|
||||
|
||||
# external
|
||||
from blessed import Terminal
|
||||
|
||||
# django
|
||||
from django.db import connection
|
||||
from django.db.models import F, Sum
|
||||
@@ -22,6 +19,11 @@ try:
|
||||
except ImportError:
|
||||
psutil = None
|
||||
|
||||
# optional
|
||||
try:
|
||||
from blessed import Terminal
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
def get_process_mb(pid):
|
||||
try:
|
||||
@@ -31,11 +33,17 @@ def get_process_mb(pid):
|
||||
mb_used = "NO_PROCESS_FOUND"
|
||||
return mb_used
|
||||
|
||||
BLESSED_INSTALL_MESSAGE = "Blessed is not installed. Please install blessed to use this: https://pypi.org/project/blessed/"
|
||||
|
||||
def monitor(run_once=False, broker=None):
|
||||
if not broker:
|
||||
broker = get_broker()
|
||||
term = Terminal()
|
||||
try:
|
||||
term = Terminal()
|
||||
except:
|
||||
print(BLESSED_INSTALL_MESSAGE)
|
||||
return
|
||||
|
||||
broker.ping()
|
||||
with term.fullscreen(), term.hidden_cursor(), term.cbreak():
|
||||
val = None
|
||||
@@ -195,7 +203,12 @@ def monitor(run_once=False, broker=None):
|
||||
def info(broker=None):
|
||||
if not broker:
|
||||
broker = get_broker()
|
||||
term = Terminal()
|
||||
try:
|
||||
term = Terminal()
|
||||
except:
|
||||
print(BLESSED_INSTALL_MESSAGE)
|
||||
return
|
||||
|
||||
broker.ping()
|
||||
stat = Stat.get_all(broker=broker)
|
||||
# general stats
|
||||
@@ -294,7 +307,11 @@ def info(broker=None):
|
||||
def memory(run_once=False, workers=False, broker=None):
|
||||
if not broker:
|
||||
broker = get_broker()
|
||||
term = Terminal()
|
||||
try:
|
||||
term = Terminal()
|
||||
except:
|
||||
print(BLESSED_INSTALL_MESSAGE)
|
||||
return
|
||||
broker.ping()
|
||||
if not psutil:
|
||||
print(term.clear_eos())
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ author = 'Ilan Steemers, Stan Triepels'
|
||||
# The short X.Y version.
|
||||
version = '1.3'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '1.3.9'
|
||||
release = '1.4.0'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
||||
@@ -2,6 +2,11 @@ Monitor
|
||||
=======
|
||||
.. py:currentmodule::django_q.monitor
|
||||
|
||||
|
||||
.. warning::
|
||||
|
||||
Blessed needs to be installed to get this to work! See: https://pypi.org/project/blessed/
|
||||
|
||||
The cluster monitor shows live information about all the Q clusters connected to your project.
|
||||
|
||||
Start the monitor with Django's `manage.py` command::
|
||||
|
||||
Generated
+17
-17
@@ -11,7 +11,7 @@ name = "ansicon"
|
||||
version = "1.89.0"
|
||||
description = "Python wrapper for loading Jason Hood's ANSICON"
|
||||
category = "main"
|
||||
optional = false
|
||||
optional = true
|
||||
python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
@@ -96,7 +96,7 @@ name = "blessed"
|
||||
version = "1.19.1"
|
||||
description = "Easy, practical library for making terminal apps, by providing an elegant, well-documented interface to Colors, Keyboard input, and screen Positioning capabilities."
|
||||
category = "main"
|
||||
optional = false
|
||||
optional = true
|
||||
python-versions = ">=2.7"
|
||||
|
||||
[package.dependencies]
|
||||
@@ -106,14 +106,14 @@ wcwidth = ">=0.1.4"
|
||||
|
||||
[[package]]
|
||||
name = "boto3"
|
||||
version = "1.24.93"
|
||||
version = "1.24.94"
|
||||
description = "The AWS SDK for Python"
|
||||
category = "main"
|
||||
optional = true
|
||||
python-versions = ">= 3.7"
|
||||
|
||||
[package.dependencies]
|
||||
botocore = ">=1.27.93,<1.28.0"
|
||||
botocore = ">=1.27.94,<1.28.0"
|
||||
jmespath = ">=0.7.1,<2.0.0"
|
||||
s3transfer = ">=0.6.0,<0.7.0"
|
||||
|
||||
@@ -122,7 +122,7 @@ crt = ["botocore[crt] (>=1.21.0,<2.0a0)"]
|
||||
|
||||
[[package]]
|
||||
name = "botocore"
|
||||
version = "1.27.93"
|
||||
version = "1.27.94"
|
||||
description = "Low-level, data-driven core of boto 3."
|
||||
category = "main"
|
||||
optional = true
|
||||
@@ -422,7 +422,7 @@ name = "jinxed"
|
||||
version = "1.2.0"
|
||||
description = "Jinxed Terminal Library"
|
||||
category = "main"
|
||||
optional = false
|
||||
optional = true
|
||||
python-versions = "*"
|
||||
|
||||
[package.dependencies]
|
||||
@@ -718,7 +718,7 @@ crt = ["botocore[crt] (>=1.20.29,<2.0a.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "sentry-sdk"
|
||||
version = "1.9.10"
|
||||
version = "1.10.0"
|
||||
description = "Python client for Sentry (https://sentry.io)"
|
||||
category = "main"
|
||||
optional = true
|
||||
@@ -753,7 +753,7 @@ name = "six"
|
||||
version = "1.16.0"
|
||||
description = "Python 2 and 3 compatibility utilities"
|
||||
category = "main"
|
||||
optional = false
|
||||
optional = true
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
|
||||
|
||||
[[package]]
|
||||
@@ -917,7 +917,7 @@ name = "wcwidth"
|
||||
version = "0.2.5"
|
||||
description = "Measures the displayed width of unicode strings in a terminal"
|
||||
category = "main"
|
||||
optional = false
|
||||
optional = true
|
||||
python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
@@ -956,12 +956,12 @@ build-backend = []
|
||||
requires = []
|
||||
rollbar = ["django-q-rollbar"]
|
||||
sentry = ["django-q-sentry"]
|
||||
testing = ["django-redis", "croniter", "hiredis", "psutil", "iron-mq", "boto3", "pymongo"]
|
||||
testing = ["django-redis", "croniter", "hiredis", "psutil", "iron-mq", "boto3", "pymongo", "blessed"]
|
||||
|
||||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = ">=3.8.14, <4"
|
||||
content-hash = "3164c7b86a93925523372abdfa8f2a88f5dbda725bd0576c0bf429de06a631db"
|
||||
content-hash = "ac947d27d316a58fe8f86837360e1328a6771fa740f93841d610e26b85ce859a"
|
||||
|
||||
[metadata.files]
|
||||
alabaster = [
|
||||
@@ -1034,12 +1034,12 @@ blessed = [
|
||||
{file = "blessed-1.19.1.tar.gz", hash = "sha256:9a0d099695bf621d4680dd6c73f6ad547f6a3442fbdbe80c4b1daa1edbc492fc"},
|
||||
]
|
||||
boto3 = [
|
||||
{file = "boto3-1.24.93-py3-none-any.whl", hash = "sha256:db9f04eeb942e7998d1971c35e1658e2d9d6687166a4ebc036f484a71a79bbeb"},
|
||||
{file = "boto3-1.24.93.tar.gz", hash = "sha256:7881fc380f2f489ae9b3a2f2448334aef9f7be58d85a7a0e8c10458247b09afa"},
|
||||
{file = "boto3-1.24.94-py3-none-any.whl", hash = "sha256:f13db0beb3c9fe2cc1ed0f031189f144610d2909b5874a616e77b0bd1ae3b686"},
|
||||
{file = "boto3-1.24.94.tar.gz", hash = "sha256:f4842b395d1580454756622069f4ca0408993885ecede967001d2c101201cdfa"},
|
||||
]
|
||||
botocore = [
|
||||
{file = "botocore-1.27.93-py3-none-any.whl", hash = "sha256:7648891692c3c69038eef902f8d64af59f91211f713fe9072fb83ecdd310dbbc"},
|
||||
{file = "botocore-1.27.93.tar.gz", hash = "sha256:d5200f7b9150cdb91c9d3994980870d7bb4554e19c4d9d847f64626d8ceacf95"},
|
||||
{file = "botocore-1.27.94-py3-none-any.whl", hash = "sha256:8237c070d2ab29fac4fbcfe9dd2e84e0ee147402e0fed3ac1629f92459c7f1d2"},
|
||||
{file = "botocore-1.27.94.tar.gz", hash = "sha256:572224608a0b7662966fc303b768e2eba61bf53bdbf314481cd9e63a0d8e1a66"},
|
||||
]
|
||||
certifi = [
|
||||
{file = "certifi-2022.9.24-py3-none-any.whl", hash = "sha256:90c1a32f1d68f940488354e36370f6cca89f0f106db09518524c88d6ed83f382"},
|
||||
@@ -1465,8 +1465,8 @@ s3transfer = [
|
||||
{file = "s3transfer-0.6.0.tar.gz", hash = "sha256:2ed07d3866f523cc561bf4a00fc5535827981b117dd7876f036b0c1aca42c947"},
|
||||
]
|
||||
sentry-sdk = [
|
||||
{file = "sentry-sdk-1.9.10.tar.gz", hash = "sha256:4fbace9a763285b608c06f01a807b51acb35f6059da6a01236654e08b0ee81ff"},
|
||||
{file = "sentry_sdk-1.9.10-py2.py3-none-any.whl", hash = "sha256:2469240f6190aaebcb453033519eae69cfe8cc602065b4667e18ee14fc1e35dc"},
|
||||
{file = "sentry-sdk-1.10.0.tar.gz", hash = "sha256:1b965bcdbfe52321bb1307c7c93c74035afdbfceb5f585f01a963327c5befc4e"},
|
||||
{file = "sentry_sdk-1.10.0-py2.py3-none-any.whl", hash = "sha256:8c648e96e0e2ec5e17ca75a28c442e2f523453fa7cf761ec093f4a656153490e"},
|
||||
]
|
||||
six = [
|
||||
{file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
|
||||
|
||||
+2
-2
@@ -46,9 +46,9 @@ include = ['CHANGELOG.md']
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.8.14, <4"
|
||||
django = ">=3.2"
|
||||
blessed = "^1.19.1"
|
||||
django-picklefield = "^3.1"
|
||||
|
||||
blessed = { version = "^1.19.1", optional = true }
|
||||
hiredis = { version = "^2.0.0", optional = true }
|
||||
redis = { version = "^4.3.4", optional = true }
|
||||
psutil = { version = "^5.9.2", optional = true }
|
||||
@@ -72,7 +72,7 @@ isort = {extras = ["requirements_deprecated_finder"], version = "^5.10.1"}
|
||||
[tool.poetry.extras]
|
||||
requires = ["poetry_core>=1.0.0"]
|
||||
build-backend = ["poetry.core.masonry.api"]
|
||||
testing = ["django-redis", "croniter", "hiredis", "psutil", "iron-mq", "boto3", "pymongo"]
|
||||
testing = ["django-redis", "croniter", "hiredis", "psutil", "iron-mq", "boto3", "pymongo", "blessed"]
|
||||
rollbar = ["django-q-rollbar"]
|
||||
sentry = ["django-q-sentry"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user