Thursday, March 21, 2013

java package 'weblogic.time' has no attribute 'localtime'

In a WLST module I am trying to print the current time with:

time.strftime("%Y%m%d_%H%M%S", time.localtime())

When I run within a wlst session, it works. When I run it from a script, it fails with the error

java package 'weblogic.time' has no attribute 'localtime'

I guess that some wlst operations import weblogic.time under the cover.

The only workaround I found is:

from time import localtime, strftime

strftime("%Y%m%d_%H%M%S", localtime())

This is REALLY silly, but this is real life.

1 comment:

Mallyboy said...

I believe this is because when the WLST connect() command executes the weblogic.time library overrides the (Python) time library.

Another solution to your problem is then to add:
import time as pytime

right upfront (before the connect() is issued) and then refer to the functions with:

pytime.time() etc