From 075fb262cc62597b9ce8ab82e482e7f5282a91e1 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 24 Nov 2019 03:23:59 +0100 Subject: [PATCH] Add coloredlogs extra (closes #103) --- poetry.lock | 122 ++++++++++++++++-------- pyproject.toml | 11 +++ royalnet/__main__.py | 14 ++- royalnet/backpack/__init__.py | 4 +- royalnet/backpack/commands/__init__.py | 6 -- royalnet/backpack/commands/ping.py | 10 -- royalnet/backpack/commands/play.py | 26 ----- royalnet/backpack/commands/summon.py | 38 -------- royalnet/backpack/events/__init__.py | 6 +- royalnet/backpack/events/play.py | 23 ----- royalnet/backpack/events/summon.py | 57 ----------- royalnet/constellation/constellation.py | 13 ++- royalnet/herald/link.py | 2 +- royalnet/herald/package.py | 3 +- royalnet/serf/serf.py | 15 ++- 15 files changed, 134 insertions(+), 216 deletions(-) delete mode 100644 royalnet/backpack/commands/ping.py delete mode 100644 royalnet/backpack/commands/play.py delete mode 100644 royalnet/backpack/commands/summon.py delete mode 100644 royalnet/backpack/events/play.py delete mode 100644 royalnet/backpack/events/summon.py diff --git a/poetry.lock b/poetry.lock index 292e0ffa..e66aa4f4 100644 --- a/poetry.lock +++ b/poetry.lock @@ -35,6 +35,7 @@ version = "3.0.1" [[package]] category = "dev" description = "Atomic file writes." +marker = "sys_platform == \"win32\"" name = "atomicwrites" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" @@ -101,7 +102,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" version = "7.0" [[package]] -category = "dev" +category = "main" description = "Cross-platform colored terminal text." marker = "sys_platform == \"win32\"" name = "colorama" @@ -109,6 +110,21 @@ optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" version = "0.4.1" +[[package]] +category = "main" +description = "Colored terminal output for Python's logging module" +name = "coloredlogs" +optional = true +python-versions = "*" +version = "10.0" + +[package.dependencies] +colorama = "*" +humanfriendly = ">=4.7" + +[package.extras] +cron = ["capturer (>=2.4)"] + [[package]] category = "main" description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." @@ -217,6 +233,17 @@ optional = true python-versions = "*" version = "0.0.13" +[[package]] +category = "main" +description = "Human friendly output for text interfaces using Python" +name = "humanfriendly" +optional = true +python-versions = "*" +version = "4.18" + +[package.dependencies] +pyreadline = "*" + [[package]] category = "main" description = "Internationalized Domain Names in Applications (IDNA)" @@ -297,8 +324,8 @@ category = "main" description = "multidict implementation" name = "multidict" optional = true -python-versions = ">=3.4.1" -version = "4.5.2" +python-versions = ">=3.5" +version = "4.6.1" [[package]] category = "dev" @@ -318,7 +345,7 @@ description = "plugin and hook calling mechanisms for python" name = "pluggy" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -version = "0.13.0" +version = "0.13.1" [package.extras] dev = ["pre-commit", "tox"] @@ -387,13 +414,22 @@ optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" version = "2.4.5" +[[package]] +category = "main" +description = "A python implmementation of GNU readline." +marker = "sys_platform == \"win32\"" +name = "pyreadline" +optional = true +python-versions = "*" +version = "2.1" + [[package]] category = "dev" description = "pytest: simple powerful testing with Python" name = "pytest" optional = false python-versions = ">=3.5" -version = "5.2.4" +version = "5.3.0" [package.dependencies] atomicwrites = ">=1.0" @@ -755,12 +791,13 @@ description = "YouTube video downloader" name = "youtube-dl" optional = true python-versions = "*" -version = "2019.11.5" +version = "2019.11.22" [extras] alchemy_easy = ["sqlalchemy", "psycopg2_binary"] alchemy_hard = ["sqlalchemy", "psycopg2"] bard = ["ffmpeg_python", "youtube_dl"] +coloredlogs = ["coloredlogs"] constellation = ["starlette", "uvicorn"] discord = ["discord.py", "pynacl"] herald = ["websockets"] @@ -768,7 +805,7 @@ sentry = ["sentry_sdk"] telegram = ["python_telegram_bot"] [metadata] -content-hash = "6866d310062cf7618050804ea66eb8e1185dfcca55273693f83b42e6ac0fc18f" +content-hash = "ab3c90d2eb5ce9e8bfad099502bb183959ee406192d2ee159f902c2a52658614" python-versions = "^3.8" [metadata.files] @@ -867,6 +904,10 @@ colorama = [ {file = "colorama-0.4.1-py2.py3-none-any.whl", hash = "sha256:f8ac84de7840f5b9c4e3347b3c1eaa50f7e49c2b07596221daec5edaabbd7c48"}, {file = "colorama-0.4.1.tar.gz", hash = "sha256:05eed71e2e327246ad6b38c540c4a3117230b19679b875190486ddd2d721422d"}, ] +coloredlogs = [ + {file = "coloredlogs-10.0-py2.py3-none-any.whl", hash = "sha256:34fad2e342d5a559c31b6c889e8d14f97cb62c47d9a2ae7b5ed14ea10a79eff8"}, + {file = "coloredlogs-10.0.tar.gz", hash = "sha256:b869a2dda3fa88154b9dd850e27828d8755bfab5a838a1c97fbc850c6e377c36"}, +] cryptography = [ {file = "cryptography-2.8-cp27-cp27m-macosx_10_6_intel.whl", hash = "sha256:fb81c17e0ebe3358486cd8cc3ad78adbae58af12fc2bf2bc0bb84e8090fa5ce8"}, {file = "cryptography-2.8-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:44ff04138935882fef7c686878e1c8fd80a723161ad6a98da31e14b7553170c2"}, @@ -918,6 +959,10 @@ h11 = [ httptools = [ {file = "httptools-0.0.13.tar.gz", hash = "sha256:e00cbd7ba01ff748e494248183abc6e153f49181169d8a3d41bb49132ca01dfc"}, ] +humanfriendly = [ + {file = "humanfriendly-4.18-py2.py3-none-any.whl", hash = "sha256:23057b10ad6f782e7bc3a20e3cb6768ab919f619bbdc0dd75691121bbde5591d"}, + {file = "humanfriendly-4.18.tar.gz", hash = "sha256:33ee8ceb63f1db61cce8b5c800c531e1a61023ac5488ccde2ba574a85be00a85"}, +] idna = [ {file = "idna-2.8-py2.py3-none-any.whl", hash = "sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c"}, {file = "idna-2.8.tar.gz", hash = "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407"}, @@ -973,43 +1018,31 @@ more-itertools = [ {file = "more_itertools-7.2.0-py3-none-any.whl", hash = "sha256:92b8c4b06dac4f0611c0729b2f2ede52b2e1bac1ab48f089c7ddc12e26bb60c4"}, ] multidict = [ - {file = "multidict-4.5.2-cp34-cp34m-macosx_10_12_intel.macosx_10_12_x86_64.macosx_10_13_intel.macosx_10_13_x86_64.whl", hash = "sha256:068167c2d7bbeebd359665ac4fff756be5ffac9cda02375b5c5a7c4777038e73"}, - {file = "multidict-4.5.2-cp34-cp34m-macosx_10_6_intel.macosx_10_6_x86_64.macosx_10_7_intel.macosx_10_7_x86_64.macosx_10_8_intel.macosx_10_8_x86_64.whl", hash = "sha256:7c1b7eab7a49aa96f3db1f716f0113a8a2e93c7375dd3d5d21c4941f1405c9c5"}, - {file = "multidict-4.5.2-cp34-cp34m-macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.macosx_10_11_intel.macosx_10_11_x86_64.whl", hash = "sha256:8ccd1c5fff1aa1427100ce188557fc31f1e0a383ad8ec42c559aabd4ff08802d"}, - {file = "multidict-4.5.2-cp34-cp34m-manylinux1_i686.whl", hash = "sha256:6a3a9b0f45fd75dc05d8e93dc21b18fc1670135ec9544d1ad4acbcf6b86781d0"}, - {file = "multidict-4.5.2-cp34-cp34m-manylinux1_x86_64.whl", hash = "sha256:31dfa2fc323097f8ad7acd41aa38d7c614dd1960ac6681745b6da124093dc351"}, - {file = "multidict-4.5.2-cp34-cp34m-win32.whl", hash = "sha256:8e08dd76de80539d613654915a2f5196dbccc67448df291e69a88712ea21e24a"}, - {file = "multidict-4.5.2-cp34-cp34m-win_amd64.whl", hash = "sha256:d1071414dd06ca2eafa90c85a079169bfeb0e5f57fd0b45d44c092546fcd6fd9"}, - {file = "multidict-4.5.2-cp35-cp35m-macosx_10_12_intel.macosx_10_12_x86_64.macosx_10_13_intel.macosx_10_13_x86_64.whl", hash = "sha256:1d1c77013a259971a72ddaa83b9f42c80a93ff12df6a4723be99d858fa30bee3"}, - {file = "multidict-4.5.2-cp35-cp35m-macosx_10_6_intel.macosx_10_6_x86_64.macosx_10_7_intel.macosx_10_7_x86_64.macosx_10_8_intel.macosx_10_8_x86_64.whl", hash = "sha256:3d5dd8e5998fb4ace04789d1d008e2bb532de501218519d70bb672c4c5a2fc5d"}, - {file = "multidict-4.5.2-cp35-cp35m-macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.macosx_10_11_intel.macosx_10_11_x86_64.whl", hash = "sha256:7fc0eee3046041387cbace9314926aa48b681202f8897f8bff3809967a049036"}, - {file = "multidict-4.5.2-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:041e9442b11409be5e4fc8b6a97e4bcead758ab1e11768d1e69160bdde18acc3"}, - {file = "multidict-4.5.2-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:c49db89d602c24928e68c0d510f4fcf8989d77defd01c973d6cbe27e684833b1"}, - {file = "multidict-4.5.2-cp35-cp35m-win32.whl", hash = "sha256:34f82db7f80c49f38b032c5abb605c458bac997a6c3142e0d6c130be6fb2b941"}, - {file = "multidict-4.5.2-cp35-cp35m-win_amd64.whl", hash = "sha256:5de53a28f40ef3c4fd57aeab6b590c2c663de87a5af76136ced519923d3efbb3"}, - {file = "multidict-4.5.2-cp36-cp36m-macosx_10_12_intel.macosx_10_12_x86_64.macosx_10_13_intel.macosx_10_13_x86_64.whl", hash = "sha256:db603a1c235d110c860d5f39988ebc8218ee028f07a7cbc056ba6424372ca31b"}, - {file = "multidict-4.5.2-cp36-cp36m-macosx_10_6_intel.macosx_10_6_x86_64.macosx_10_7_intel.macosx_10_7_x86_64.macosx_10_8_intel.macosx_10_8_x86_64.whl", hash = "sha256:ce20044d0317649ddbb4e54dab3c1bcc7483c78c27d3f58ab3d0c7e6bc60d26a"}, - {file = "multidict-4.5.2-cp36-cp36m-macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.macosx_10_11_intel.macosx_10_11_x86_64.whl", hash = "sha256:4b843f8e1dd6a3195679d9838eb4670222e8b8d01bc36c9894d6c3538316fa0a"}, - {file = "multidict-4.5.2-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:047c0a04e382ef8bd74b0de01407e8d8632d7d1b4db6f2561106af812a68741b"}, - {file = "multidict-4.5.2-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:148ff60e0fffa2f5fad2eb25aae7bef23d8f3b8bdaf947a65cdbe84a978092bc"}, - {file = "multidict-4.5.2-cp36-cp36m-win32.whl", hash = "sha256:4b02a3b2a2f01d0490dd39321c74273fed0568568ea0e7ea23e02bd1fb10a10b"}, - {file = "multidict-4.5.2-cp36-cp36m-win_amd64.whl", hash = "sha256:d3be11ac43ab1a3e979dac80843b42226d5d3cccd3986f2e03152720a4297cd7"}, - {file = "multidict-4.5.2-cp37-cp37m-macosx_10_12_intel.macosx_10_12_x86_64.macosx_10_13_intel.macosx_10_13_x86_64.whl", hash = "sha256:1d48bc124a6b7a55006d97917f695effa9725d05abe8ee78fd60d6588b8344cd"}, - {file = "multidict-4.5.2-cp37-cp37m-macosx_10_6_intel.macosx_10_6_x86_64.macosx_10_7_intel.macosx_10_7_x86_64.macosx_10_8_intel.macosx_10_8_x86_64.whl", hash = "sha256:61b2b33ede821b94fa99ce0b09c9ece049c7067a33b279f343adfe35108a4ea7"}, - {file = "multidict-4.5.2-cp37-cp37m-macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.macosx_10_11_intel.macosx_10_11_x86_64.whl", hash = "sha256:76ad8e4c69dadbb31bad17c16baee61c0d1a4a73bed2590b741b2e1a46d3edd0"}, - {file = "multidict-4.5.2-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:7ba19b777dc00194d1b473180d4ca89a054dd18de27d0ee2e42a103ec9b7d014"}, - {file = "multidict-4.5.2-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:c18498c50c59263841862ea0501da9f2b3659c00db54abfbf823a80787fde8ce"}, - {file = "multidict-4.5.2-cp37-cp37m-win32.whl", hash = "sha256:045b4dd0e5f6121e6f314d81759abd2c257db4634260abcfe0d3f7083c4908ef"}, - {file = "multidict-4.5.2-cp37-cp37m-win_amd64.whl", hash = "sha256:4a6ae52bd3ee41ee0f3acf4c60ceb3f44e0e3bc52ab7da1c2b2aa6703363a3d1"}, - {file = "multidict-4.5.2.tar.gz", hash = "sha256:024b8129695a952ebd93373e45b5d341dbb87c17ce49637b34000093f243dd4f"}, + {file = "multidict-4.6.1-cp35-cp35m-macosx_10_13_x86_64.whl", hash = "sha256:318aadf1cfb6741c555c7dd83d94f746dc95989f4f106b25b8a83dfb547f2756"}, + {file = "multidict-4.6.1-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:9c890978e2b37dd0dc1bd952da9a5d9f245d4807bee33e3517e4119c48d66f8c"}, + {file = "multidict-4.6.1-cp35-cp35m-win32.whl", hash = "sha256:efaf1b18ea6c1f577b1371c0159edbe4749558bfe983e13aa24d0a0c01e1ad7b"}, + {file = "multidict-4.6.1-cp35-cp35m-win_amd64.whl", hash = "sha256:07f9a6bf75ad675d53956b2c6a2d4ef2fa63132f33ecc99e9c24cf93beb0d10b"}, + {file = "multidict-4.6.1-cp36-cp36m-macosx_10_13_x86_64.whl", hash = "sha256:42cdd649741a14b0602bf15985cad0dd4696a380081a3319cd1ead46fd0f0fab"}, + {file = "multidict-4.6.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:205a011e636d885af6dd0029e41e3514a46e05bb2a43251a619a6e8348b96fc0"}, + {file = "multidict-4.6.1-cp36-cp36m-win32.whl", hash = "sha256:cfec9d001a83dc73580143f3c77e898cf7ad78b27bb5e64dbe9652668fcafec7"}, + {file = "multidict-4.6.1-cp36-cp36m-win_amd64.whl", hash = "sha256:8d919034420378132d074bf89df148d0193e9780c9fe7c0e495e895b8af4d8a2"}, + {file = "multidict-4.6.1-cp37-cp37m-macosx_10_13_x86_64.whl", hash = "sha256:a37433ce8cdb35fc9e6e47e1606fa1bfd6d70440879038dca7d8dd023197eaa9"}, + {file = "multidict-4.6.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:1b605272c558e4c659dbaf0fb32a53bfede44121bcf77b356e6e906867b958b7"}, + {file = "multidict-4.6.1-cp37-cp37m-win32.whl", hash = "sha256:891b7e142885e17a894d9d22b0349b92bb2da4769b4e675665d0331c08719be5"}, + {file = "multidict-4.6.1-cp37-cp37m-win_amd64.whl", hash = "sha256:250632316295f2311e1ed43e6b26a63b0216b866b45c11441886ac1543ca96e1"}, + {file = "multidict-4.6.1-cp38-cp38-macosx_10_13_x86_64.whl", hash = "sha256:2bc9c2579312c68a3552ee816311c8da76412e6f6a9cf33b15152e385a572d2a"}, + {file = "multidict-4.6.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:0ffe4d4d28cbe9801952bfb52a8095dd9ffecebd93f84bdf973c76300de783c5"}, + {file = "multidict-4.6.1-cp38-cp38-win32.whl", hash = "sha256:87e26d8b89127c25659e962c61a4c655ec7445d19150daea0759516884ecb8b4"}, + {file = "multidict-4.6.1-cp38-cp38-win_amd64.whl", hash = "sha256:c626029841ada34c030b94a00c573a0c7575fe66489cde148785b6535397d675"}, + {file = "multidict-4.6.1.tar.gz", hash = "sha256:5159c4975931a1a78bf6602bbebaa366747fce0a56cb2111f44789d2c45e379f"}, ] packaging = [ {file = "packaging-19.2-py2.py3-none-any.whl", hash = "sha256:d9551545c6d761f3def1677baf08ab2a3ca17c56879e70fecba2fc4dde4ed108"}, {file = "packaging-19.2.tar.gz", hash = "sha256:28b924174df7a2fa32c1953825ff29c61e2f5e082343165438812f00d3a7fc47"}, ] pluggy = [ - {file = "pluggy-0.13.0-py2.py3-none-any.whl", hash = "sha256:0db4b7601aae1d35b4a033282da476845aa19185c1e6964b25cf324b5e4ec3e6"}, - {file = "pluggy-0.13.0.tar.gz", hash = "sha256:fa5fa1622fa6dd5c030e9cad086fa19ef6a0cf6d7a2d12318e10cb49d6d68f34"}, + {file = "pluggy-0.13.1-py2.py3-none-any.whl", hash = "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d"}, + {file = "pluggy-0.13.1.tar.gz", hash = "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0"}, ] psycopg2 = [ {file = "psycopg2-2.8.4-cp27-cp27m-win32.whl", hash = "sha256:72772181d9bad1fa349792a1e7384dde56742c14af2b9986013eb94a240f005b"}, @@ -1098,9 +1131,14 @@ pyparsing = [ {file = "pyparsing-2.4.5-py2.py3-none-any.whl", hash = "sha256:20f995ecd72f2a1f4bf6b072b63b22e2eb457836601e76d6e5dfcd75436acc1f"}, {file = "pyparsing-2.4.5.tar.gz", hash = "sha256:4ca62001be367f01bd3e92ecbb79070272a9d4964dce6a48a82ff0b8bc7e683a"}, ] +pyreadline = [ + {file = "pyreadline-2.1.win-amd64.exe", hash = "sha256:9ce5fa65b8992dfa373bddc5b6e0864ead8f291c94fbfec05fbd5c836162e67b"}, + {file = "pyreadline-2.1.win32.exe", hash = "sha256:65540c21bfe14405a3a77e4c085ecfce88724743a4ead47c66b84defcf82c32e"}, + {file = "pyreadline-2.1.zip", hash = "sha256:4530592fc2e85b25b1a9f79664433da09237c1a270e4d78ea5aa3a2c7229e2d1"}, +] pytest = [ - {file = "pytest-5.2.4-py3-none-any.whl", hash = "sha256:8e256fe71eb74e14a4d20a5987bb5e1488f0511ee800680aaedc62b9358714e8"}, - {file = "pytest-5.2.4.tar.gz", hash = "sha256:ff0090819f669aaa0284d0f4aad1a6d9d67a6efdc6dd4eb4ac56b704f890a0d6"}, + {file = "pytest-5.3.0-py3-none-any.whl", hash = "sha256:f6a567e20c04259d41adce9a360bd8991e6aa29dd9695c5e6bd25a9779272673"}, + {file = "pytest-5.3.0.tar.gz", hash = "sha256:1897d74f60a5d8be02e06d708b41bf2445da2ee777066bd68edf14474fc201eb"}, ] python-dateutil = [ {file = "python-dateutil-2.8.1.tar.gz", hash = "sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c"}, @@ -1253,6 +1291,6 @@ yarl = [ {file = "yarl-1.3.0.tar.gz", hash = "sha256:024ecdc12bc02b321bc66b41327f930d1c2c543fa9a561b39861da9388ba7aa9"}, ] youtube-dl = [ - {file = "youtube_dl-2019.11.5-py2.py3-none-any.whl", hash = "sha256:1314de17f0d41c0f1062c4942406b8e0558d14d44b32f9fce00272760a06455b"}, - {file = "youtube_dl-2019.11.5.tar.gz", hash = "sha256:25324aab78df9a09b2ee34f642f116933134bc66ea629a778c1fffe05b66f733"}, + {file = "youtube_dl-2019.11.22-py2.py3-none-any.whl", hash = "sha256:bd785113687f201415389156664b9ebd81698fb6eb44c6d9fd35898619e27bf7"}, + {file = "youtube_dl-2019.11.22.tar.gz", hash = "sha256:0575efd332cb9817f5a1fffd2a1e569e5a7d3642e7c24c7a5c47cbf70f301f25"}, ] diff --git a/pyproject.toml b/pyproject.toml index 2b5d4a24..53f7b4f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,26 +21,36 @@ python = "^3.8" dateparser = "^0.7.2" keyring = "^19.2.0" # TODO: Maybe remove this when possible? + # telegram python_telegram_bot = {version="^12.2.0", optional=true} + # discord "discord.py" = {git="https://github.com/Steffo99/discord.py", optional=true} # discord.py 1.2.4 is missing Go Live related methods pynacl = {version="^1.3.0", optional=true} # This requires libffi-dev and python3.*-dev to be installed on Linux systems + # bard ffmpeg_python = {version="~0.2.0", optional=true} youtube_dl = {version="*", optional=true} + # alchemy sqlalchemy = {version="^1.3.10", optional=true} psycopg2 = {version="^2.8.4", optional=true} # Requires quite a bit of stuff http://initd.org/psycopg/docs/install.html#install-from-source psycopg2_binary = {version="^2.8.4", optional=true} # Prebuilt alternative to psycopg2, not recommended + # constellation starlette = {version="^0.12.13", optional=true} uvicorn = {version="^0.10.7", optional=true} + # sentry sentry_sdk = {version="~0.13.2", optional=true} + # herald websockets = {version="^8.1", optional=true} + # logging + coloredlogs = {version="^10.0", optional=true} + # Development dependencies [tool.poetry.dev-dependencies] pytest = "^5.2.1" @@ -58,6 +68,7 @@ constellation = ["starlette", "uvicorn"] sentry = ["sentry_sdk"] herald = ["websockets"] + coloredlogs = ["coloredlogs"] [build-system] requires = ["poetry>=0.12"] diff --git a/royalnet/__main__.py b/royalnet/__main__.py index 047370b1..ad2541b0 100644 --- a/royalnet/__main__.py +++ b/royalnet/__main__.py @@ -6,6 +6,11 @@ import multiprocessing import keyring from logging import Formatter, StreamHandler, getLogger, Logger +try: + import coloredlogs +except ImportError: + coloredlogs = None + @click.command() @click.option("--telegram/--no-telegram", default=None, @@ -47,7 +52,12 @@ def run(telegram: typing.Optional[bool], royalnet_log: Logger = getLogger("royalnet") royalnet_log.setLevel(log_level) stream_handler = StreamHandler() - stream_handler.formatter = Formatter("{asctime}\t| {processName}\t| {levelname}\t| {name}\t| {message}", style="{") + if coloredlogs is not None: + stream_handler.formatter = coloredlogs.ColoredFormatter("{asctime}\t| {processName}\t| {levelname}\t| {name}\t|" + " {message}", style="{") + else: + stream_handler.formatter = Formatter("{asctime}\t| {processName}\t| {levelname}\t| {name}\t| {message}", + style="{") royalnet_log.addHandler(stream_handler) royalnet_log.debug("Logging: ready") @@ -192,7 +202,7 @@ def run(telegram: typing.Optional[bool], daemon=True) constellation_process.start() - click.echo("Royalnet is now running! You can stop its execution by pressing Ctrl+C at any time.") + royalnet_log.info("Royalnet is now running!") if herald_process is not None: herald_process.join() if telegram_process is not None: diff --git a/royalnet/backpack/__init__.py b/royalnet/backpack/__init__.py index b07133a6..1f5a09d7 100644 --- a/royalnet/backpack/__init__.py +++ b/royalnet/backpack/__init__.py @@ -1,4 +1,6 @@ -"""A Pack that is imported by default by all :mod:`royalnet` instances.""" +"""A Pack that is imported by default by all :mod:`royalnet` instances. + +Keep things here to a minimum!""" from . import commands, tables, stars, events from .commands import available_commands diff --git a/royalnet/backpack/commands/__init__.py b/royalnet/backpack/commands/__init__.py index bc02fc58..50c1aa68 100644 --- a/royalnet/backpack/commands/__init__.py +++ b/royalnet/backpack/commands/__init__.py @@ -1,15 +1,9 @@ # Imports go here! -from .ping import PingCommand from .version import VersionCommand -from .summon import SummonCommand -from .play import PlayCommand # Enter the commands of your Pack here! available_commands = [ - PingCommand, VersionCommand, - SummonCommand, - PlayCommand, ] # Don't change this, it should automatically generate __all__ diff --git a/royalnet/backpack/commands/ping.py b/royalnet/backpack/commands/ping.py deleted file mode 100644 index 25f2b9bd..00000000 --- a/royalnet/backpack/commands/ping.py +++ /dev/null @@ -1,10 +0,0 @@ -from royalnet.commands import * - - -class PingCommand(Command): - name: str = "ping" - - description: str = "Get a pong response." - - async def run(self, args: CommandArgs, data: CommandData) -> None: - await data.reply("๐Ÿ“ Pong!") diff --git a/royalnet/backpack/commands/play.py b/royalnet/backpack/commands/play.py deleted file mode 100644 index 69e52c61..00000000 --- a/royalnet/backpack/commands/play.py +++ /dev/null @@ -1,26 +0,0 @@ -from royalnet.commands import * -from typing import TYPE_CHECKING, Optional, List, Union -import asyncio - -try: - import discord -except ImportError: - discord = None - -if TYPE_CHECKING: - from royalnet.serf.discord import DiscordSerf - - -class PlayCommand(Command): - # TODO: possibly move this in another pack - - name: str = "play" - - description = "" - - syntax = "[url]" - - async def run(self, args: CommandArgs, data: CommandData) -> None: - url = args.joined() - response: dict = await self.interface.call_herald_event("discord", "play", url=url) - await data.reply("blah") diff --git a/royalnet/backpack/commands/summon.py b/royalnet/backpack/commands/summon.py deleted file mode 100644 index bdfa780a..00000000 --- a/royalnet/backpack/commands/summon.py +++ /dev/null @@ -1,38 +0,0 @@ -from royalnet.commands import * -from typing import TYPE_CHECKING, Optional, List, Union -import asyncio - -try: - import discord -except ImportError: - discord = None - -if TYPE_CHECKING: - from royalnet.serf.discord import DiscordSerf - - -class SummonCommand(Command): - # TODO: possibly move this in another pack - - name: str = "summon" - - description = "Connect the bot to a Discord voice channel." - - syntax = "[channelname]" - - async def run(self, args: CommandArgs, data: CommandData) -> None: - if self.interface.name == "discord": - msg: Optional["discord.Message"] = data.message - member: Optional["discord.Member"] = msg.author - guild: Optional["discord.Guild"] = msg.guild - else: - member = None - guild = None - name = args.joined() - response: dict = await self.interface.call_herald_event("discord", "summon", **{ - "channel_name": name, - "guild_id": guild.id if guild is not None else None, - "user_id": member.id if member is not None else None, - }) - await data.reply(f"โœ… Connected to [b]#{response['channel']['name']}[/b]" - f" in [i]{response['channel']['guild']['name']}[/i]!") diff --git a/royalnet/backpack/events/__init__.py b/royalnet/backpack/events/__init__.py index 5771d686..0c59d789 100644 --- a/royalnet/backpack/events/__init__.py +++ b/royalnet/backpack/events/__init__.py @@ -1,11 +1,9 @@ # Imports go here! -from .summon import SummonEvent -from .play import PlayEvent + # Enter the commands of your Pack here! available_events = [ - SummonEvent, - PlayEvent, + ] # Don't change this, it should automatically generate __all__ diff --git a/royalnet/backpack/events/play.py b/royalnet/backpack/events/play.py deleted file mode 100644 index 64dcad76..00000000 --- a/royalnet/backpack/events/play.py +++ /dev/null @@ -1,23 +0,0 @@ -from typing import Optional -from royalnet.commands import * -from royalnet.serf.discord import DiscordSerf, PlayableYTDQueue -from royalnet.bard import YtdlDiscord - -try: - import discord -except ImportError: - discord = None - - -class PlayEvent(Event): - name = "play" - - async def run(self, *, url: str): - if not isinstance(self.serf, DiscordSerf): - raise UnsupportedError("Summon can't be called on interfaces other than Discord.") - if discord is None: - raise UnsupportedError("'discord' extra is not installed.") - ytd = await YtdlDiscord.from_url(url) - self.serf.voice_players[0].playing.contents.append(ytd[0]) - await self.serf.voice_players[0].start() - return {"ok": "ok"} \ No newline at end of file diff --git a/royalnet/backpack/events/summon.py b/royalnet/backpack/events/summon.py deleted file mode 100644 index d6f314f9..00000000 --- a/royalnet/backpack/events/summon.py +++ /dev/null @@ -1,57 +0,0 @@ -from typing import Optional -from royalnet.commands import * -from royalnet.serf.discord import DiscordSerf, VoicePlayer, PlayableYTDQueue - -try: - import discord -except ImportError: - discord = None - - -class SummonEvent(Event): - name = "summon" - - async def run(self, *, channel_name: str, guild_id: Optional[int] = None, user_id: Optional[int] = None, **kwargs): - if not isinstance(self.serf, DiscordSerf): - raise UnsupportedError("Summon can't be called on interfaces other than Discord.") - if discord is None: - raise UnsupportedError("'discord' extra is not installed.") - # Find the guild - if guild_id is not None: - guild: Optional["discord.Guild"] = self.serf.client.get_guild(guild_id) - else: - guild = None - # Find the member - if user_id is not None and guild is not None: - member = guild.get_member(user_id=user_id) - else: - member = None - # Find accessible_to - accessible_to = [self.serf.client.user] - if member is not None: - accessible_to.append(member) - # Find the channel - channel: Optional["discord.VoiceChannel"] = self.serf.find_channel(channel_type=discord.VoiceChannel, - name=channel_name, - guild=guild, - accessible_to=accessible_to, - required_permissions=["connect", "speak"]) - if channel is None: - raise InvalidInputError("No channels found with the specified name.") - # Create a new VoicePlayer - vp = VoicePlayer(loop=self.loop) - vp.playing = await PlayableYTDQueue.create() - # Connect to the channel - await vp.connect(channel) - # Add the created VoicePlayer to the list - self.serf.voice_players.append(vp) - # Reply to the request - return { - "channel": { - "id": channel.id, - "name": channel.name, - "guild": { - "name": channel.guild.name, - }, - } - } diff --git a/royalnet/constellation/constellation.py b/royalnet/constellation/constellation.py index 8e47a1a1..0be322f3 100644 --- a/royalnet/constellation/constellation.py +++ b/royalnet/constellation/constellation.py @@ -22,6 +22,11 @@ except ImportError: SqlalchemyIntegration = None LoggingIntegration = None +try: + import coloredlogs +except ImportError: + coloredlogs = None + log = logging.getLogger(__name__) @@ -136,8 +141,12 @@ class Constellation: royalnet_log: logging.Logger = logging.getLogger("royalnet") royalnet_log.setLevel(log_level) stream_handler = logging.StreamHandler() - stream_handler.formatter = logging.Formatter("{asctime}\t| {processName}\t| {levelname}\t| {name}\t| {message}", - style="{") + if coloredlogs is not None: + stream_handler.formatter = coloredlogs.ColoredFormatter("{asctime}\t| {processName}\t| {levelname}\t|" + " {name}\t| {message}", style="{") + else: + stream_handler.formatter = logging.Formatter("{asctime}\t| {processName}\t| {levelname}\t| {name}\t| {message}", + style="{") if len(royalnet_log.handlers) < 1: royalnet_log.addHandler(stream_handler) royalnet_log.debug("Logging: ready") diff --git a/royalnet/herald/link.py b/royalnet/herald/link.py index bd8269c8..dc74f129 100644 --- a/royalnet/herald/link.py +++ b/royalnet/herald/link.py @@ -159,7 +159,7 @@ class Link: async def run(self): """Blockingly run the Link.""" - log.debug(f"Running main client loop for {self.nid}.") + log.debug(f"Running link: {self.config.name}") if self.error_event.is_set(): raise ConnectionClosedError("RoyalnetLinks can't be rerun after an error.") while True: diff --git a/royalnet/herald/package.py b/royalnet/herald/package.py index e7285222..77ca97a2 100644 --- a/royalnet/herald/package.py +++ b/royalnet/herald/package.py @@ -34,8 +34,7 @@ class Package: self.destination_conv_id: typing.Optional[str] = destination_conv_id def __repr__(self): - return f"<{self.__class__.__qualname__} {self.source} ({self.source_conv_id})" \ - f" to {self.destination} ({self.destination_conv_id}>" + return f"<{self.__class__.__qualname__} {self.source} ยป {self.destination}>" def __eq__(self, other): if isinstance(other, Package): diff --git a/royalnet/serf/serf.py b/royalnet/serf/serf.py index 106177c7..bd66e18e 100644 --- a/royalnet/serf/serf.py +++ b/royalnet/serf/serf.py @@ -36,6 +36,11 @@ except ImportError: AioHttpIntegration = None LoggingIntegration = None +try: + import coloredlogs +except ImportError: + coloredlogs = None + log = logging.getLogger(__name__) @@ -272,6 +277,7 @@ class Serf: def sentry_exc(exc: Exception): if sentry_sdk is not None: sentry_sdk.capture_exception(exc) + log.error(f"Captured error: {exc}") def get_secret(self, username: str): """Get a Royalnet secret from the keyring. @@ -281,6 +287,7 @@ class Serf: return get_password(f"Royalnet/{self.secrets_name}", username) async def call(self, command: Command, data: CommandData, parameters: List[str]): + log.info(f"Calling command: {command.name}") try: # Run the command await command.run(CommandArgs(parameters), data) @@ -317,8 +324,12 @@ class Serf: royalnet_log: logging.Logger = logging.getLogger("royalnet") royalnet_log.setLevel(log_level) stream_handler = logging.StreamHandler() - stream_handler.formatter = logging.Formatter("{asctime}\t| {processName}\t| {levelname}\t| {name}\t| {message}", - style="{") + if coloredlogs is not None: + stream_handler.formatter = coloredlogs.ColoredFormatter("{asctime}\t| {processName}\t| {levelname}\t| {name}\t|" + " {message}", style="{") + else: + stream_handler.formatter = Formatter("{asctime}\t| {processName}\t| {levelname}\t| {name}\t| {message}", + style="{") if len(royalnet_log.handlers) < 1: royalnet_log.addHandler(stream_handler) royalnet_log.debug("Logging: ready")