No such file or directory python in linux only (coming from windows)
- by user1804633
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