diff --git a/.gitignore b/.gitignore index 69ada1a..05f492f 100644 --- a/.gitignore +++ b/.gitignore @@ -176,4 +176,5 @@ cython_debug/ *.json *.pdf -data/* \ No newline at end of file +data/* +*.html \ No newline at end of file diff --git a/daemon.py b/daemon.py index 02a10e7..9a56048 100644 --- a/daemon.py +++ b/daemon.py @@ -6,6 +6,8 @@ import os from webSimple import generate_pdf_list_html from email_pdf_downloader import read_emails +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) + def run_daemon(): while True: try: @@ -14,8 +16,8 @@ def run_daemon(): except Exception as e: logging.error(f"An error occurred: {e}") - directory = '/scrapy/amznMailConverter/data' - output_file = os.path.join(directory, "/scrapy/amznMailConverter/index.html") + directory = SCRIPT_DIR+'/data' + output_file = os.path.join(directory, SCRIPT_DIR+"/index.html") generate_pdf_list_html(directory, output_file) time.sleep(60) # Sleep for 1 minute between checks diff --git a/email_pdf_downloader.py b/email_pdf_downloader.py index 1c9af74..d15c87a 100644 --- a/email_pdf_downloader.py +++ b/email_pdf_downloader.py @@ -20,15 +20,15 @@ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) def get_credentials(): creds = None - if os.path.exists('/scrapy/amznMailConverter/token.json'): - creds = Credentials.from_authorized_user_file('token.json', SCOPES) + if os.path.exists(SCRIPT_DIR+'/token.json'): + creds = Credentials.from_authorized_user_file(SCRIPT_DIR+'/token.json', SCOPES) if not creds or not creds.valid: if creds and creds.expired and creds.refresh_token: creds.refresh(Request()) else: - flow = InstalledAppFlow.from_client_secrets_file('/scrapy/amznMailConverter/credentials.json', SCOPES) + flow = InstalledAppFlow.from_client_secrets_file(SCRIPT_DIR+'/credentials.json', SCOPES) creds = flow.run_local_server(port=0) - with open('/scrapy/amznMailConverter/token.json', 'w') as token: + with open(SCRIPT_DIR+'/token.json', 'w') as token: token.write(creds.to_json()) return creds diff --git a/webSimple.py b/webSimple.py index 88c5ea8..1d1eb5d 100644 --- a/webSimple.py +++ b/webSimple.py @@ -1,7 +1,6 @@ #!/scrapy/venvs/amznMailConverter/bin/python import os - from datetime import datetime def generate_pdf_list_html(directory, output_file="pdf_list.html"): @@ -14,24 +13,26 @@ def generate_pdf_list_html(directory, output_file="pdf_list.html"): # Get the current timestamp generation_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S") - # HTML content with dark and blue-themed Material Design styling + # HTML content with updated styling html_content = f''' PDF Files

Available PDF Files for Download

+