This commit is contained in:
R5600U_PC 2024-09-27 14:31:41 +09:00
parent 71a9b9a975
commit 6a96c6e4ed
8 changed files with 1724 additions and 11 deletions

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -387,6 +387,8 @@ class BrowserController:
pyautogui.hotkey('ctrl', 'v') # 클립보드 이미지 붙여넣기 pyautogui.hotkey('ctrl', 'v') # 클립보드 이미지 붙여넣기
pyautogui.press('right') # 오른쪽 입력 pyautogui.press('right') # 오른쪽 입력
self.logger.debug("이미지 붙여넣기 완료.") self.logger.debug("이미지 붙여넣기 완료.")
self.logger.debug("이미지 붙여넣기 완료로 클립보드 비우기.")
clipboardImageManager.clear_clipboard()
else: else:
self.logger.debug("클립보드가 비어있습니다.") self.logger.debug("클립보드가 비어있습니다.")
except Exception as e: except Exception as e:

107
gui.py
View File

@ -21,7 +21,7 @@ class TranslationApp(QWidget):
self.vertexAI = VertexAITranslator(self.logger, key_path) self.vertexAI = VertexAITranslator(self.logger, key_path)
self.optionHandler = None self.optionHandler = None
self.clipboardImageManager = ClipboardImageManager(self, logger, self.browser_controller) self.clipboardImageManager = ClipboardImageManager(self, logger, self.browser_controller, debug=False)
self.running = False self.running = False
@ -304,6 +304,88 @@ class TranslationApp(QWidget):
self.detail_progress_bar.setValue(percentage) self.detail_progress_bar.setValue(percentage)
self.detail_progress_bar.setFormat(f"{current_value}/{total_value}개 완료 [{percentage}%]") self.detail_progress_bar.setFormat(f"{current_value}/{total_value}개 완료 [{percentage}%]")
# def start_translation(self):
# self.logger.debug('번역 작업을 시작합니다...')
# self.running = True # 번역 작업이 시작됨
# try:
# # 1. "신규 상품 등록" 페이지로 이동
# self.logger.debug('신규 상품 등록 페이지로 이동 중...')
# self.browser_controller.go_to_new_product_page()
# # 2. 총 상품 수 수집
# self.browser_controller.scroll_page_to_bottom()
# total_products = self.browser_controller.get_total_product_count()
# if total_products == 0:
# self.logger.debug('수집할 상품이 없습니다. 작업을 종료합니다.')
# return
# self.total_progress_bar.setMaximum(total_products)
# self.total_progress_bar.setValue(0)
# completed_count = 0
# self.update_total_progress(completed_count,total_products)
# page_number = 1
# # 4. 현재 페이지의 모든 "세부사항 수정 및 업로드" 버튼 찾기
# product_buttons = self.browser_controller.get_product_edit_buttons()
# while self.running:
# self.logger.debug(f'현재 페이지: {page_number}')
# if not product_buttons:
# self.logger.debug('수정할 상품이 없습니다. 번역 작업을 종료합니다.')
# break
# # 5. 각 상품에 대해 번역 작업 수행
# for index, button in enumerate(product_buttons, start=1):
# if not self.running:
# self.logger.debug('번역 작업이 중단되었습니다.')
# break
# self.logger.debug(f'{index}/{len(product_buttons)}: 세부사항 수정 작업 중...')
# # 상품명 수집 및 수집오류 처리
# product_name = self.browser_controller.get_product_name(index)
# if product_name == "수집 오류 발생":
# self.logger.debug('상품 수집 오류, 다음 상품으로 넘어갑니다.')
# continue
# # 상품 수정 다이얼로그 열기
# self.browser_controller.open_product_edit_dialog(button)
# # 옵션 수정
# self.start_stage(0)
# self.edit_option()
# self.complete_stage(0)
# # 상세페이지 수정
# self.start_stage(1)
# self.detail_trans()
# self.complete_stage(1)
# # 수정 후 저장
# self.logger.debug('상품 세부사항 저장 중...')
# self.browser_controller.save_product_edit()
# completed_count += 1
# self.update_total_progress(completed_count,total_products)
# self.logger.debug('상품 수정 완료.')
# # 6. 다음 페이지로 이동 (있으면)
# if not self.browser_controller.go_to_next_page():
# self.logger.debug('더 이상 페이지가 없습니다. 작업을 종료합니다.')
# break
# page_number += 1
# if self.running:
# self.logger.debug('모든 상품 번역 및 저장 완료.')
# self.running = False # 작업 종료 후 상태를 False로 전환
# except Exception as e:
# self.logger.debug(f"번역 작업 중 오류 발생: {e}", exc_info=True)
# self.running = False
def start_translation(self): def start_translation(self):
self.logger.debug('번역 작업을 시작합니다...') self.logger.debug('번역 작업을 시작합니다...')
self.running = True # 번역 작업이 시작됨 self.running = True # 번역 작업이 시작됨
@ -323,13 +405,13 @@ class TranslationApp(QWidget):
self.total_progress_bar.setMaximum(total_products) self.total_progress_bar.setMaximum(total_products)
self.total_progress_bar.setValue(0) self.total_progress_bar.setValue(0)
completed_count = 0 completed_count = 0
self.update_total_progress(completed_count,total_products) self.update_total_progress(completed_count, total_products)
page_number = 1 page_number = 1
while self.running:
self.logger.debug(f'현재 페이지: {page_number}') while self.running or completed_count < total_products:
# 4. 현재 페이지의 모든 "세부사항 수정 및 업로드" 버튼 찾기 # 4. 현재 페이지의 모든 "세부사항 수정 및 업로드" 버튼 찾기
self.logger.debug(f'현재 페이지: {page_number}')
product_buttons = self.browser_controller.get_product_edit_buttons() product_buttons = self.browser_controller.get_product_edit_buttons()
if not product_buttons: if not product_buttons:
@ -338,13 +420,13 @@ class TranslationApp(QWidget):
# 5. 각 상품에 대해 번역 작업 수행 # 5. 각 상품에 대해 번역 작업 수행
for index, button in enumerate(product_buttons, start=1): for index, button in enumerate(product_buttons, start=1):
if not self.running: if not self.running or completed_count >= total_products:
self.logger.debug('번역 작업이 중단되었습니다.') self.logger.debug('번역 작업이 중단되었습니다.')
break break
self.logger.debug(f'{index}/{len(product_buttons)}: 세부사항 수정 작업 중...') self.logger.debug(f'{index}/{len(product_buttons)}: 세부사항 수정 작업 중...')
# 상품명 수집 및 수집오류 처리 # 상품명 수집 및 수집 오류 처리
product_name = self.browser_controller.get_product_name(index) product_name = self.browser_controller.get_product_name(index)
if product_name == "수집 오류 발생": if product_name == "수집 오류 발생":
self.logger.debug('상품 수집 오류, 다음 상품으로 넘어갑니다.') self.logger.debug('상품 수집 오류, 다음 상품으로 넘어갑니다.')
@ -357,7 +439,7 @@ class TranslationApp(QWidget):
self.start_stage(0) self.start_stage(0)
self.edit_option() self.edit_option()
self.complete_stage(0) self.complete_stage(0)
# 상세페이지 수정 # 상세페이지 수정
self.start_stage(1) self.start_stage(1)
self.detail_trans() self.detail_trans()
@ -368,8 +450,13 @@ class TranslationApp(QWidget):
self.browser_controller.save_product_edit() self.browser_controller.save_product_edit()
completed_count += 1 completed_count += 1
self.update_total_progress(completed_count,total_products) self.update_total_progress(completed_count, total_products)
self.logger.debug('상품 수정 완료.') self.logger.debug(f'{completed_count}/[{total_products}]개 상품 수정 완료.')
# 모든 상품이 완료되었는지 체크
if completed_count >= total_products:
self.logger.debug('모든 상품이 완료되었습니다.')
break
# 6. 다음 페이지로 이동 (있으면) # 6. 다음 페이지로 이동 (있으면)
if not self.browser_controller.go_to_next_page(): if not self.browser_controller.go_to_next_page():

