From a2b31868b4ee797f085c5df18e304096a2c7a409 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Thu, 29 Apr 2021 17:53:30 -0400 Subject: [PATCH] Revert "Added Docker url fix to docker_utility.py" This reverts commit 6d1c07f39b0d8cfe1725f0e5882abf80eb4eecea. --- .../implemented/ChannelReward_Hydration.py | 6 ++---- .../implemented/ChannelReward_RubiksCube.py | 6 ++---- .../implemented/ChannelReward_twitchBits.py | 6 ++---- .../implemented/ChannelReward_twitchSubs.py | 6 ++---- commands/implemented/Command_lights_v2.py | 4 +--- commands/implemented/Command_tts_v2.py | 6 ++---- docker_utility.py | 14 -------------- standalone_discord_script.py | 10 ++++------ standalone_twitch_pubsub.py | 6 ++---- standalone_twitch_script.py | 8 +++----- 10 files changed, 20 insertions(+), 52 deletions(-) delete mode 100644 docker_utility.py diff --git a/channel_rewards/implemented/ChannelReward_Hydration.py b/channel_rewards/implemented/ChannelReward_Hydration.py index 873ef01..7579170 100644 --- a/channel_rewards/implemented/ChannelReward_Hydration.py +++ b/channel_rewards/implemented/ChannelReward_Hydration.py @@ -6,8 +6,6 @@ from json import loads from urllib.parse import urlencode import requests -import docker_utility - import threading import random @@ -48,7 +46,7 @@ class ChannelReward_Hydration(AbstractChannelRewards, metaclass=ABCMeta): # todo need to url-escape command and rest params = urlencode({'user_name': username, 'light_group': light_group, 'command': command, 'rest':rest}) #standalone_lights - url = "http://%s:42069/api/v1/exec_lights?%s" % docker_utility.ifNotDockerUseLocalhost("standalone_lights"), params + url = "http://standalone_lights:42069/api/v1/exec_lights?%s" % params resp = requests.get(url) if resp.status_code == 200: print("Got the following message: %s" % resp.text) @@ -64,7 +62,7 @@ class ChannelReward_Hydration(AbstractChannelRewards, metaclass=ABCMeta): def send_TTS(self, username, message): params = urlencode({'tts_sender': username, 'tts_text': message}) #standalone_tts_core - url = "http://%s:60809/api/v1/tts/send_text?%s" % docker_utility.ifNotDockerUseLocalhost("standalone_tts_core"), params + url = "http://standalone_tts_core:60809/api/v1/tts/send_text?%s" % params resp = requests.get(url) if resp.status_code == 200: print("Got the following message: %s" % resp.text) diff --git a/channel_rewards/implemented/ChannelReward_RubiksCube.py b/channel_rewards/implemented/ChannelReward_RubiksCube.py index 270c79b..920b775 100644 --- a/channel_rewards/implemented/ChannelReward_RubiksCube.py +++ b/channel_rewards/implemented/ChannelReward_RubiksCube.py @@ -6,8 +6,6 @@ from json import loads from urllib.parse import urlencode import requests -import docker_utility - import threading import random @@ -49,7 +47,7 @@ class ChannelReward_RubiksCube(AbstractChannelRewards, metaclass=ABCMeta): # todo need to url-escape command and rest params = urlencode({'user_name': username, 'light_group': light_group, 'command': command, 'rest':rest}) #standalone_lights - url = "http://%s:42069/api/v1/exec_lights?%s" % docker_utility.ifNotDockerUseLocalhost("standalone_lights"), params + url = "http://standalone_lights:42069/api/v1/exec_lights?%s" % params resp = requests.get(url) if resp.status_code == 200: print("Got the following message: %s" % resp.text) @@ -65,7 +63,7 @@ class ChannelReward_RubiksCube(AbstractChannelRewards, metaclass=ABCMeta): def send_TTS(self, username, message): params = urlencode({'tts_sender': username, 'tts_text': message}) #standalone_tts_core - url = "http://%s:60809/api/v1/tts/send_text?%s" % docker_utility.ifNotDockerUseLocalhost("standalone_tts_core"), params + url = "http://standalone_tts_core:60809/api/v1/tts/send_text?%s" % params resp = requests.get(url) if resp.status_code == 200: print("Got the following message: %s" % resp.text) diff --git a/channel_rewards/implemented/ChannelReward_twitchBits.py b/channel_rewards/implemented/ChannelReward_twitchBits.py index bd5d13c..f73e069 100644 --- a/channel_rewards/implemented/ChannelReward_twitchBits.py +++ b/channel_rewards/implemented/ChannelReward_twitchBits.py @@ -6,8 +6,6 @@ from json import loads from urllib.parse import urlencode import requests -import docker_utility - import threading import random @@ -47,7 +45,7 @@ class ChannelReward_TwitchBits(AbstractChannelRewards, metaclass=ABCMeta): # todo need to url-escape command and rest params = urlencode({'user_name': username, 'light_group': light_group, 'command': command, 'rest':rest}) #standalone_lights - url = "http://%s:42069/api/v1/exec_lights?%s" % docker_utility.ifNotDockerUseLocalhost("standalone_lights"), params + url = "http://standalone_lights:42069/api/v1/exec_lights?%s" % params resp = requests.get(url) if resp.status_code == 200: print("Got the following message: %s" % resp.text) @@ -63,7 +61,7 @@ class ChannelReward_TwitchBits(AbstractChannelRewards, metaclass=ABCMeta): def send_TTS(self, username, message): params = urlencode({'tts_sender': username, 'tts_text': message}) #standalone_tts_core - url = "http://%s:60809/api/v1/tts/send_text?%s" % docker_utility.ifNotDockerUseLocalhost("standalone_tts_core"), params + url = "http://standalone_tts_core:60809/api/v1/tts/send_text?%s" % params resp = requests.get(url) if resp.status_code == 200: print("Got the following message: %s" % resp.text) diff --git a/channel_rewards/implemented/ChannelReward_twitchSubs.py b/channel_rewards/implemented/ChannelReward_twitchSubs.py index b1d47de..461d910 100644 --- a/channel_rewards/implemented/ChannelReward_twitchSubs.py +++ b/channel_rewards/implemented/ChannelReward_twitchSubs.py @@ -6,8 +6,6 @@ from json import loads from urllib.parse import urlencode import requests -import docker_utility - import threading import random @@ -48,7 +46,7 @@ class ChannelReward_TwitchSubs(AbstractChannelRewards, metaclass=ABCMeta): # todo need to url-escape command and rest params = urlencode({'user_name': username, 'light_group': light_group, 'command': command, 'rest':rest}) #standalone_lights - url = "http://%s:42069/api/v1/exec_lights?%s" % docker_utility.ifNotDockerUseLocalhost("standalone_lights"), params + url = "http://standalone_lights:42069/api/v1/exec_lights?%s" % params resp = requests.get(url) if resp.status_code == 200: print("Got the following message: %s" % resp.text) @@ -64,7 +62,7 @@ class ChannelReward_TwitchSubs(AbstractChannelRewards, metaclass=ABCMeta): def send_TTS(self, username, message): params = urlencode({'tts_sender': username, 'tts_text': message}) #standalone_tts_core - url = "http://%s:60809/api/v1/tts/send_text?%s" % docker_utility.ifNotDockerUseLocalhost("standalone_tts_core"), params + url = "http://standalone_tts_core:60809/api/v1/tts/send_text?%s" % params resp = requests.get(url) if resp.status_code == 200: print("Got the following message: %s" % resp.text) diff --git a/commands/implemented/Command_lights_v2.py b/commands/implemented/Command_lights_v2.py index ca81f0a..66e1fbd 100644 --- a/commands/implemented/Command_lights_v2.py +++ b/commands/implemented/Command_lights_v2.py @@ -6,8 +6,6 @@ from json import loads from urllib.parse import urlencode import requests -import docker_utility - import config import os @@ -49,7 +47,7 @@ class Command_lights_v2(AbstractCommand, metaclass=ABCMeta): # todo need to url-escape command and rest params = urlencode({'user_name': username, 'light_group': light_group, 'command': command, 'rest':rest}) #standalone_lights - url = "http://%s:42069/api/v1/exec_lights?%s" % docker_utility.ifNotDockerUseLocalhost("standalone_lights"), params + url = "http://standalone_lights:42069/api/v1/exec_lights?%s" % params resp = requests.get(url) if resp.status_code == 200: print("Got the following message: %s" % resp.text) diff --git a/commands/implemented/Command_tts_v2.py b/commands/implemented/Command_tts_v2.py index 41325b9..6d59239 100644 --- a/commands/implemented/Command_tts_v2.py +++ b/commands/implemented/Command_tts_v2.py @@ -6,8 +6,6 @@ from json import loads from urllib.parse import urlencode import requests -import docker_utility - import config import os @@ -44,7 +42,7 @@ class Command_tts_v2(AbstractCommand, metaclass=ABCMeta): # todo need to url-escape command and rest params = urlencode({'user_name': username, 'light_group': light_group, 'command': command, 'rest':rest}) #standalone_lights - url = "http://%s:42069/api/v1/exec_lights?%s" % docker_utility.ifNotDockerUseLocalhost("standalone_lights"), params + url = "http://standalone_lights:42069/api/v1/exec_lights?%s" % params resp = requests.get(url) if resp.status_code == 200: print("Got the following message: %s" % resp.text) @@ -60,7 +58,7 @@ class Command_tts_v2(AbstractCommand, metaclass=ABCMeta): def send_TTS(self, username, message): params = urlencode({'tts_sender': username, 'tts_text': message}) #standalone_tts_core - url = "http://%s:60809/api/v1/tts/send_text?%s" % docker_utility.ifNotDockerUseLocalhost("standalone_tts_core"), params + url = "http://standalone_tts_core:60809/api/v1/tts/send_text?%s" % params resp = requests.get(url) if resp.status_code == 200: print("Got the following message: %s" % resp.text) diff --git a/docker_utility.py b/docker_utility.py deleted file mode 100644 index 9268c93..0000000 --- a/docker_utility.py +++ /dev/null @@ -1,14 +0,0 @@ -import os - -def isRunningInDocker(): - isD = os.getenv('ISDOCKER') - if isD is None: - return False - return isD == "cat" - -def ifNotDockerUseLocalhost(address): - amIDocker = isRunningInDocker() - if amIDocker: - return address - else: - return "localhost" \ No newline at end of file diff --git a/standalone_discord_script.py b/standalone_discord_script.py index 80995a4..723fc86 100644 --- a/standalone_discord_script.py +++ b/standalone_discord_script.py @@ -25,8 +25,6 @@ import discord.abc from cooldowns import Cooldown_Module -import docker_utility - import os import praxis_logging praxis_logger_obj = praxis_logging.praxis_logger() @@ -107,14 +105,14 @@ class Discord_Module(discord.Client): async def is_command(self, word: str) -> bool: # todo need to url-escape word clean_param = urlencode({'name': word}) - url = "http://%s:6009/api/v1/command?%s" % docker_utility.ifNotDockerUseLocalhost("standalone_command"), clean_param + url = "http://standalone_command:6009/api/v1/command?%s" % clean_param resp = requests.get(url) return resp.status_code == 200 async def exec_command(self, realMessage: discord.Message, command: str, rest: str): # todo need to url-escape command and rest - clean_param = urlencode({'command_source': commands.command_base.AbstractCommand.CommandSource.Discord, 'user_name': realMessage.author.mention, 'command_name': command, 'rest': rest, 'bonus_data': realMessage}) - url = "http://%s:6009/api/v1/exec_command?%s" % docker_utility.ifNotDockerUseLocalhost("standalone_command"), clean_param + params = urlencode({'command_source': commands.command_base.AbstractCommand.CommandSource.Discord, 'user_name': realMessage.author.mention, 'command_name': command, 'rest': rest, 'bonus_data': realMessage}) + url = "http://standalone_command:6009/api/v1/exec_command?%s" % params resp = requests.get(url) if resp.status_code == 200: print("Got the following message: %s" % resp.text) @@ -176,7 +174,7 @@ class Discord_Module(discord.Client): async def exec_tts_sender(self, username, message): params = urlencode({'tts_sender': username, 'tts_text': message}) #standalone_tts_core - url = "http://%s:60809/api/v1/tts/send_text?%s" % docker_utility.ifNotDockerUseLocalhost("standalone_tts_core"), params + url = "http://standalone_tts_core:60809/api/v1/tts/send_text?%s" % params resp = requests.get(url) if resp.status_code == 200: print("Got the following message: %s" % resp.text) diff --git a/standalone_twitch_pubsub.py b/standalone_twitch_pubsub.py index d86ff8d..37ebfad 100644 --- a/standalone_twitch_pubsub.py +++ b/standalone_twitch_pubsub.py @@ -20,8 +20,6 @@ from uuid import UUID from cooldowns import Cooldown_Module -import docker_utility - import os import praxis_logging praxis_logger_obj = praxis_logging.praxis_logger() @@ -173,7 +171,7 @@ class Twitch_Pubsub(): clean_param = urlencode({'reward_name': rewardName, 'reward_type':rewardType}) print(rewardName, rewardType) #standalone_channelrewards - url = "http://%s:6969/api/v1/reward?%s" % docker_utility.ifNotDockerUseLocalhost("standalone_channelrewards"), clean_param + url = "http://standalone_channelrewards:6969/api/v1/reward?%s" % clean_param resp = requests.get(url) return resp.status_code == 200 @@ -188,7 +186,7 @@ class Twitch_Pubsub(): 'bonus_data': realMessage}) #standalone_channelrewards - url = "http://%s:6969/api/v1/exec_reward?%s" % docker_utility.ifNotDockerUseLocalhost("standalone_channelrewards"), params + url = "http://standalone_channelrewards:6969/api/v1/exec_reward?%s" % params resp = requests.get(url) if resp.status_code == 200: print("Got the following message: %s" % resp.text) diff --git a/standalone_twitch_script.py b/standalone_twitch_script.py index 6861d81..e5e02fd 100644 --- a/standalone_twitch_script.py +++ b/standalone_twitch_script.py @@ -12,8 +12,6 @@ from cooldowns import Cooldown_Module import commands.command_base import utilities_script as utility -import docker_utility - import os import praxis_logging praxis_logger_obj = praxis_logging.praxis_logger() @@ -77,20 +75,20 @@ class Twitch_Module(): def is_command(self, word: str) -> bool: # todo need to url-escape word clean_param = urlencode({'name': word}) - url = "http://%s:6009/api/v1/command?%s" % docker_utility.ifNotDockerUseLocalhost("standalone_command"), clean_param + url = "http://standalone_command:6009/api/v1/command?%s" % clean_param resp = requests.get(url) return resp.status_code == 200 def exec_command(self, realMessage: twitch.chat.Message, command: str, rest: str): # todo need to url-escape command and rest - clean_param = urlencode( + params = urlencode( {'command_source': commands.command_base.AbstractCommand.CommandSource.Twitch, 'user_name': realMessage.sender, 'command_name': command, 'rest': rest, 'bonus_data': realMessage}) - url = "http://%s:6009/api/v1/exec_command?%s" % docker_utility.ifNotDockerUseLocalhost("standalone_command"), clean_param + url = "http://standalone_command:6009/api/v1/exec_command?%s" % params resp = requests.get(url) if resp.status_code == 200: print("Got the following message: %s" % resp.text)