<?xml version='1.0' encoding='utf-8'?>
<PyFile xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<variable name="FileNotify" type="HMI_INT"/>
<variable name="CurrentPath" type="HMI_STRING" initial="..."/>
<variable name="FileName" type="HMI_STRING"/>
from twisted.web.resource import Resource
from os import getcwd, listdir
from os.path import dirname, isfile, join
class FilesJsonResource(Resource):
def render_POST(self, request):
newstr = request.content.getvalue()
newdata = json.loads(newstr)
range_feedback = newdata['range']
slider_position = newdata['position']
visible = newdata['visible']
options = newdata['options']
path = PLCGlobals.CurrentPath
PLCGlobals.CurrentPath = path = getcwd()
if action == 'action_reset':
PLCGlobals.CurrentPath = path = getcwd()
action, sent_path = options
if action == 'onClick[acknowledge]':
if sent_path.endswith('.csv'):
PLCGlobals.FileName = sent_path
PLCGlobals.CurrentPath = path = sent_path
'thumbnail': 'folder.png'
'thumbnail': 'folder.png'
if not (isfile(join(path, f))
answer = self.renderTable(
FileList, range_feedback, slider_position, visible, extra
janswer = json.dumps(answer)
def renderTable(self, FileList, old_range, old_position, visible, extra):
if len(extra) > 0 and extra[0] != "":
fFiles = [fl for fl in FileList if extra[0] in fl]
delta = new_range - visible
new_position = 0 if delta <= 0 else delta if old_position > delta else old_position
new_visible = new_range if delta <= 0 else visible
for desc in fFiles[new_position:new_position + new_visible]:
visible_files.append(desc)
return new_range, new_position, visible_files
AddPathToSVGHMIServers(b"files", FilesJsonResource)