Permission issue with Python datetime module

Sixteen Stars

Permission issue with Python datetime module

As I am new to Python, this might be me being a bit stupid, but it looks like there *may* be an issue with some Python module imports. When I try to import the datetime module, I get the following error message.....

 

WarningTraceback (most recent call last): File "<string>", line 31, in userFunction File "/opt/docker/lib/org.python.jython-standalone-2.7.0.jar/Lib/datetime.py", line 38, in <module> at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) at java.security.AccessController.checkPermission(AccessController.java:884) at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) at java.lang.SecurityManager.checkPackageAccess(SecurityManager.java:1564) at java.lang.Class.checkPackageAccess(Class.java:2372) at java.lang.Class.checkMemberAccess(Class.java:2351) at java.lang.Class.getMethods(Class.java:1614) at org.python.core.PyJavaType.init(PyJavaType.java:284) at org.python.core.PyType.createType(PyType.java:1412) at org.python.core.PyType.addFromClass(PyType.java:1348) at org.python.core.PyType.fromClass(PyType.java:1439) at org.python.core.PyJavaType.wrapJavaObject(PyJavaType.java:86) at org.python.core.adapter.ClassicPyObjectAdapter.adapt(ClassicPyObjectAdapter.java:135) at org.python.core.Py.java2py(Py.java:1788) java.security.AccessControlException: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.sun.util.calendar")

 

I've used other modules with no issue, but this one won't seems to have issues. Since the error hints at access permissions and I haven't actually used the module (I removed everything but the module import), I suspect it is a bug.


Accepted Solutions
Employee

Re: Permission issue with Python datetime module

Hello @rhall_2_0,

 

I've tried on my end and I got the same error message.The Python component has been protected to prevent some security breaches in Talend Data Streams. This module might be concerned by this if it uses some forbidden other modules. So indeed it looks like an issue/bug.

 

In the meantime, if you wanted to be able to use the current date or something like that you can use the time module for now as a workaround :

 

 

import time
t = time.time()
t_str = time.strftime('%Y-%m-%d %H:%M %Z', time.localtime(t))

output = json.loads("{}")
output= input
output['t_str']=t_str
outputList.append(output)

 


All Replies
Employee

Re: Permission issue with Python datetime module

Hello @rhall_2_0,

 

I've tried on my end and I got the same error message.The Python component has been protected to prevent some security breaches in Talend Data Streams. This module might be concerned by this if it uses some forbidden other modules. So indeed it looks like an issue/bug.

 

In the meantime, if you wanted to be able to use the current date or something like that you can use the time module for now as a workaround :

 

 

import time
t = time.time()
t_str = time.strftime('%Y-%m-%d %H:%M %Z', time.localtime(t))

output = json.loads("{}")
output= input
output['t_str']=t_str
outputList.append(output)

 

Sixteen Stars

Re: Permission issue with Python datetime module

Thanks @tgourdel. I was trying to convert from milliseconds to a datetime, but it looks like I can do that with the time module.

 

It would be nice to see the ability for us to make use of third party modules with the python component. I am interested in trying out some sentiment analysis and since there are python modules that have been written to enable that, it would be great to be able to download them through the web interface. I imagine I can ssh into the machine and use pip to install them, but it would be a real plus to be able to do that using the web interface.

Employee

Re: Permission issue with Python datetime module

Happy it suits your needs!

 

As a remark, you could achieve the same with the Type Converter processor in order to convert a timestamp to a DateTime format Smiley Wink

 

I am afraid that currently it is not possible to add external Python libraries in Talend Data streams.