error sending path to Win OS
Tim Roberts
timr at probo.com
Wed Mar 16 01:35:18 EST 2005
Earl Eiland <eee at nmt.edu> wrote:
>
>A couple of you commented that I should be using os.path.join.
>Accordingly, I rewrote my code. Unfortunately, I still have the same
>problem. the following code snippet
>
>Results.SetOriginal(os.path.getsize(os.path.join(InputDirectory , x)))
>y = str(x.split('.')[0]) + '.rk'
>print InputDirectory, y
>raw_input()
>Results.SetArchive(os.path.getsize(os.path.join(InputDirectory, y)))
>
>is executed from the command line with
>C:\Documents and Settings\eeiland\Desktop> ..\Thesis\Plan2\Compressor.py
>Test_Data\ Test_Output\Results
>Test_Data\ Book1.rk, where InputDirectory (in the above snippet) =
>'Test_Data\' (I've also tried 'Test_Data', with the same results).
>
>x (in the above snippet) is an element of the list generated by
>os.listdir(InputDirectory).
>
>Output upon execution is as follows:
>Test_Data\ Book1.rk
>
>Traceback (most recent call last):
> File "C:\Documents and Settings\eeiland\Thesis\Plan2\Compressor.py",
>line 60,
>in ?
> Results.SetArchive(os.path.getsize(os.path.join(InputDirectory, y)))
> File "C:\Python24\lib\ntpath.py", line 229, in getsize
> return os.stat(filename).st_size
>OSError: [Errno 2] No such file or directory: 'Test_Data\\Book1.rk'
>
>What am I doing wrong?
My guess would be that Test_Data\Book1.rk does not exist from the point of
view of the directory where the script is running this. You might do this:
print os.getcwd()
os.system('dir ' + InputDirectory)
just to prove that you are where you think you are.
--
- Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list