added task files
parent
6c2e2c6fe9
commit
fcf6625137
|
@ -32,16 +32,14 @@
|
|||
"displayName": "Nummer der Kiste",
|
||||
"global": true
|
||||
}
|
||||
],
|
||||
"feedback": "image"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Label drucken",
|
||||
"onFinish": "nextStep",
|
||||
"undoPossible": false,
|
||||
"scriptPath": "test2.py",
|
||||
"parameters": [],
|
||||
"feedback": ""
|
||||
"parameters": []
|
||||
},
|
||||
{
|
||||
"name": "Label 1",
|
||||
|
@ -55,16 +53,14 @@
|
|||
"displayName": "Name des Kunden",
|
||||
"global": true
|
||||
}
|
||||
],
|
||||
"feedback": ""
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Label 2",
|
||||
"onFinish": "nextStep",
|
||||
"undoPossible": false,
|
||||
"scriptPath": "test2.py",
|
||||
"parameters": [],
|
||||
"feedback": ""
|
||||
"parameters": []
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ import random
|
|||
from PIL import Image, ImageDraw
|
||||
import time
|
||||
import sys
|
||||
import numpy as np
|
||||
from stl import mesh
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
|
@ -33,27 +35,68 @@ image_height = height * line_thickness
|
|||
# Hintergrundfarbe festlegen
|
||||
background_color = (255, 255, 255) # Weiß
|
||||
|
||||
# Ein neues Bild erstellen
|
||||
image = Image.new("RGB", (image_width, image_height), background_color)
|
||||
for i in range(2):
|
||||
# Ein neues Bild erstellen
|
||||
image = Image.new("RGB", (image_width, image_height), background_color)
|
||||
|
||||
# Eine Zeichenfläche für das Bild erstellen
|
||||
draw = ImageDraw.Draw(image)
|
||||
# Eine Zeichenfläche für das Bild erstellen
|
||||
draw = ImageDraw.Draw(image)
|
||||
|
||||
# Zufällige Linien zeichnen
|
||||
for _ in range(max_lines):
|
||||
start_x = random.randint(0, image_width)
|
||||
start_y = random.randint(0, image_height)
|
||||
end_x = random.randint(0, image_width)
|
||||
end_y = random.randint(0, image_height)
|
||||
# Zufällige Linien zeichnen
|
||||
for _ in range(max_lines):
|
||||
start_x = random.randint(0, image_width)
|
||||
start_y = random.randint(0, image_height)
|
||||
end_x = random.randint(0, image_width)
|
||||
end_y = random.randint(0, image_height)
|
||||
|
||||
color = (random.randint(0, 255), random.randint(
|
||||
0, 255), random.randint(0, 255))
|
||||
draw.line([(start_x, start_y), (end_x, end_y)],
|
||||
fill=color, width=line_thickness)
|
||||
color = (random.randint(0, 255), random.randint(
|
||||
0, 255), random.randint(0, 255))
|
||||
draw.line([(start_x, start_y), (end_x, end_y)],
|
||||
fill=color, width=line_thickness)
|
||||
|
||||
# Bild als Datei speichern
|
||||
image.save("generiertes_bild.png")
|
||||
# Bild als Datei speichern
|
||||
image.save("generiertes_bild"+str(i)+".png")
|
||||
|
||||
# Erstellen eines einfachen Würfelmodells
|
||||
vertices = np.array([
|
||||
# Vorderseite
|
||||
[-1, -1, 1],
|
||||
[1, -1, 1],
|
||||
[1, 1, 1],
|
||||
[-1, 1, 1],
|
||||
# Rückseite
|
||||
[-1, -1, -1],
|
||||
[1, -1, -1],
|
||||
[1, 1, -1],
|
||||
[-1, 1, -1]
|
||||
])
|
||||
|
||||
faces = np.array([
|
||||
# Vorderseite
|
||||
[0, 1, 2],
|
||||
[0, 2, 3],
|
||||
# Rückseite
|
||||
[4, 5, 6],
|
||||
[4, 6, 7],
|
||||
# Seiten
|
||||
[0, 4, 7],
|
||||
[0, 7, 3],
|
||||
[1, 5, 6],
|
||||
[1, 6, 2],
|
||||
[0, 1, 5],
|
||||
[0, 5, 4],
|
||||
[2, 3, 7],
|
||||
[2, 7, 6]
|
||||
])
|
||||
|
||||
cube_mesh = mesh.Mesh(np.zeros(faces.shape[0], dtype=mesh.Mesh.dtype))
|
||||
for i, face in enumerate(faces):
|
||||
for j, vertex_id in enumerate(face):
|
||||
cube_mesh.vectors[i][j] = vertices[vertex_id]
|
||||
|
||||
# Exportieren des Modells als .stl-Datei
|
||||
cube_mesh.save('cube.stl')
|
||||
print("Das 3D-Modell wurde erfolgreich als 'cube.stl' exportiert.")
|
||||
|
||||
"""
|
||||
try:
|
||||
|
|
|
@ -1,6 +1,32 @@
|
|||
import time
|
||||
import sys
|
||||
import random
|
||||
import string
|
||||
import zipfile
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
print("hello this is test2 lul")
|
||||
|
||||
|
||||
def generate_random_text(length):
|
||||
"""Generiert einen zufälligen Text mit der angegebenen Länge"""
|
||||
letters = string.ascii_lowercase
|
||||
return ''.join(random.choice(letters) for _ in range(length))
|
||||
|
||||
|
||||
def create_zip_file(file_name, text_length):
|
||||
"""Erstellt eine Zip-Datei mit einer Textdatei mit zufälligem Text"""
|
||||
random_text = generate_random_text(text_length)
|
||||
|
||||
with open('random_text.txt', 'w') as file:
|
||||
file.write(random_text)
|
||||
|
||||
with zipfile.ZipFile(file_name, 'w') as zip_file:
|
||||
zip_file.write('random_text.txt')
|
||||
|
||||
print(f'Die Zip-Datei "{file_name}" wurde erfolgreich erstellt.')
|
||||
|
||||
|
||||
# Beispielaufruf
|
||||
create_zip_file('random_text.zip', 100)
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
"name": "Haha",
|
||||
"onFinish": "pause",
|
||||
"undoPossible": false,
|
||||
"scriptPath": "haha.py",
|
||||
"feedback": ""
|
||||
"scriptPath": "haha.py"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -7,40 +7,35 @@
|
|||
"onFinish": "pause",
|
||||
"undoPossible": false,
|
||||
"scriptPath": "",
|
||||
"parameters": [],
|
||||
"feedback": ""
|
||||
"parameters": []
|
||||
},
|
||||
{
|
||||
"name": "Test2",
|
||||
"onFinish": "nextStep",
|
||||
"undoPossible": false,
|
||||
"scriptPath": "",
|
||||
"parameters": [],
|
||||
"feedback": ""
|
||||
"parameters": []
|
||||
},
|
||||
{
|
||||
"name": "Test3",
|
||||
"onFinish": "nextStep",
|
||||
"undoPossible": false,
|
||||
"scriptPath": "",
|
||||
"parameters": [],
|
||||
"feedback": ""
|
||||
"parameters": []
|
||||
},
|
||||
{
|
||||
"name": "Test3",
|
||||
"onFinish": "nextStep",
|
||||
"undoPossible": false,
|
||||
"scriptPath": "",
|
||||
"parameters": [],
|
||||
"feedback": ""
|
||||
"parameters": []
|
||||
},
|
||||
{
|
||||
"name": "Test3",
|
||||
"onFinish": "nextStep",
|
||||
"undoPossible": false,
|
||||
"scriptPath": "",
|
||||
"parameters": [],
|
||||
"feedback": ""
|
||||
"parameters": []
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -291,6 +291,8 @@ func RunGroupTask(args RunGroupTaskArgs) {
|
|||
}
|
||||
}
|
||||
|
||||
var taskFiles []structs.GroupTaskStepFile
|
||||
|
||||
for _, foundFile := range foundFiles {
|
||||
log.Info().Msgf("found file %s", foundFile)
|
||||
|
||||
|
@ -306,7 +308,11 @@ func RunGroupTask(args RunGroupTaskArgs) {
|
|||
log.Error().Msgf("Error writing file %s", err.Error())
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(publicPath+groupTaskStep.GroupTasksId+"/"+foundFile.FileName, bytesRead, 0644)
|
||||
systemFileName := uuid.New().String() + filepath.Ext(foundFile.FileName)
|
||||
|
||||
log.Debug().Msgf("systemFileName: %s", systemFileName)
|
||||
|
||||
err = ioutil.WriteFile(publicPath+groupTaskStep.GroupTasksId+"/"+systemFileName, bytesRead, 0644)
|
||||
|
||||
if err != nil {
|
||||
log.Error().Msgf("Error writing file %s", err.Error())
|
||||
|
@ -317,6 +323,19 @@ func RunGroupTask(args RunGroupTaskArgs) {
|
|||
if err != nil {
|
||||
log.Error().Msgf("Failed to delete created file by task %s", err.Error())
|
||||
}
|
||||
|
||||
taskFiles = append(taskFiles, structs.GroupTaskStepFile{
|
||||
OriginalFileName: foundFile.FileName,
|
||||
SystemFileName: systemFileName,
|
||||
})
|
||||
}
|
||||
|
||||
marshaledTaskFiles, err := json.Marshal(taskFiles)
|
||||
|
||||
if err != nil {
|
||||
log.Error().Msgf("Failed to marshal task files %s", err.Error())
|
||||
} else {
|
||||
groupTaskStep.Files = string(marshaledTaskFiles)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ type GroupTaskSteps struct {
|
|||
Status uint8
|
||||
Log string `gorm:"type:text"`
|
||||
Inputs string `gorm:"type:json"`
|
||||
Files string `gorm:"type:json"`
|
||||
StartedAt time.Time
|
||||
EndedAt time.Time
|
||||
LockedByUserId string `gorm:"-"` // used by the web client to ensure that only one user can edit the input value
|
||||
|
@ -62,7 +63,6 @@ type Task struct {
|
|||
UndoPossible bool `json:"undoPossible"`
|
||||
ScriptPath string `json:"scriptPath"`
|
||||
Parameters []TaskParameter `json:"parameters"` // same as task inputs
|
||||
Feedback string `json:"feedback"`
|
||||
}
|
||||
|
||||
type TaskParameter struct {
|
||||
|
@ -88,3 +88,8 @@ type GroupTaskStepsInput struct {
|
|||
ParameterName string
|
||||
Value interface{}
|
||||
}
|
||||
|
||||
type GroupTaskStepFile struct {
|
||||
OriginalFileName string // file name which was used by the python script
|
||||
SystemFileName string // file name which was set by this server
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue