This discussion is archived
3 Replies Latest reply: Dec 4, 2012 4:49 PM by 977998 RSS

import os in jython

944567 Newbie
Currently Being Moderated
Hi,

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?

Greetings,

Peter
  • 1. OSError: [Errno 0] chdir not supported in Java:
    977998 Newbie
    Currently Being Moderated
    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
    977998 Newbie
    Currently Being Moderated
    Peter,

    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.
    cheers

    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
    977998 Newbie
    Currently Being Moderated
    Hi All

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

    def chdir(path):
    """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?
    Thanks

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points