diff options
| author | jantuomi <jans.tuomi@gmail.com> | 2016-07-19 14:50:22 +0300 |
|---|---|---|
| committer | jantuomi <jans.tuomi@gmail.com> | 2016-07-19 14:50:22 +0300 |
| commit | 9d94a01b631676b54f680c2571ae4dbba9ccd037 (patch) | |
| tree | 2cac58eba2cd5d29ae0c2192efc5ca365dde7f74 | |
| parent | 080cfd6cfe946e243239af201dea8466abaee020 (diff) | |
Restructure project
| -rw-r--r-- | project/__init__.py | 0 | ||||
| -rw-r--r-- | project/basecommunicator.py (renamed from basecommunicator.py) | 0 | ||||
| -rw-r--r-- | project/botmanager.py (renamed from botmanager.py) | 16 | ||||
| -rw-r--r-- | project/jsonfactory.py (renamed from jsonfactory.py) | 0 | ||||
| -rw-r--r-- | project/mockshoutbox.py (renamed from mockshoutbox.py) | 0 | ||||
| -rw-r--r-- | project/shoutboxapicommunicator.py (renamed from shoutboxapicommunicator.py) | 6 | ||||
| -rw-r--r-- | project/telegramapicommunicator.py (renamed from telegramapicommunicator.py) | 4 | ||||
| -rwxr-xr-x | radiodiodibot (renamed from radiodiodibot.py) | 19 |
8 files changed, 25 insertions, 20 deletions
diff --git a/project/__init__.py b/project/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/project/__init__.py diff --git a/basecommunicator.py b/project/basecommunicator.py index f4f8337..f4f8337 100644 --- a/basecommunicator.py +++ b/project/basecommunicator.py diff --git a/botmanager.py b/project/botmanager.py index 8cfe949..805f20c 100644 --- a/botmanager.py +++ b/project/botmanager.py @@ -1,15 +1,17 @@ # -*- coding: utf-8 -*- +import logging import random import sys -import telepot -import traceback import time -import logging +import traceback + +import telepot + +from project.jsonfactory import JSONFactory +from project.shoutboxapicommunicator import ShoutboxCommunicator +from project.telegramapicommunicator import TelegramCommunicator -from jsonfactory import JSONFactory -from shoutboxapicommunicator import ShoutboxCommunicator -from telegramapicommunicator import TelegramCommunicator class BotManager(object): """Manager class for the process""" @@ -32,7 +34,7 @@ class BotManager(object): logging.info("Bot succesfully created.") except: traceback.print_exc() - logging.error("Error creating bot listener. radiodiodibot will now exit...") + logging.error("Error creating bot listener. src will now exit...") sys.exit(1) def set_parameters(self, shoutbox_api_url, telegram_chat_id, api_call_interval): diff --git a/jsonfactory.py b/project/jsonfactory.py index c57b430..c57b430 100644 --- a/jsonfactory.py +++ b/project/jsonfactory.py diff --git a/mockshoutbox.py b/project/mockshoutbox.py index 4a64406..4a64406 100644 --- a/mockshoutbox.py +++ b/project/mockshoutbox.py diff --git a/shoutboxapicommunicator.py b/project/shoutboxapicommunicator.py index 7138aa9..7194c8f 100644 --- a/shoutboxapicommunicator.py +++ b/project/shoutboxapicommunicator.py @@ -1,7 +1,9 @@ import json -import requests import logging -from basecommunicator import BaseCommunicator + +import requests + +from project.basecommunicator import BaseCommunicator class ShoutboxCommunicator(BaseCommunicator): diff --git a/telegramapicommunicator.py b/project/telegramapicommunicator.py index 169a1ce..7fdb29c 100644 --- a/telegramapicommunicator.py +++ b/project/telegramapicommunicator.py @@ -1,9 +1,9 @@ import logging - import sys + import telepot -from basecommunicator import BaseCommunicator +from project.basecommunicator import BaseCommunicator class TelegramCommunicator(BaseCommunicator): diff --git a/radiodiodibot.py b/radiodiodibot index 8499e90..4bd53e0 100755 --- a/radiodiodibot.py +++ b/radiodiodibot @@ -1,15 +1,16 @@ -#!/usr/bin/env python -import configparser -import sys +#!/usr/bin/env python3 import argparse -import botmanager +import configparser import logging import signal +import sys + +from project import botmanager def sigint_handler(signal, frame): """Exit gracefully when receiving an interrupt signal""" - print("Exiting radiodiodibot...") + print("Exiting src...") sys.exit(0) signal.signal(signal.SIGINT, sigint_handler) @@ -23,8 +24,8 @@ except ImportError: logging.getLogger(__name__).addHandler(NullHandler()) -# Read configs, unsuccessful reads are silently -# ignored +# Read configs, unsuccessful reads are +# silently ignored CONFIG_FILE = "bot.config" config = configparser.ConfigParser() config.read(CONFIG_FILE) @@ -51,8 +52,8 @@ logging.basicConfig(level=logging_level, format="%(asctime)s %(levelname)s %(mes try: import telepot except: - print("radiodiodibot needs the telepot module to communicate with Telegram.") - print("Please install telepot before using radiodiodibot.") + print("src needs the telepot module to communicate with Telegram.") + print("Please install telepot before using src.") sys.exit(1) |
