Актализировал пакеты и структуру
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,4 +1,4 @@
|
|||||||
venv
|
.venv
|
||||||
.vscode
|
.vscode
|
||||||
__pycache__
|
__pycache__
|
||||||
.env
|
.env
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
[project]
|
[project]
|
||||||
name = "MailOrderBot"
|
name = "MailOrderBot"
|
||||||
description = "Config manager for building applications"
|
description = "Config manager for building applications"
|
||||||
version = "1.0.2"
|
version = "1.0.3"
|
||||||
authors = [
|
authors = [
|
||||||
{ name = "Aleksei Zosimov", email = "lesha.spb@gmail.com" }
|
{ name = "Aleksei Zosimov", email = "lesha.spb@gmail.com" }
|
||||||
]
|
]
|
||||||
@@ -15,12 +15,17 @@ requires-python = ">=3.12"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"python-dotenv>=1.0.0"
|
"python-dotenv>=1.0.0"
|
||||||
]
|
]
|
||||||
dynamic = ["version"]
|
|
||||||
|
|
||||||
[tool.setuptools.packages.find]
|
[tool.setuptools.packages.find]
|
||||||
where = ["src"]
|
where = ["src"]
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
Homepage = "https://git.lesha.spb.ru/alex/config_manager"
|
Homepage = "https://git.lesha.spb.ru/alex/mail_order_bot"
|
||||||
Documentation = "https://git.lesha.spb.ru/alex/config_manager"
|
Documentation = "https://git.lesha.spb.ru/alex/mail_order_bot"
|
||||||
Repository = "https://git.lesha.spb.ru/alex/config_manager"
|
Repository = "https://git.lesha.spb.ru/alex/mail_order_bot"
|
||||||
|
|
||||||
|
|
||||||
|
[tool.pytest.ini_options]
|
||||||
|
addopts = [
|
||||||
|
"--import-mode=importlib",
|
||||||
|
]
|
||||||
11
src/MailOrderBot.egg-info/PKG-INFO
Normal file
11
src/MailOrderBot.egg-info/PKG-INFO
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
Metadata-Version: 2.4
|
||||||
|
Name: MailOrderBot
|
||||||
|
Version: 1.0.2
|
||||||
|
Summary: Config manager for building applications
|
||||||
|
Author-email: Aleksei Zosimov <lesha.spb@gmail.com>
|
||||||
|
Project-URL: Homepage, https://git.lesha.spb.ru/alex/config_manager
|
||||||
|
Project-URL: Documentation, https://git.lesha.spb.ru/alex/config_manager
|
||||||
|
Project-URL: Repository, https://git.lesha.spb.ru/alex/config_manager
|
||||||
|
Requires-Python: >=3.12
|
||||||
|
Description-Content-Type: text/markdown
|
||||||
|
Requires-Dist: python-dotenv>=1.0.0
|
||||||
17
src/MailOrderBot.egg-info/SOURCES.txt
Normal file
17
src/MailOrderBot.egg-info/SOURCES.txt
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
README.md
|
||||||
|
pyproject.toml
|
||||||
|
src/MailOrderBot.egg-info/PKG-INFO
|
||||||
|
src/MailOrderBot.egg-info/SOURCES.txt
|
||||||
|
src/MailOrderBot.egg-info/dependency_links.txt
|
||||||
|
src/MailOrderBot.egg-info/requires.txt
|
||||||
|
src/MailOrderBot.egg-info/top_level.txt
|
||||||
|
src/mail_order_bot/__init__.py
|
||||||
|
src/mail_order_bot/main.py
|
||||||
|
src/mail_order_bot/email_client/__init__.py
|
||||||
|
src/mail_order_bot/email_client/email_client.py
|
||||||
|
src/mail_order_bot/email_client/email_objects.py
|
||||||
|
src/mail_order_bot/excel_processor/configurable_parser.py
|
||||||
|
src/mail_order_bot/excel_processor/excel_parser.py
|
||||||
|
src/mail_order_bot/excel_processor/excel_processor.py
|
||||||
|
src/mail_order_bot/excel_processor/order_position.py
|
||||||
|
src/mail_order_bot/excel_processor/parser_factory.py
|
||||||
1
src/MailOrderBot.egg-info/dependency_links.txt
Normal file
1
src/MailOrderBot.egg-info/dependency_links.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
1
src/MailOrderBot.egg-info/requires.txt
Normal file
1
src/MailOrderBot.egg-info/requires.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
python-dotenv>=1.0.0
|
||||||
1
src/MailOrderBot.egg-info/top_level.txt
Normal file
1
src/MailOrderBot.egg-info/top_level.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
mail_order_bot
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
# === Раздел с общими конфигурационными параметрами ===
|
|
||||||
runtime:
|
|
||||||
symbols: ["BTC_USDT", "ETH_USDT", "USDD_USDT", "TRX_USDT", "BTT_USDT", "NFT_USDT", "XRP_USDT",
|
|
||||||
"ETH_BTC", "XRP_BTC", "TRX_BTC", "LTC_BTC", "EOS_BTC", "XMR_BTC", "DOGE_BTC",
|
|
||||||
"NFT_TRX", "ETH_TRX", "JST_TRX", "XRP_TRX",
|
|
||||||
"ETHBULL_USDT", "BULL_USDT", "BEAR_USDT", "ADABULL_USDT"]
|
|
||||||
|
|
||||||
updateTimeout: 45
|
|
||||||
errorTimeout: 10
|
|
||||||
|
|
||||||
orderbook:
|
|
||||||
levels: [ 0.0, 0.2, 0.4, 0.6, 0.8,
|
|
||||||
1.0, 1.2, 1.4, 1.6, 1.8,
|
|
||||||
2.0, 2.2, 2.4, 2.6, 2.8,
|
|
||||||
3.0, 3.3, 3.6, 3.9,
|
|
||||||
4.2, 4.5, 4.8,
|
|
||||||
5.1, 5.4, 5.7, 100 ]
|
|
||||||
|
|
||||||
trades:
|
|
||||||
depth: 300
|
|
||||||
|
|
||||||
# === Database params ===
|
|
||||||
db:
|
|
||||||
#host: 185.117.118.107
|
|
||||||
host: 92.53.127.143
|
|
||||||
port: 59000
|
|
||||||
database: rt5_dev
|
|
||||||
|
|
||||||
|
|
||||||
# === Логирование ===
|
|
||||||
log:
|
|
||||||
version: 1
|
|
||||||
disable_existing_loggers: False
|
|
||||||
|
|
||||||
formatters:
|
|
||||||
standard:
|
|
||||||
format: '%(asctime)s %(name)30s [%(levelname)8s]: %(message)s'
|
|
||||||
telegram:
|
|
||||||
format: '%(message)s'
|
|
||||||
|
|
||||||
handlers:
|
|
||||||
console:
|
|
||||||
level: DEBUG
|
|
||||||
formatter: standard
|
|
||||||
class: logging.StreamHandler
|
|
||||||
stream: ext://sys.stdout # Default is stderr
|
|
||||||
|
|
||||||
file:
|
|
||||||
level: DEBUG
|
|
||||||
formatter: standard
|
|
||||||
class: logging.handlers.RotatingFileHandler
|
|
||||||
filename: logs/log.log
|
|
||||||
mode: a
|
|
||||||
maxBytes: 500000
|
|
||||||
backupCount: 15
|
|
||||||
|
|
||||||
telegram:
|
|
||||||
level: CRITICAL
|
|
||||||
formatter: telegram
|
|
||||||
class: logging_telegram_handler.TelegramHandler
|
|
||||||
chat_id: 211945135
|
|
||||||
alias: "PDC"
|
|
||||||
|
|
||||||
|
|
||||||
# -- Логгеры --
|
|
||||||
loggers:
|
|
||||||
'':
|
|
||||||
handlers: [console, file]
|
|
||||||
level: ERROR
|
|
||||||
propagate: False
|
|
||||||
|
|
||||||
__main__:
|
|
||||||
handlers: [console, file, telegram]
|
|
||||||
level: WARNING
|
|
||||||
propagate: False
|
|
||||||
|
|
||||||
basic_application:
|
|
||||||
handlers: [console, file, telegram]
|
|
||||||
level: INFO
|
|
||||||
|
|
||||||
config_manager:
|
|
||||||
level: INFO
|
|
||||||
|
|
||||||
log_manager:
|
|
||||||
level: INFO
|
|
||||||
|
|
||||||
poloniex.public:
|
|
||||||
level: ERROR
|
|
||||||
|
|
||||||
controllers.abstract:
|
|
||||||
level: ERROR
|
|
||||||
|
|
||||||
controllers.trades:
|
|
||||||
level: ERROR
|
|
||||||
|
|
||||||
controllers.orderbook:
|
|
||||||
level: ERROR
|
|
||||||
|
|
||||||
clickhouse_connector.clickhouse_connector:
|
|
||||||
level: ERROR
|
|
||||||
5
src/mail_order_bot/__init__.py
Normal file
5
src/mail_order_bot/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import sys
|
||||||
|
import os
|
||||||
|
path = os.path.abspath(os.path.join(os.path.dirname(__file__)))
|
||||||
|
#print(path)
|
||||||
|
sys.path.insert(0, path)
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
runtime: 5
|
runtime: 5
|
||||||
|
|
||||||
update_interval: 1
|
update_interval: 1
|
||||||
work_interval: 3
|
work_interval: 2
|
||||||
|
|
||||||
# === Логирование ===
|
# === Логирование ===
|
||||||
log:
|
log:
|
||||||
@@ -1,19 +1,2 @@
|
|||||||
from .email_client import EmailClient
|
from .email_client import EmailClient
|
||||||
from .email_objects import EmailMessage, EmailAttachment
|
from .email_objects import EmailMessage, EmailAttachment
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['EmailClient', 'EmailMessage', 'EmailAttachment']
|
|
||||||
|
|
||||||
def test_email_client():
|
|
||||||
email_client = EmailClient(
|
|
||||||
imap_host='imap.yandex.ru',
|
|
||||||
smtp_host='smtp.yandex.ru',
|
|
||||||
email='zosimovaa@yandex.ru',
|
|
||||||
password='test'
|
|
||||||
)
|
|
||||||
assert email_client is not None
|
|
||||||
email_client.close()
|
|
||||||
pytest.main()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
test_email_client()
|
|
||||||
|
|||||||
43
src/mail_order_bot/main.py
Normal file
43
src/mail_order_bot/main.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
|
||||||
|
from basic_application import ConfigManager
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
import asyncio
|
||||||
|
import logging
|
||||||
|
|
||||||
|
#cdimport os
|
||||||
|
#os.chdir(os.path.dirname(__file__))
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
class MailOrderBot(ConfigManager):
|
||||||
|
def __init__(self, *agrs, **kwargs):
|
||||||
|
super().__init__(*agrs, **kwargs)
|
||||||
|
self.cycle = 0
|
||||||
|
|
||||||
|
def execute(self):
|
||||||
|
logger.info(f"run {self.cycle}")
|
||||||
|
print(f"run {self.cycle}")
|
||||||
|
self.cycle += 1
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
class MyApp(ConfigManager):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.iter = 0
|
||||||
|
|
||||||
|
def execute(self) -> None:
|
||||||
|
logger.info(f"current iteration {self.iter}")
|
||||||
|
self.iter += 1
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
app = MyApp("config.yaml")
|
||||||
|
app.start()
|
||||||
|
logger.info("App started")
|
||||||
|
await asyncio.sleep(20)
|
||||||
|
await app.stop()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
load_dotenv()
|
||||||
|
asyncio.run(main())
|
||||||
|
|
||||||
31
src/main.py
31
src/main.py
@@ -1,31 +0,0 @@
|
|||||||
|
|
||||||
from config_manager.config_manager import ConfigManager
|
|
||||||
import asyncio
|
|
||||||
import logging
|
|
||||||
|
|
||||||
import os
|
|
||||||
os.chdir(os.path.dirname(__file__))
|
|
||||||
|
|
||||||
logger = logging.getLogger()
|
|
||||||
|
|
||||||
class MailOrderBot(ConfigManager):
|
|
||||||
def __init__(self, *agrs, **kwargs):
|
|
||||||
super().__init__(*agrs, **kwargs)
|
|
||||||
|
|
||||||
def execute(self):
|
|
||||||
print("run")
|
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
|
||||||
app = MailOrderBot("config.yaml") # Можно config.json или config.yaml
|
|
||||||
task = asyncio.create_task(app.start())
|
|
||||||
await asyncio.sleep(5)
|
|
||||||
app.stop()
|
|
||||||
await task
|
|
||||||
logger.info("Work finished.")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
asyncio.run(main())
|
|
||||||
|
|
||||||
@@ -1,13 +1,12 @@
|
|||||||
import os
|
import os
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
import sys
|
|
||||||
sys.path.append('./src')
|
|
||||||
|
|
||||||
load_dotenv()
|
|
||||||
|
|
||||||
from mail_order_bot.email_client import EmailClient
|
from mail_order_bot.email_client import EmailClient
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
# подгружаем переменные окружения
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
email_client = EmailClient(
|
email_client = EmailClient(
|
||||||
imap_host=os.getenv('IMAP_HOST'),
|
imap_host=os.getenv('IMAP_HOST'),
|
||||||
smtp_host=os.getenv('SMTP_HOST'),
|
smtp_host=os.getenv('SMTP_HOST'),
|
||||||
@@ -17,6 +16,7 @@ if __name__ == "__main__":
|
|||||||
smtp_port=os.getenv('SMTP_PORT')
|
smtp_port=os.getenv('SMTP_PORT')
|
||||||
)
|
)
|
||||||
emails = email_client.get_emails(folder='spareparts', only_unseen=True, mark_as_read=True)
|
emails = email_client.get_emails(folder='spareparts', only_unseen=True, mark_as_read=True)
|
||||||
|
|
||||||
for email in emails:
|
for email in emails:
|
||||||
print(email.subj)
|
print(email.subj)
|
||||||
print(email.from_addr)
|
print(email.from_addr)
|
||||||
|
|||||||
Reference in New Issue
Block a user