BNA8/.resources/4a09061ecd72294b5eeaf0e445343d97b139ac5373f0b9402295c61a3320a16c
2025-08-18 15:23:02 +04:00

33 lines
1.0 KiB
Plaintext

import os
LOG = system.util.logger("HMI Setup")
def upload():
system.gui.messageBox("Please provide the file location of the Description of Operations...")
path = system.file.openFile('pdf')
if path == None:
system.gui.messageBox("No path given!")
else:
# Load file contents as csv:
tags = {}
try:
project = system.util.getProjectName()
print "Opening file..."
with open(path, 'rb') as pdf:
payload = { "data": pdf.read() }
print "Uploading file..."
system.util.sendMessage(project, "setup-doo", payload, "G")
print "Done!"
except:
# In case the csv file is corrupt or in a bad format, ignore it:
system.gui.messageBox("Failed to open file!")
def store(data):
path = os.path.join(os.getcwd(), "webserver", "webapps", "main", "pdfs")
if not os.path.exists(path):
os.makedirs(path)
path = os.path.join(path, "Description of Operations.pdf")
with open(path, 'wb') as pdf:
pdf.write(data)
LOG.info("Uploaded new Description of Operations: /pdfs/Description of Operations.pdf")