No such file or directory python in linux only (coming from windows)

Posted by user1804633 on Stack Overflow See other posts from Stack Overflow or by user1804633
Published on 2012-11-27T04:13:39Z Indexed on 2012/11/27 5:04 UTC
Read the original article Hit count: 92

Filed under:

I have the same exact directory structure within a folder in Windows & in Linux (Debian) - where the script is along the static + dataoutput folders

How come the following code works fine in Windows, but gives a no such file or directory path error in linux?

@app.route('/_getdataoutputfilelisting')
def getdataoutputfilelisting():
    listoffilesindataouput = getfiles('static/dataoutput')
    return jsonify(listoffiles = listoffilesindataouput) 

def getfiles(dirpath):
    a = [s for s in os.listdir(dirpath)
         if os.path.isfile(os.path.join(dirpath, s))]
    a.sort(key=lambda s: os.path.getmtime(os.path.join(dirpath, s)))
    a.reverse()
    return a

Is there a way to make it universal such that it works in both OSs?

Thanks

© Stack Overflow or respective owner

Related posts about python