我正在尝试使用python:
找到最后创建的文件夹名称directory = mx.get_env('WORKDIR')+'/Benchmarks/SPECjvm2008/SPECjvm2008/results/'
folders = os.walk(directory).next()[1]
creation_times = [(folder, os.path.getctime(folder)) for folder in folders]
creation_times.sort(key=lambda x: x[1]) # sort by creation time
但是我收到以下错误:
File "/home/taleporos/.jenkins/workspace/MaxineBench/graal/mxtool/mx.py", line 3588, in <module>
main()
File "/home/taleporos/.jenkins/workspace/MaxineBench/graal/mxtool/mx.py", line 3577, in main
retcode = c(command_args)
File "/home/taleporos/.jenkins/workspace/MaxineBench/maxine/mxmaxine/commands.py", line 432, in specjvmregression
dirfinder('specjvm')
File "/home/taleporos/.jenkins/workspace/MaxineBench/maxine/mxmaxine/commands.py", line 394, in dirfinder
print 'Folder: ', [(folder, os.path.getctime(folder)) for folder in folders]
File "/usr/lib/python2.7/genericpath.py", line 72, in getctime
return os.stat(filename).st_ctime
OSError: [Errno 2] No such file or directory: 'SPECjvm2008.002'
答案 0 :(得分:0)
只需添加整个路径:
creation_times = [(folder, os.path.getctime(directory+folder)) for folder in folders]
creation_times.sort(key=lambda x: x[1]) # sort by creation time