From ef6f13ded7b4d6eaaedd73c223556f8352e32824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Wed, 24 Apr 2019 10:41:18 +0900 Subject: [PATCH] Fix: restructuring python directory --- .gitignore | 6 +++ src/web/python/batch/test_python.py | 43 ------------------- src/web/python/batch/test_requests.py | 6 --- .../batch/unpaid_maestro_manager.py | 10 ++++- src/web/python/chocomae/helloworld.py | 12 ++++++ .../lib/database}/db_manager.py | 7 ++- .../lib/database}/db_setting.py | 0 .../python/chocomae/lib/database/module_a.py | 4 ++ .../lib/mail}/mail_sender.py | 0 src/web/python/chocomae/lib/mail/module_b.py | 7 +++ .../python/chocomae/remove_unpaid_maestro.py | 5 +++ 11 files changed, 48 insertions(+), 52 deletions(-) delete mode 100644 src/web/python/batch/test_python.py delete mode 100644 src/web/python/batch/test_requests.py rename src/web/python/{ => chocomae}/batch/unpaid_maestro_manager.py (81%) create mode 100644 src/web/python/chocomae/helloworld.py rename src/web/python/{batch => chocomae/lib/database}/db_manager.py (90%) rename src/web/python/{batch => chocomae/lib/database}/db_setting.py (100%) create mode 100644 src/web/python/chocomae/lib/database/module_a.py rename src/web/python/{batch => chocomae/lib/mail}/mail_sender.py (100%) create mode 100644 src/web/python/chocomae/lib/mail/module_b.py create mode 100644 src/web/python/chocomae/remove_unpaid_maestro.py diff --git a/.gitignore b/.gitignore index d9c461f..3cbc87b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,11 @@ # psd files *.psd + +# python +.idea/ +venv/ +__pycache__/ + # python compiled files *.pyc diff --git a/src/web/python/batch/test_python.py b/src/web/python/batch/test_python.py deleted file mode 100644 index b22b5ee..0000000 --- a/src/web/python/batch/test_python.py +++ /dev/null @@ -1,43 +0,0 @@ -from unpaid_maestro_manager import UnpaidMaestroManager -from mail_sender import NCloud -from mail_sender import MailSender - - -def test_send_mail(): - MailSender.send_temp_mail() - return - - maestro_name = 'test1' - maestro_email = 'jisangs@daum.net' - params = {'maestro_name': maestro_name, 'maestro_date': '2019-04-08'} - - mail_sender = MailSender() - mail_sender.make_default_post_param() - mail_sender.set_post_param('templateSid', 337) - mail_sender.set_post_param_recipients(maestro_name, maestro_email) - mail_sender.set_post_param('parameters', params) - - timestamp = MailSender.get_timestamp() - # print('hmac : ' + MailSender.hash_hmac('ripemd160', 'The quick brown fox jumped over the lazy dog.', 'secret')) - signature = MailSender.make_signature(NCloud.request_url, timestamp) - # print('signature : ' + signature.decode('utf-8')) - mail_sender.send_email(timestamp, signature) - - -def test_db_work(): - unpaid_maestro_manager = UnpaidMaestroManager() - day7_maestro_list = unpaid_maestro_manager.get_unpaid_7days_maestro_list() - # print(day7_maestro_list) - maestro_list = list() - maestro_list.append(day7_maestro_list[0]) - # print(maestro_list) - for maestro in maestro_list: - maestro_id = maestro['MaestroID'] - maestro_name = maestro['Name'] - remark = maestro_name + ' / ' + 'unpaid 7 days' - unpaid_maestro_manager.insert_maestro_log(maestro_id, remark) - unpaid_maestro_manager.delete_maestro(maestro_id) - - -test_send_mail() -# test_db_work() \ No newline at end of file diff --git a/src/web/python/batch/test_requests.py b/src/web/python/batch/test_requests.py deleted file mode 100644 index 322e4bd..0000000 --- a/src/web/python/batch/test_requests.py +++ /dev/null @@ -1,6 +0,0 @@ -import requests - -url = 'http://google.com' -res = requests.get(url=url) -print(res.status_code) -print(res.text) \ No newline at end of file diff --git a/src/web/python/batch/unpaid_maestro_manager.py b/src/web/python/chocomae/batch/unpaid_maestro_manager.py similarity index 81% rename from src/web/python/batch/unpaid_maestro_manager.py rename to src/web/python/chocomae/batch/unpaid_maestro_manager.py index 7383e88..f509784 100644 --- a/src/web/python/batch/unpaid_maestro_manager.py +++ b/src/web/python/chocomae/batch/unpaid_maestro_manager.py @@ -1,5 +1,11 @@ -from db_manager import DBConnectParams -from db_manager import DBManager +import sys +import os +root = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + '/..') +# lib = os.path.join(root, 'lib') +sys.path.insert(0, root) +# print(sys.path) +from lib.database.db_manager import DBConnectParams +from lib.database.db_manager import DBManager class UnpaidMaestroManager: diff --git a/src/web/python/chocomae/helloworld.py b/src/web/python/chocomae/helloworld.py new file mode 100644 index 0000000..2185ce5 --- /dev/null +++ b/src/web/python/chocomae/helloworld.py @@ -0,0 +1,12 @@ +import sys +import os +from lib.mail.module_b import ModuleB + +print('path :') +path_list = sys.path +print('path count : {}'.format(len(path_list))) +for item in path_list: + print(item) + +mb = ModuleB() +mb.print() \ No newline at end of file diff --git a/src/web/python/batch/db_manager.py b/src/web/python/chocomae/lib/database/db_manager.py similarity index 90% rename from src/web/python/batch/db_manager.py rename to src/web/python/chocomae/lib/database/db_manager.py index df30e3e..1d0f3bb 100644 --- a/src/web/python/batch/db_manager.py +++ b/src/web/python/chocomae/lib/database/db_manager.py @@ -1,7 +1,12 @@ +import sys +import os +root = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + '/..' + '/..') +sys.path.insert(0, root) + import datetime import time import pymysql -from db_setting import DBSetting +from lib.database.db_setting import DBSetting class DBConnectParams: diff --git a/src/web/python/batch/db_setting.py b/src/web/python/chocomae/lib/database/db_setting.py similarity index 100% rename from src/web/python/batch/db_setting.py rename to src/web/python/chocomae/lib/database/db_setting.py diff --git a/src/web/python/chocomae/lib/database/module_a.py b/src/web/python/chocomae/lib/database/module_a.py new file mode 100644 index 0000000..d5aba23 --- /dev/null +++ b/src/web/python/chocomae/lib/database/module_a.py @@ -0,0 +1,4 @@ + +class ModuleA: + def print(self): + print('module A') \ No newline at end of file diff --git a/src/web/python/batch/mail_sender.py b/src/web/python/chocomae/lib/mail/mail_sender.py similarity index 100% rename from src/web/python/batch/mail_sender.py rename to src/web/python/chocomae/lib/mail/mail_sender.py diff --git a/src/web/python/chocomae/lib/mail/module_b.py b/src/web/python/chocomae/lib/mail/module_b.py new file mode 100644 index 0000000..999d413 --- /dev/null +++ b/src/web/python/chocomae/lib/mail/module_b.py @@ -0,0 +1,7 @@ +from lib.database.module_a import ModuleA + + +class ModuleB: + def print(self): + ma = ModuleA() + ma.print() \ No newline at end of file diff --git a/src/web/python/chocomae/remove_unpaid_maestro.py b/src/web/python/chocomae/remove_unpaid_maestro.py new file mode 100644 index 0000000..987d0c0 --- /dev/null +++ b/src/web/python/chocomae/remove_unpaid_maestro.py @@ -0,0 +1,5 @@ +from batch.unpaid_maestro_manager import UnpaidMaestroManager + +umMan = UnpaidMaestroManager() +maestro_list = umMan.get_unpaid_7days_maestro_list() +print(maestro_list) \ No newline at end of file