handling oldFiles

main
alex 2024-05-03 22:47:45 +02:00
parent 68c587f30a
commit 53c84dd613
6 changed files with 26 additions and 6 deletions

View File

@ -83,6 +83,8 @@ def replacePlaceholder():
if __name__ == "__main__":
utils.move_files_back_from_old_files()
print(f"Creating package label for {customer_first_name}")
downloadFile(shipping_label_url, "label.png")

View File

@ -4,6 +4,13 @@ import yaml
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import os
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')))
from libs.utils import utils
utils.move_files_back_from_old_files()
STATIC_PATH = "../../groupsData/shx-order-voucher-code-activated/"

View File

@ -3,7 +3,6 @@ import sys
import json
import qrcode
import subprocess
import PyPDF2
import sys
import os
@ -115,7 +114,6 @@ def CreateCrmActivityLink(customerId):
print(f"CreateCrmActivityLink req error {response.status_code}")
sys.exit(1)
req("10 % Gutschein", "https://shinnex.de")
req("5 € Gutschein", productUrl)
req("10 € Gutschein", f"https://docs.google.com/forms/d/e/1FAIpQLSd2GXFbidzazuQnh_Lf2mgeA1npuwHkWjsdmjrxDmSkDQTfew/viewform?entry.347359844={orderId}")
@ -141,7 +139,7 @@ def create_qrcode(type, id):
img.save(f"./{type}.png")
# Display the generated QR code image
img.show()
#img.show()
def GetCustomerActivityLinks(customerId):
@ -220,7 +218,6 @@ def createPdf(sourceHtml, outputPdf):
"--headless",
"--no-sandbox",
"--disable-gpu",
"--debug=1",
"--print-to-pdf=" + outputPdf,
"--run-all-compositor-stages-before-draw",
"--virtual-time-budget=10000",
@ -237,6 +234,8 @@ def createPdf(sourceHtml, outputPdf):
if __name__ == "__main__":
utils.move_files_back_from_old_files()
CheckIfCrmCustomerExists()
ReplaceHtmlVariables()

View File

@ -41,7 +41,6 @@ def createPdf(sourceHtml, outputPdf):
"--headless",
"--no-sandbox",
"--disable-gpu",
"--debug=1",
"--print-to-pdf=" + outputPdf,
"--run-all-compositor-stages-before-draw",
"--virtual-time-budget=10000",
@ -57,6 +56,8 @@ def createPdf(sourceHtml, outputPdf):
sys.exit(1)
if __name__ == "__main__":
utils.move_files_back_from_old_files()
# replace placeholders in index.js
p_type_id = product_type_id.split(" ")[0].split("#")[1]

View File

@ -1,5 +1,7 @@
import subprocess
import PyPDF2
import os
import shutil
def clear_workspace(files):
if not files or not isinstance(files, list) or len(files) == 0:
@ -31,4 +33,13 @@ def merge_pdfs(pdf1_path, pdf2_path, output_path):
# save the combined PDF
with open(output_path, 'wb') as output_file:
pdf_writer.write(output_file)
pdf_writer.write(output_file)
# If a script failes the files are moved to the old_files directory so we need to move them back so that the paths defined in the files are correct
def move_files_back_from_old_files():
# check if old_files directory exists and move files back
if os.path.exists("oldFiles"):
for file in os.listdir("oldFiles"):
shutil.move(os.path.join("oldFiles", file), file)
os.rmdir("oldFiles")