all in one task for order
parent
7ae95c9291
commit
1d6ad5e927
|
@ -0,0 +1,99 @@
|
||||||
|
{
|
||||||
|
"category": "Shinnex",
|
||||||
|
"name": "All-in-One Bestelltask",
|
||||||
|
"globalInputs": [],
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"name": "Gummibärchen einpacken",
|
||||||
|
"onFinish": "pause",
|
||||||
|
"undoPossible": false,
|
||||||
|
"repeatPossible": true,
|
||||||
|
"scriptPath": "empty.py",
|
||||||
|
"parameters": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Produktschilder ausdrucken",
|
||||||
|
"onFinish": "pause",
|
||||||
|
"undoPossible": false,
|
||||||
|
"repeatPossible": true,
|
||||||
|
"scriptPath": "product-label-script.py",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"parameterName": "label_paper_position",
|
||||||
|
"type": "text",
|
||||||
|
"displayName": "Position auf dem A4 Blatt (Beginnend mit 1 von oben links) (Mit Komma trennbar wie z. B. 1,3,7)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parameterName": "product_type_id",
|
||||||
|
"type": "select",
|
||||||
|
"displayName": "Produkttyp auswählen",
|
||||||
|
"options": [
|
||||||
|
"#32420; Gizmo die Eidechse; Grün, Blau, Orange; (Glänzend)",
|
||||||
|
"#92784; Gizmo die Eidechse; Glitzer Grün; (Seidenmatt)",
|
||||||
|
"#36521; Charlie das Häschen; Hellbraun; (Matt)",
|
||||||
|
"#48273; Charlie das Häschen; Gold; (Glänzend)",
|
||||||
|
"#71936; Ruby die Schlange; Feuerrot; (Glänzend)",
|
||||||
|
"#58324; Ruby die Schlange; Rot/Blau; (Glänzend)",
|
||||||
|
"#21433; Bruno der Dino; Grün/Blau/Orange; (Glänzend)",
|
||||||
|
"#57953; Bruno der Dino; Rot/Blau; (Glänzend)",
|
||||||
|
"#90578; Bruno der Dino; Gold; (Glänzend)",
|
||||||
|
"#51563; Bruno der Dino; Himmelblau; (Fluoreszierend)"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Gutscheincodes für Bestellung erstellen",
|
||||||
|
"onFinish": "pause",
|
||||||
|
"undoPossible": false,
|
||||||
|
"repeatPossible": true,
|
||||||
|
"scriptPath": "order-voucher-codes-script.py",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"parameterName": "orderId",
|
||||||
|
"type": "text",
|
||||||
|
"displayName": "Bestellnummer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parameterName": "customerEmail",
|
||||||
|
"type": "text",
|
||||||
|
"displayName": "E-Mail vom Kunden"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parameterName": "customerName",
|
||||||
|
"type": "text",
|
||||||
|
"displayName": "Vorname vom Kunden"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parameterName": "productUrl",
|
||||||
|
"type": "text",
|
||||||
|
"displayName": "URL vom Produkt (Shopify) (z. B. https://shinnex.de/products/gizmo) (für Direktweiterleitung 5 € Gutschein QR-Code)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parameterName": "discountCode",
|
||||||
|
"type": "text",
|
||||||
|
"displayName": "10 % Gutscheincode für den Kunden (in Shopify erstellen)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Versandlabel erstellen",
|
||||||
|
"onFinish": "pause",
|
||||||
|
"undoPossible": false,
|
||||||
|
"repeatPossible": true,
|
||||||
|
"scriptPath": "order-package-label-script.py",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"parameterName": "shipping_label_url",
|
||||||
|
"type": "text",
|
||||||
|
"displayName": "Bild-URL des Versandlabels"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parameterName": "customer_first_name",
|
||||||
|
"type": "text",
|
||||||
|
"displayName": "Vorname des Kunden"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')))
|
||||||
|
|
||||||
|
from libs.utils import utils
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
utils.delete_folder("oldFiles")
|
||||||
|
|
||||||
|
utils.execute_another_group_task("../../groups/shx-order-package-label/", "script.py")
|
|
@ -0,0 +1,11 @@
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')))
|
||||||
|
|
||||||
|
from libs.utils import utils
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
utils.delete_folder("oldFiles")
|
||||||
|
|
||||||
|
utils.execute_another_group_task("../../groups/shx-order-voucher-codes/", "script.py")
|
|
@ -0,0 +1,9 @@
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')))
|
||||||
|
|
||||||
|
from libs.utils import utils
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
utils.execute_another_group_task("../../groups/shx-product-label/", "script.py")
|
Binary file not shown.
|
@ -2,13 +2,23 @@ import subprocess
|
||||||
import PyPDF2
|
import PyPDF2
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def clear_workspace(files):
|
def clear_workspace(files):
|
||||||
if not files or not isinstance(files, list) or len(files) == 0:
|
if not files or not isinstance(files, list) or len(files) == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
for file in files:
|
for file in files:
|
||||||
subprocess.run(["rm", file])
|
if os.path.exists(file):
|
||||||
|
os.remove(file)
|
||||||
|
|
||||||
|
|
||||||
|
def delete_folder(folder_path):
|
||||||
|
try:
|
||||||
|
shutil.rmtree(folder_path)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error deleting the folder {folder_path}: {e}")
|
||||||
|
|
||||||
|
|
||||||
def merge_pdfs(pdf1_path, pdf2_path, output_path):
|
def merge_pdfs(pdf1_path, pdf2_path, output_path):
|
||||||
|
@ -43,3 +53,63 @@ def move_files_back_from_old_files():
|
||||||
for file in os.listdir("oldFiles"):
|
for file in os.listdir("oldFiles"):
|
||||||
shutil.move(os.path.join("oldFiles", file), file)
|
shutil.move(os.path.join("oldFiles", file), file)
|
||||||
os.rmdir("oldFiles")
|
os.rmdir("oldFiles")
|
||||||
|
|
||||||
|
|
||||||
|
# copy the tasks files from another task to the current runningTasks to execute it
|
||||||
|
# be aware of that in your work directory the python script has not the same name as the target script because it will be overwriten
|
||||||
|
def execute_another_group_task(folder_path, script_file_name):
|
||||||
|
work_directory = os.getcwd() # get current folder path
|
||||||
|
|
||||||
|
copy_files(folder_path, work_directory)
|
||||||
|
clear_workspace(["index.json", "requirements.txt"])
|
||||||
|
|
||||||
|
execute_python_file(script_file_name)
|
||||||
|
|
||||||
|
|
||||||
|
def execute_python_file(file_path):
|
||||||
|
if not os.path.exists(file_path):
|
||||||
|
print(f"The file {file_path} does not exist.")
|
||||||
|
sys.exit(1)
|
||||||
|
return
|
||||||
|
|
||||||
|
if not file_path.endswith('.py'):
|
||||||
|
print("The specified file is not a Python file.")
|
||||||
|
sys.exit(1)
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
#base_dir = os.path.dirname(os.path.abspath(file_path))
|
||||||
|
#os.chdir(base_dir) # Change to the directory of the script
|
||||||
|
subprocess.run(['python3.9', os.path.basename(file_path)] + sys.argv[1:], check=True)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print(f"Error executing the file: {e}")
|
||||||
|
sys.exit(1)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"An unexpected error occurred: {e}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def copy_files(source_folder, destination_folder):
|
||||||
|
if not os.path.exists(source_folder):
|
||||||
|
print(f"The source folder {source_folder} does not exist.")
|
||||||
|
sys.exit(1)
|
||||||
|
return
|
||||||
|
|
||||||
|
if not os.path.exists(destination_folder):
|
||||||
|
print(f"The destination folder {destination_folder} does not exist.")
|
||||||
|
sys.exit(1)
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
# List all files in the source folder
|
||||||
|
files = os.listdir(source_folder)
|
||||||
|
|
||||||
|
# Copy each file to the destination folder
|
||||||
|
for file in files:
|
||||||
|
source_path = os.path.join(source_folder, file)
|
||||||
|
destination_path = os.path.join(destination_folder, file)
|
||||||
|
shutil.copy2(source_path, destination_path)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"An error occurred while copying files: {e}")
|
||||||
|
sys.exit(1)
|
Loading…
Reference in New Issue