3 Replies Latest reply: Dec 4, 2012 6:49 PM by 977998 RSS

    import os in jython


      recently, I started using wlst as a jython-module, so I could use it in external functions.
      However, since that moment, I can't use the os module anymore. Specifically, I need os.listdir(), which appareantly does not exist in the supplied version for jython.
      Any known workarounds?


        • 1. OSError: [Errno 0] chdir not supported in Java:
          Hi All,

          We use Oracle 11G SOA Suite. Under Unix, I have tried to use os.chdir and noticed I get the >> OSError: [Errno 0] chdir not supported in Java:
          Isn't the os library written in Java under Jython ? Looks like it is a native call to the OS ? I guess its the case with Peter's observation as well.
          Any thoughts.
          • 2. Re: import os in jython

            No sure why your not able to import os module. Environmental settings, classpaths? I have imported os and os.path

            Once your able to access os module...
            I tried this and it returns a list os.listdir(path='myPathString')
            e.g print os.listdir(path='.')
            gives me a list of files under the current directory. I had to provide the optional parameter Path within listdir.

            myList = ArrayList()
            myList = os.listdir(path='.')

            for item in myList:
            print item

            Hope this helps.

            Edited by: 974995 on Dec 4, 2012 4:36 PM

            Edited by: 974995 on Dec 4, 2012 4:41 PM
            • 3. Re: OSError: [Errno 0] chdir not supported in Java: - Unimplemented
              Hi All

              Noticed that the javaos.py has a unimplemented function...no wonder it does not work!!!

              def chdir(path):
              Change the current working directory to the specified path.
              raise OSError(0, 'chdir not supported in Java', path)

              Is there a work around?