View File

@ -81,8 +81,10 @@ class OptionHandler:
try: try:
checkbox = self.page.query_selector('#productMainContentContainerId .ant-checkbox-wrapper-checked') checkbox = self.page.query_selector('#productMainContentContainerId .ant-checkbox-wrapper-checked')
if checkbox: if checkbox:
self.logger.debug("전체 옵션이 체크되어 있음")
return True return True
checkbox_partial = self.page.query_selector('#productMainContentContainerId .ant-checkbox-indeterminate') checkbox_partial = self.page.query_selector('#productMainContentContainerId .ant-checkbox-indeterminate')
self.logger.debug("일부 옵션이 체크되어 있으므로 수정완료 상품으로 판단.")
return checkbox_partial is None # 일부 체크 시 False return checkbox_partial is None # 일부 체크 시 False
except Exception as e: except Exception as e:
self.logger.error(f"전체 옵션 체크박스 확인 중 오류 발생: {e}", exc_info=True) self.logger.error(f"전체 옵션 체크박스 확인 중 오류 발생: {e}", exc_info=True)

View File

@ -1,5 +1,5 @@
{ {
"option_prompt_template": "질문은 아래와 같아.\n\n가공방법\n1. 특수문자가 있을 경우 제거해줘.\n2. 원본 상품명을 참고해서, 각 옵션의 이름을 최대한 간결하게, 각 옵션의 특징만 남겨줘.\n3. 간결하게 만들어진 각 옵션명을 한국어로 일관되게 번역해줘.\n4. 각 옵션이름이 중복되면 안되.\n6. 가격문의, 문의사항, 견적, 견적문의, 예약금, 선결제, 고객센터 연락 등 옵션명을 바로 알려주지 않고 고객에게 연락을 유도하는 옵션명은 삭제해야 해.\n6. 번역된 옵션명들은 'trans_option_1': '', 'trans_option_2': '', 'trans_option_3': '', 'trans_option_4': '' 와 같은 형식(json)으로 반환해줘.\n\n원본 데이터\n{options}", "option_prompt_template": "질문은 아래와 같아.\n\n가공방법\n1. 특수문자가 있을 경우 제거해줘.\n2. 원본 상품명을 참고해서, 각 옵션의 이름을 최대한 간결하게, 각 옵션의 특징(제품의 스펙을 나타내는 크기,무게,용량,전압,전류,상품코드등)만 남겨줘.\n3. 간결하게 만들어진 각 옵션명을 한국어로 일관되게 번역해줘.\n4. 번역된 옵션 이름 중 같은 이름의 옵션이 있을 경우, 해당옵션들만 원본옵션명에서 특징들을 다시 추출해서 추가해줘.\n5. 가격문의, 문의사항, 견적, 견적문의, 예약금, 선결제, 고객센터 연락 등 옵션명을 바로 알려주지 않고 고객에게 연락을 유도하는 옵션명은 삭제해야 해.\n6. 번역된 옵션명들은 'trans_option_1': '', 'trans_option_2': '', 'trans_option_3': '', 'trans_option_4': '' 와 같은 형식(json)으로 반환해줘.\n\n원본 데이터\n{options}",
"detail_page_prompt_template": "상세 페이지 번역 요청: {detail_page}", "detail_page_prompt_template": "상세 페이지 번역 요청: {detail_page}",
"title_prompt_template": "제목 번역 요청: {title}", "title_prompt_template": "제목 번역 요청: {title}",
"price_prompt_template": "가격 가공 요청: {price}", "price_prompt_template": "가격 가공 요청: {price}",