This code works fine in Linux, but not in Windows:
import system
import tempfile, os
import zipfile
tempDir = tempfile.gettempdir()
def unzip(gwbk_path):
extractDir = os.path.join(tempDir, 'extracted').decode('unicode-escape')
# Extract the .gwbk (zip) file
with zipfile.ZipFile(gwbk_path, 'r') as zip_ref:
zip_ref.extractall(extractDir) ### bails here ###
I have a feeling it's breaking on an empty email-profiles
folder, and perhaps this cpython 2.7.4 issue is related.
any workaround ideas?
Wrapper log
INFO | jvm 1 | 2024/05/06 14:54:47 | W [p.a.script ] [14:54:47.185]: Error running action 'component.onFileReceived' on _DEV/GWBK@C/root/FileUpload: Traceback (most recent call last):
INFO | jvm 1 | 2024/05/06 14:54:47 | File "<function:runAction>", line 2, in runAction
INFO | jvm 1 | 2024/05/06 14:54:47 | File "<module:_DEV.GWBK>", line 52, in runAction
INFO | jvm 1 | 2024/05/06 14:54:47 | File "<module:_DEV.GWBK>", line 11, in unzip
INFO | jvm 1 | 2024/05/06 14:54:47 | File "C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\zipfile.py", line 1038, in extractall
INFO | jvm 1 | 2024/05/06 14:54:47 | self.extract(zipinfo, path, pwd)
INFO | jvm 1 | 2024/05/06 14:54:47 | File "C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\zipfile.py", line 1026, in extract
INFO | jvm 1 | 2024/05/06 14:54:47 | return self._extract_member(member, path, pwd)
INFO | jvm 1 | 2024/05/06 14:54:47 | File "C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\zipfile.py", line 1059, in _extract_member
INFO | jvm 1 | 2024/05/06 14:54:47 | arcname = arcname.translate(table)
INFO | jvm 1 | 2024/05/06 14:54:47 | TypeError: character mapping must return integer, None or unicode
INFO | jvm 1 | 2024/05/06 14:54:47 | project-name=_DEV, view=_DEV/GWBK@C, component=root/FileUpload
INFO | jvm 1 | 2024/05/06 14:54:47 | com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last):
INFO | jvm 1 | 2024/05/06 14:54:47 | File "<function:runAction>", line 2, in runAction
INFO | jvm 1 | 2024/05/06 14:54:47 | File "<module:_DEV.GWBK>", line 52, in runAction
INFO | jvm 1 | 2024/05/06 14:54:47 | File "<module:_DEV.GWBK>", line 11, in unzip
INFO | jvm 1 | 2024/05/06 14:54:47 | File "C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\zipfile.py", line 1038, in extractall
INFO | jvm 1 | 2024/05/06 14:54:47 | self.extract(zipinfo, path, pwd)
INFO | jvm 1 | 2024/05/06 14:54:47 | File "C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\zipfile.py", line 1026, in extract
INFO | jvm 1 | 2024/05/06 14:54:47 | return self._extract_member(member, path, pwd)
INFO | jvm 1 | 2024/05/06 14:54:47 | File "C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\zipfile.py", line 1059, in _extract_member
INFO | jvm 1 | 2024/05/06 14:54:47 | arcname = arcname.translate(table)
INFO | jvm 1 | 2024/05/06 14:54:47 | TypeError: character mapping must return integer, None or unicode
INFO | jvm 1 | 2024/05/06 14:54:47 |
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.core.PyException.doRaise(PyException.java:211)
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.core.Py.makeException(Py.java:1654)
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.core.Py.makeException(Py.java:1658)
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.core.Py.makeException(Py.java:1662)
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.core.Py.makeException(Py.java:1666)
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.pycode._pyx18.unzip$1(<module:_DEV.GWBK>:39)
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.pycode._pyx18.call_function(<module:_DEV.GWBK>)
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.core.PyTableCode.call(PyTableCode.java:173)
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.core.PyBaseCode.call(PyBaseCode.java:150)
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.core.PyFunction.__call__(PyFunction.java:426)
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.pycode._pyx18.runAction$2(<module:_DEV.GWBK>:59)
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.pycode._pyx18.call_function(<module:_DEV.GWBK>)
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.core.PyTableCode.call(PyTableCode.java:173)
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.core.PyBaseCode.call(PyBaseCode.java:150)
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.core.PyFunction.__call__(PyFunction.java:426)
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.pycode._pyx17.runAction$1(<function:runAction>:2)
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.pycode._pyx17.call_function(<function:runAction>)
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.core.PyTableCode.call(PyTableCode.java:173)
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.core.PyBaseCode.call(PyBaseCode.java:306)
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.core.PyFunction.function___call__(PyFunction.java:474)
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.core.PyFunction.__call__(PyFunction.java:469)
INFO | jvm 1 | 2024/05/06 14:54:47 | at org.python.core.PyFunction.__call__(PyFunction.java:464)
INFO | jvm 1 | 2024/05/06 14:54:47 | at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:847)
INFO | jvm 1 | 2024/05/06 14:54:47 | at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:829)
INFO | jvm 1 | 2024/05/06 14:54:47 | at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$TrackingProjectScriptManager.runFunction(ProjectScriptLifecycle.java:868)
INFO | jvm 1 | 2024/05/06 14:54:47 | at com.inductiveautomation.ignition.common.script.ScriptManager$ScriptFunctionImpl.invoke(ScriptManager.java:1010)
INFO | jvm 1 | 2024/05/06 14:54:47 | at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$AutoRecompilingScriptFunction.invoke(ProjectScriptLifecycle.java:950)
INFO | jvm 1 | 2024/05/06 14:54:47 | at com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.invoke(ScriptFunctionHelper.java:161)
INFO | jvm 1 | 2024/05/06 14:54:47 | at com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.invoke(ScriptFunctionHelper.java:98)
INFO | jvm 1 | 2024/05/06 14:54:47 | at com.inductiveautomation.perspective.gateway.action.ScriptAction.runAction(ScriptAction.java:80)
INFO | jvm 1 | 2024/05/06 14:54:47 | at com.inductiveautomation.perspective.gateway.action.ActionDecorator.runAction(ActionDecorator.java:18)
INFO | jvm 1 | 2024/05/06 14:54:47 | at com.inductiveautomation.perspective.gateway.action.SecuredAction.runAction(SecuredAction.java:44)
INFO | jvm 1 | 2024/05/06 14:54:47 | at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.lambda$call$0(ActionCollection.java:263)
INFO | jvm 1 | 2024/05/06 14:54:47 | at com.inductiveautomation.perspective.gateway.api.LoggingContext.mdc(LoggingContext.java:54)
INFO | jvm 1 | 2024/05/06 14:54:47 | at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.call(ActionCollection.java:252)
INFO | jvm 1 | 2024/05/06 14:54:47 | at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.call(ActionCollection.java:221)
INFO | jvm 1 | 2024/05/06 14:54:47 | at com.inductiveautomation.perspective.gateway.threading.BlockingTaskQueue$TaskWrapper.run(BlockingTaskQueue.java:154)
INFO | jvm 1 | 2024/05/06 14:54:47 | at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
INFO | jvm 1 | 2024/05/06 14:54:47 | at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
INFO | jvm 1 | 2024/05/06 14:54:47 | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
INFO | jvm 1 | 2024/05/06 14:54:47 | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
INFO | jvm 1 | 2024/05/06 14:54:47 | at com.inductiveautomation.perspective.gateway.threading.BlockingWork$BlockingWorkRunnable.run(BlockingWork.java:58)
INFO | jvm 1 | 2024/05/06 14:54:47 | at java.base/java.lang.Thread.run(Unknown Source)
INFO | jvm 1 | 2024/05/06 14:54:47 | Caused by: org.python.core.PyException: TypeError: character mapping must return integer, None or unicode
INFO | jvm 1 | 2024/05/06 14:54:47 | ... 43 common frames omitted