From ed56635eb94442c77adcca2dd984902b6694d6de Mon Sep 17 00:00:00 2001 From: KWON Date: Mon, 30 Jun 2025 14:32:52 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=91=EC=97=85=20=ED=8F=B4=EB=8D=94=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + {data => app}/config.sample.py | 0 {data => app}/gnu_autoupload.py | 19 ++++++++++--------- {data => app}/run.sh | 2 +- {data => app}/weather.py | 0 {data => app}/weather_capture.py | 6 +++++- 6 files changed, 17 insertions(+), 11 deletions(-) rename {data => app}/config.sample.py (100%) rename {data => app}/gnu_autoupload.py (93%) rename {data => app}/run.sh (54%) rename {data => app}/weather.py (100%) rename {data => app}/weather_capture.py (93%) diff --git a/.gitignore b/.gitignore index 77c312b..66cd2f8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ config.py data/__pycache__/ +app/__pycache__/ diff --git a/data/config.sample.py b/app/config.sample.py similarity index 100% rename from data/config.sample.py rename to app/config.sample.py diff --git a/data/gnu_autoupload.py b/app/gnu_autoupload.py similarity index 93% rename from data/gnu_autoupload.py rename to app/gnu_autoupload.py index fcf229d..08c0672 100644 --- a/data/gnu_autoupload.py +++ b/app/gnu_autoupload.py @@ -163,11 +163,12 @@ def main(): MAIN['content'] = weather_content today = datetime.today().strftime('%Y%m%d') - script_dir = os.path.dirname(os.path.abspath(__file__)) - capture_script = os.path.join(script_dir, 'weather_capture.py') + data_dir = '/data' # 파일 저장 및 업로드 디렉토리 + + capture_script = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'weather_capture.py') weather_filename = f'weather_capture_{today}.png' - weather_file = os.path.join(script_dir, weather_filename) - thumb_file = os.path.join(script_dir, 'thumb.jpg') + weather_file = os.path.join(data_dir, weather_filename) + thumb_file = os.path.join(data_dir, 'thumb.jpg') if not capture_image(capture_script, weather_file): return @@ -190,14 +191,14 @@ def main(): ) try: - # weather_file만 삭제, thumb.jpg는 삭제하지 않음 - if os.path.isfile(weather_file): - os.remove(weather_file) - print(f"[정리 완료] 캡처 이미지 삭제됨: {weather_file}") + ## weather_file만 삭제, thumb.jpg는 삭제하지 않음 + #if os.path.isfile(weather_file): + # os.remove(weather_file) + # print(f"[정리 완료] 캡처 이미지 삭제됨: {weather_file}") + pass except Exception as e: print(f"[삭제 오류] {type(e).__name__}: {e}") - if __name__ == "__main__": main() diff --git a/data/run.sh b/app/run.sh similarity index 54% rename from data/run.sh rename to app/run.sh index 5a7a0db..4f98546 100644 --- a/data/run.sh +++ b/app/run.sh @@ -1,3 +1,3 @@ #!/bin/bash echo "run.sh 시작: $(date '+%Y-%m-%d %H:%M:%S')" -python3 /data/gnu_autoupload.py >> /proc/1/fd/1 2>&1 +python3 /app/gnu_autoupload.py >> /proc/1/fd/1 2>&1 diff --git a/data/weather.py b/app/weather.py similarity index 100% rename from data/weather.py rename to app/weather.py diff --git a/data/weather_capture.py b/app/weather_capture.py similarity index 93% rename from data/weather_capture.py rename to app/weather_capture.py index 74d346e..fe3e404 100644 --- a/data/weather_capture.py +++ b/app/weather_capture.py @@ -65,7 +65,11 @@ try: )) # 저장 경로 설정 - save_path = os.path.join(script_dir, f'weather_capture_{TODAY}.png') + # 기존 + # save_path = os.path.join(script_dir, f'weather_capture_{TODAY}.png') + # 수정 + save_path = os.path.join('/data', f'weather_capture_{TODAY}.png') + # 요소 스크린샷 저장 target_element.screenshot(save_path)