From c71c976111037f6408482f12cc7c515b6155dfb7 Mon Sep 17 00:00:00 2001 From: Romain J Date: Wed, 1 Jan 2020 23:44:46 +0100 Subject: [PATCH] change(name): set cluser_ as fallback_ --- .gitignore | 2 +- bot.py | 5 +++-- cogs/{cluster_manager.py => fallback_manager.py} | 16 +++++++++------- logs/tuxbot.log | 0 requirements.txt | 2 +- venv/bin/activate | 2 +- venv/bin/activate.csh | 2 +- venv/bin/activate.fish | 2 +- venv/bin/chardetect | 6 ++++-- venv/bin/easy_install | 2 +- venv/bin/import_expression | 6 ++++-- venv/bin/pip | 2 +- venv/bin/pip3 | 2 +- venv/bin/tcp-latency | 6 ++++-- venv/pyvenv.cfg | 2 +- 15 files changed, 33 insertions(+), 24 deletions(-) rename cogs/{cluster_manager.py => fallback_manager.py} (83%) create mode 100644 logs/tuxbot.log diff --git a/.gitignore b/.gitignore index 801a505..f916017 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,7 @@ private.py .idea/ #other -*.log +logs/tuxbot.log # Byte-compiled / optimized / DLL files diff --git a/bot.py b/bot.py index 5efd809..c88398f 100755 --- a/bot.py +++ b/bot.py @@ -18,6 +18,7 @@ from cogs.utils.version import Version description = """ Je suis TuxBot, le bot qui vit de l'OpenSource ! ;) """ + build = git.Repo(search_parent_directories=True).head.object.hexsha log = logging.getLogger(__name__) @@ -25,7 +26,7 @@ log = logging.getLogger(__name__) l_extensions: List[str] = [ 'cogs.admin', 'cogs.basics', - 'cogs.cluster_manager', + 'cogs.fallback_manager', 'cogs.logs', 'cogs.poll', 'cogs.user', @@ -144,7 +145,7 @@ class TuxBot(commands.AutoShardedBot): ) ) print(f"Discord.py: {discord.__version__}") - print(f"Cluster: {self.cluster.get('Name')}") + print(f"Server: {self.cluster.get('Name')}") print('-' * 60) await self.change_presence(**presence) diff --git a/cogs/cluster_manager.py b/cogs/fallback_manager.py similarity index 83% rename from cogs/cluster_manager.py rename to cogs/fallback_manager.py index caee847..8e96438 100644 --- a/cogs/cluster_manager.py +++ b/cogs/fallback_manager.py @@ -28,7 +28,7 @@ class Monitoring(commands.Cog): def cog_unload(self): self.ping_clusters.stop() - @tasks.loop(minutes=2.0) + @tasks.loop(seconds=10.0) async def ping_clusters(self): for cluster in self.bot.clusters: if cluster == 'DEFAULT': @@ -40,17 +40,19 @@ class Monitoring(commands.Cog): port = cluster.get('Port') try: - req = urllib.request.urlopen(f"http://{host}:{port}", - timeout=2) + req = urllib.request.urlopen( + f"http://{host}:{port}", + timeout=2 + ) except Exception: global_channel = await self.bot.fetch_channel( 661347412463321098 ) e = discord.Embed( - title=f"Cluster `{cluster.get('Name')}`", + title=f"Server `{cluster.get('Name')}`", color=discord.colour.Color.red(), - description=f"Cluster **`{cluster.get('Name')}`** with address **`http://{host}:{port}`** is down ! ", + description=f"Server **`{cluster.get('Name')}`** with address **`http://{host}:{port}`** is down ! ", timestamp=datetime.now() ) e.set_thumbnail( @@ -74,9 +76,9 @@ class Monitoring(commands.Cog): ) e = discord.Embed( - title=f"Cluster `{cluster.get('Name')}`", + title=f"Server `{cluster.get('Name')}`", color=discord.colour.Color.green(), - description=f"Cluster **`{cluster.get('Name')}`** with address **`http://{host}:{port}`** is started ! ", + description=f"Server **`{cluster.get('Name')}`** with address **`http://{host}:{port}`** is started ! ", timestamp=datetime.now() ) e.set_thumbnail( diff --git a/logs/tuxbot.log b/logs/tuxbot.log new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt index 23208d8..a428aba 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ requests humanize -discord.py[voice] +git+https://github.com/Rapptz/discord.py@master jishaku gitpython sqlalchemy diff --git a/venv/bin/activate b/venv/bin/activate index c9a2175..3f4bf1c 100644 --- a/venv/bin/activate +++ b/venv/bin/activate @@ -37,7 +37,7 @@ deactivate () { # unset irrelevant variables deactivate nondestructive -VIRTUAL_ENV="/opt/tuxbot-bot/venv" +VIRTUAL_ENV="/home/romain/gnousEU/rm-dev01/tuxbot-bot/venv" export VIRTUAL_ENV _OLD_VIRTUAL_PATH="$PATH" diff --git a/venv/bin/activate.csh b/venv/bin/activate.csh index 83031a3..98060ea 100644 --- a/venv/bin/activate.csh +++ b/venv/bin/activate.csh @@ -8,7 +8,7 @@ alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PA # Unset irrelevant variables. deactivate nondestructive -setenv VIRTUAL_ENV "/opt/tuxbot-bot/venv" +setenv VIRTUAL_ENV "/home/romain/gnousEU/rm-dev01/tuxbot-bot/venv" set _OLD_VIRTUAL_PATH="$PATH" setenv PATH "$VIRTUAL_ENV/bin:$PATH" diff --git a/venv/bin/activate.fish b/venv/bin/activate.fish index 49518e4..4963b20 100644 --- a/venv/bin/activate.fish +++ b/venv/bin/activate.fish @@ -29,7 +29,7 @@ end # unset irrelevant variables deactivate nondestructive -set -gx VIRTUAL_ENV "/opt/tuxbot-bot/venv" +set -gx VIRTUAL_ENV "/home/romain/gnousEU/rm-dev01/tuxbot-bot/venv" set -gx _OLD_VIRTUAL_PATH $PATH set -gx PATH "$VIRTUAL_ENV/bin" $PATH diff --git a/venv/bin/chardetect b/venv/bin/chardetect index a43fcee..967b10d 100755 --- a/venv/bin/chardetect +++ b/venv/bin/chardetect @@ -1,8 +1,10 @@ -#!/opt/tuxbot-bot/venv/bin/python +#!/home/romain/gnousEU/rm-dev01/tuxbot-bot/venv/bin/python # -*- coding: utf-8 -*- import re import sys + from chardet.cli.chardetect import main + if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) sys.exit(main()) diff --git a/venv/bin/easy_install b/venv/bin/easy_install index 6475025..de4c6b6 100755 --- a/venv/bin/easy_install +++ b/venv/bin/easy_install @@ -1,4 +1,4 @@ -#!/opt/tuxbot-bot/venv/bin/python +#!/home/romain/gnousEU/rm-dev01/tuxbot-bot/venv/bin/python # -*- coding: utf-8 -*- import re import sys diff --git a/venv/bin/import_expression b/venv/bin/import_expression index 0d4fa1e..b88a6d8 100755 --- a/venv/bin/import_expression +++ b/venv/bin/import_expression @@ -1,8 +1,10 @@ -#!/opt/tuxbot-bot/venv/bin/python +#!/home/romain/gnousEU/rm-dev01/tuxbot-bot/venv/bin/python # -*- coding: utf-8 -*- import re import sys + from import_expression.__main__ import main + if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) sys.exit(main()) diff --git a/venv/bin/pip b/venv/bin/pip index c8cec3c..6b21959 100755 --- a/venv/bin/pip +++ b/venv/bin/pip @@ -1,4 +1,4 @@ -#!/opt/tuxbot-bot/venv/bin/python +#!/home/romain/gnousEU/rm-dev01/tuxbot-bot/venv/bin/python # -*- coding: utf-8 -*- import re import sys diff --git a/venv/bin/pip3 b/venv/bin/pip3 index c8cec3c..6b21959 100755 --- a/venv/bin/pip3 +++ b/venv/bin/pip3 @@ -1,4 +1,4 @@ -#!/opt/tuxbot-bot/venv/bin/python +#!/home/romain/gnousEU/rm-dev01/tuxbot-bot/venv/bin/python # -*- coding: utf-8 -*- import re import sys diff --git a/venv/bin/tcp-latency b/venv/bin/tcp-latency index f368ef6..a2583cb 100755 --- a/venv/bin/tcp-latency +++ b/venv/bin/tcp-latency @@ -1,8 +1,10 @@ -#!/opt/tuxbot-bot/venv/bin/python +#!/home/romain/gnousEU/rm-dev01/tuxbot-bot/venv/bin/python # -*- coding: utf-8 -*- import re import sys + from tcp_latency.tcp_latency import _main + if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) sys.exit(_main()) diff --git a/venv/pyvenv.cfg b/venv/pyvenv.cfg index 517a829..1f606f9 100644 --- a/venv/pyvenv.cfg +++ b/venv/pyvenv.cfg @@ -1,3 +1,3 @@ home = /usr/bin include-system-site-packages = false -version = 3.8.1 +version = 3.8.0