first commit

This commit is contained in:
R5600U_PC 2024-04-05 16:35:40 +09:00
parent 492dc677e4
commit 68d9ba9ae7
6 changed files with 88 additions and 0 deletions

0
config.ini Normal file
View File

33
configurator.py Normal file
View File

@ -0,0 +1,33 @@
from PyQt5.QtWidgets import QMainWindow, QTabWidget, QWidget, QVBoxLayout, QLabel, QLineEdit, QPushButton, QApplication, QMessageBox
import logging
from playwright_handler import login_and_update_api_keys
logger = logging.getLogger(__name__)
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle('Market API Configurator')
self.setGeometry(100, 100, 800, 600)
self.tabWidget = QTabWidget()
self.setCentralWidget(self.tabWidget)
for i in range(1, 6):
tab = QWidget()
self.tabWidget.addTab(tab, f'사업자 {i}')
layout = QVBoxLayout()
tab.setLayout(layout)
layout.addWidget(QLabel('사업자 이름:'))
layout.addWidget(QLineEdit())
layout.addWidget(QLabel('사업자 번호:'))
layout.addWidget(QLineEdit())
applySettingsBtn = QPushButton('마켓 설정 적용')
layout.addWidget(applySettingsBtn)
applySettingsBtn.clicked.connect(self.applyMarketSettings)
def applyMarketSettings(self):
QMessageBox.information(self, "성공", "마켓 설정이 성공적으로 변경되었습니다.")

17
log_config.py Normal file
View File

@ -0,0 +1,17 @@
import logging
import sys
def setup_logging():
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
file_handler = logging.FileHandler('app.log')
file_handler.setLevel(logging.INFO)
file_handler.setFormatter(formatter)
logger.addHandler(file_handler)
stream_handler = logging.StreamHandler(sys.stdout)
stream_handler.setLevel(logging.DEBUG)
stream_handler.setFormatter(formatter)
logger.addHandler(stream_handler)

11
main.py Normal file
View File

@ -0,0 +1,11 @@
from PyQt5.QtWidgets import QApplication
from configurator import MainWindow
from log_config import setup_logging
import sys
if __name__ == "__main__":
setup_logging()
app = QApplication(sys.argv)
mainWindow = MainWindow()
mainWindow.show()
sys.exit(app.exec_())

25
playwright_handler.py Normal file
View File

@ -0,0 +1,25 @@
from playwright.async_api import async_playwright
import asyncio
import logging
logger = logging.getLogger(__name__)
async def login_and_update_api_keys(username, password, market_settings):
try:
logger.info("Playwright 세션 시작")
async with async_playwright() as p:
browser = await p.chromium.launch(headless=True)
page = await browser.new_page()
await page.goto('https://www.percenty.com/login')
await page.fill('.ant-input:nth-child(4)', username)
await page.fill('.ant-input:nth-child(1)', password)
await page.click('.ant-btn-primary')
await asyncio.sleep(5) # 대기
logger.info("API 키 업데이트 완료")
await browser.close()
except Exception as e:
logger.error(f"API 키 업데이트 중 오류 발생: {e}", exc_info=True)
await browser.close()

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
PyQt5
playwright