Re: Temat:, Re: IOError: [Errno 22] invalid mode ('wb') or filename: in windows xp while making tarfile
On 25 Sie, 07:33, Dennis Lee Bieber wrote: > On Mon, 24 Aug 2009 14:23:41 -0700 (PDT), ryniek > declaimed the following in gmane.comp.python.general: > > > C:\Users\Ryniek's WinSe7en\Documents\My Dropbox\Aplikacje > > \Moje_aplikacje\Pythonowe_aplikacje\Skrypty>python ba > > ckuper.py -f E:\APLIKACJE\nowegg.exe E:\ MyGG > > > > > OSError: [Errno 22] Invalid argument: 'E:\\MyGG(2009-08-24 > > 23:18:25).tar.bz2' > > " > > WHERE in your program are you creating that file name? Based upon > the invocation line, all you are supplying is the E:\MyGG part... > Somewhere you are creating a timestamp and attaching that to the prefix. > > THAT is where you need to get rid of the colons -- the ones in the > timestamp. Instead of 23:18:25 (or whatever the next run generates) you > want something like 23_18_25... > -- > Wulfraed Dennis Lee Bieber KD6MOG > wlfr...@ix.netcom.com HTTP://wlfraed.home.netcom.com/ Yep, i realized that it were THOSE colons. Thanks very much. I think i must work on my perceptivity : P Thanks again. -- http://mail.python.org/mailman/listinfo/python-list
Re: Temat:,Re: IOError: [Errno 22] invalid mode ('wb') or filename: in windows xp while making tarfile
ryniek wrote: On 24 Sie, 22:34, ryniek wrote: On 24 Sie, 16:56, John Machin wrote: On Aug 25, 12:46 am, Tim Golden wrote: Dave Angel wrote: You still haven't gotten rid of those illegal colons in the filename. They're not legal in Windows, as has been pointed out a couple of times in this thread. Ummm.. Colons are of course legal in Windows filenames as designating That is the most inappropriate "of course" I've seen for quite a while. the Alternate Data Streams: OK, so s/illegal/evil/ Ok, but how to get rid of those colons? Is it necessary? I dealt with it. Had to change 'w:bz2' into 'w|bz2'. But now have another problem: It's the same problem, asked and answered. Why not read the replies of the people telling you what the problem is? -- Erik Max Francis && m...@alcyone.com && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis If the sky should fall, hold up your hands. -- (a Spanish proverb) -- http://mail.python.org/mailman/listinfo/python-list
Re: Temat:, Re: IOError: [Errno 22] invalid mode ('wb') or filename: in windows xp while making tarfile
You shouldn't want either a colon or a pipe symbol in the filename string (not counting the drive letter prefix). A single colon gives you surprising behavior, and two will give you Invalid Argument. See inline responses. ryniek wrote: On 24 Sie, 22:34, ryniek wrote: Ok, but how to get rid of those colons? Is it necessary? I dealt with it. Had to change 'w:bz2' into 'w|bz2'. Looks to me like you're putting a pipe in again (unless that's just an artifact of the mail system) But now have another problem: " C:\Users\Ryniek's WinSe7en\Documents\My Dropbox\Aplikacje \Moje_aplikacje\Pythonowe_aplikacje\Skrypty>python ba ckuper.py -f E:\APLIKACJE\nowegg.exe E:\ MyGG Checking permissions for reading and writing... Traceback (most recent call last): File "backuper.py", line 194, in main_meth() File "backuper.py", line 186, in main_meth paq.backup_file(pars.options.filename[0], pars.options.filename [1], pars.options.filename[2]) File "backuper.py", line 114, in backup_file backup_obj =arfile.open(dest, 'w|bz2') File "E:\WinSe7en Apps\APLIKACJE\ActiveState Python 2.6\lib \tarfile.py", line 1675, in open _Stream(name, filemode, comptype, fileobj, bufsize), File "E:\WinSe7en Apps\APLIKACJE\ActiveState Python 2.6\lib \tarfile.py", line 400, in __init__ fileobj =LowLevelFile(name, mode) File "E:\WinSe7en Apps\APLIKACJE\ActiveState Python 2.6\lib \tarfile.py", line 373, in __init__ self.fd =s.open(name, mode) OSError: [Errno 22] Invalid argument: 'E:\\MyGG(2009-08-24 23:18:25).tar.bz2' " Still have two erroneous colons in that string. The one after the E is okay. When i type path with foreward slashes, Python converts them to double backslashes :P " C:\Users\Ryniek's WinSe7en\Documents\My Dropbox\Aplikacje \Moje_aplikacje\Pythonowe_aplikacje\Skrypty>python backuper.py -f E:/ APLIKACJE/nowegg.exe E:/ MyGG Checking permissions for reading and writing... Traceback (most recent call last): File "backuper.py", line 194, in main_meth() File "backuper.py", line 186, in main_meth paq.backup_file(pars.options.filename[0], pars.options.filename [1], pars.options.filename[2]) File "backuper.py", line 114, in backup_file backup_obj =arfile.open(dest, 'w|bz2') File "E:\WinSe7en Apps\APLIKACJE\ActiveState Python 2.6\lib \tarfile.py", line 1675, in open _Stream(name, filemode, comptype, fileobj, bufsize), File "E:\WinSe7en Apps\APLIKACJE\ActiveState Python 2.6\lib \tarfile.py", line 400, in __init__ fileobj =LowLevelFile(name, mode) File "E:\WinSe7en Apps\APLIKACJE\ActiveState Python 2.6\lib \tarfile.py", line 373, in __init__ self.fd =s.open(name, mode) OSError: [Errno 22] Invalid argument: 'E:\\MyGG(2009-08-24 23:20:19).tar.bz2' " I tried raw string also, but nothing helps. :-/ If a string has a backslash in it, and it is printed, you see a single backslash. But if it is output with repr(), then you see it doubled, just as you would do if you were typing it in as a literal. That does NOT mean that it has a double backslash, it just means that particular display formatting shows you that. Try the following to see what I mean: >>> st = r"e:\testing\again.txt" >>> st 'e:\\testing\\again.txt' >>> print st e:\testing\again.txt >>> print [st, st] ['e:\\testing\\again.txt', 'e:\\testing\\again.txt'] >>> Since you don't know how a particular error message was constructed, you don't know for sure which way to interpret the results. That comes with practice. In the meantime, if you print a simple string with simple print, you should be able to see it fine. Incidentally, in nearly every case, Windows ignores extra backslashes. So that's not likely to be your problem. Get rid of those colons, without replacing them with pipes. DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Temat:, Re: IOError: [Errno 22] invalid mode ('wb') or filename: in windows xp while making tarfile
On 24 Sie, 22:34, ryniek wrote: > On 24 Sie, 16:56, John Machin wrote: > > > On Aug 25, 12:46 am, Tim Golden wrote: > > > > Dave Angel wrote: > > > > You still haven't gotten rid of those illegal colons in the filename. > > > > They're not legal in Windows, as has been pointed out a couple of times > > > > in this thread. > > > > Ummm.. Colons are of course legal in Windows filenames as designating > > > That is the most inappropriate "of course" I've seen for quite a > > while. > > > > the Alternate Data Streams: > > > OK, so s/illegal/evil/ > > Ok, but how to get rid of those colons? > Is it necessary? I dealt with it. Had to change 'w:bz2' into 'w|bz2'. But now have another problem: " C:\Users\Ryniek's WinSe7en\Documents\My Dropbox\Aplikacje \Moje_aplikacje\Pythonowe_aplikacje\Skrypty>python ba ckuper.py -f E:\APLIKACJE\nowegg.exe E:\ MyGG Checking permissions for reading and writing... Traceback (most recent call last): File "backuper.py", line 194, in main_meth() File "backuper.py", line 186, in main_meth paq.backup_file(pars.options.filename[0], pars.options.filename [1], pars.options.filename[2]) File "backuper.py", line 114, in backup_file backup_obj = tarfile.open(dest, 'w|bz2') File "E:\WinSe7en Apps\APLIKACJE\ActiveState Python 2.6\lib \tarfile.py", line 1675, in open _Stream(name, filemode, comptype, fileobj, bufsize), File "E:\WinSe7en Apps\APLIKACJE\ActiveState Python 2.6\lib \tarfile.py", line 400, in __init__ fileobj = _LowLevelFile(name, mode) File "E:\WinSe7en Apps\APLIKACJE\ActiveState Python 2.6\lib \tarfile.py", line 373, in __init__ self.fd = os.open(name, mode) OSError: [Errno 22] Invalid argument: 'E:\\MyGG(2009-08-24 23:18:25).tar.bz2' " When i type path with foreward slashes, Python converts them to double backslashes :P " C:\Users\Ryniek's WinSe7en\Documents\My Dropbox\Aplikacje \Moje_aplikacje\Pythonowe_aplikacje\Skrypty>python backuper.py -f E:/ APLIKACJE/nowegg.exe E:/ MyGG Checking permissions for reading and writing... Traceback (most recent call last): File "backuper.py", line 194, in main_meth() File "backuper.py", line 186, in main_meth paq.backup_file(pars.options.filename[0], pars.options.filename [1], pars.options.filename[2]) File "backuper.py", line 114, in backup_file backup_obj = tarfile.open(dest, 'w|bz2') File "E:\WinSe7en Apps\APLIKACJE\ActiveState Python 2.6\lib \tarfile.py", line 1675, in open _Stream(name, filemode, comptype, fileobj, bufsize), File "E:\WinSe7en Apps\APLIKACJE\ActiveState Python 2.6\lib \tarfile.py", line 400, in __init__ fileobj = _LowLevelFile(name, mode) File "E:\WinSe7en Apps\APLIKACJE\ActiveState Python 2.6\lib \tarfile.py", line 373, in __init__ self.fd = os.open(name, mode) OSError: [Errno 22] Invalid argument: 'E:\\MyGG(2009-08-24 23:20:19).tar.bz2' " I tried raw string also, but nothing helps. :-/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Temat:, Re: IOError: [Errno 22] invalid mode ('wb') or filename: in windows xp while making tarfile
On 24 Sie, 16:56, John Machin wrote: > On Aug 25, 12:46 am, Tim Golden wrote: > > > Dave Angel wrote: > > > You still haven't gotten rid of those illegal colons in the filename. > > > They're not legal in Windows, as has been pointed out a couple of times > > > in this thread. > > > Ummm.. Colons are of course legal in Windows filenames as designating > > That is the most inappropriate "of course" I've seen for quite a > while. > > > the Alternate Data Streams: > > OK, so s/illegal/evil/ Ok, but how to get rid of those colons? Is it necessary? -- http://mail.python.org/mailman/listinfo/python-list
Re: Temat:, Re: IOError: [Errno 22] invalid mode ('wb') or filename: in windows xp while making tarfile
On Aug 25, 12:46 am, Tim Golden wrote: > Dave Angel wrote: > > You still haven't gotten rid of those illegal colons in the filename. > > They're not legal in Windows, as has been pointed out a couple of times > > in this thread. > > Ummm.. Colons are of course legal in Windows filenames as designating That is the most inappropriate "of course" I've seen for quite a while. > the Alternate Data Streams: OK, so s/illegal/evil/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Temat:,Re: IOError: [Errno 22] invalid mode ('wb') or filename: in windows xp while making tarfile
Dave Angel wrote: You still haven't gotten rid of those illegal colons in the filename. They're not legal in Windows, as has been pointed out a couple of times in this thread. Ummm.. Colons are of course legal in Windows filenames as designating the Alternate Data Streams: with open ("c:/temp/test.txt", "w") as f: f.write ("base text") with open ("c:/temp/test.txt:blah", "w") as f: f.write ("ADS text") print open ("c:/temp/test.txt:blah").read () On the other hand, though, you can't have more than one of them: with open ("c:/temp/test.txt:blah:blah2", "w") as f: f.write ("ADS text2") should raise an error. TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: Temat:,Re: IOError: [Errno 22] invalid mode ('wb') or filename: in windows xp while making tarfile
Ryniek90 wrote: John Machin wrote: Erik Max Francis alcyone.com> writes: I also suspect the "pipe" symbol. I don't know if it's an invalid character to Windows, but it's certainly a bad idea. The '|' character means something special to the shell. The "pipe" character is not a valid character in a Windows file. Despite the OP's message wrapping the filename in "pipes", there are no pipes in the filename in the traceback to which he posted a link. Wrapping the filename in "pipes" and the cryptic reference to "the '|\U' literal fault" appear to be side-issue bogglements. >>> open('boggle|txt', 'wb') Traceback (most recent call last): File "", line 1, in IOError: [Errno 22] invalid mode ('wb') or filename: 'boggle|txt' >>> open('|boggle.txt|', 'wb') Traceback (most recent call last): File "", line 1, in IOError: [Errno 22] invalid mode ('wb') or filename: '|boggle.txt|' Sorry, but i don't know where those pipes came from : P The proper path is "C:\\Users\\Ryniek's WinSe7en\\MyNewGGBackup(2009-08-23 14:59:02).tar.bz2" and that string literal is "\U", without any pipes :) The truth is that script works on linux (ubuntu) but not on windows (neither Win7 nor WinXP). Maybe it's good idea to use raw string for specifing those paths? As i mentioned later, some python users had the same problem with this IOError ( like here: http://www.daniweb.com/forums/thread174552.html or here: http://groups.google.com/group/sympy/browse_thread/thread/c42aca3eb532928c ). You still haven't gotten rid of those illegal colons in the filename. They're not legal in Windows, as has been pointed out a couple of times in this thread. DaveA -- http://mail.python.org/mailman/listinfo/python-list
Temat:,Re: IOError: [Errno 22] invalid mode ('wb') or filename: in windows xp while making tarfile
John Machin wrote: Erik Max Francis alcyone.com> writes: I also suspect the "pipe" symbol. I don't know if it's an invalid character to Windows, but it's certainly a bad idea. The '|' character means something special to the shell. The "pipe" character is not a valid character in a Windows file. Despite the OP's message wrapping the filename in "pipes", there are no pipes in the filename in the traceback to which he posted a link. Wrapping the filename in "pipes" and the cryptic reference to "the '|\U' literal fault" appear to be side-issue bogglements. >>> open('boggle|txt', 'wb') Traceback (most recent call last): File "", line 1, in IOError: [Errno 22] invalid mode ('wb') or filename: 'boggle|txt' >>> open('|boggle.txt|', 'wb') Traceback (most recent call last): File "", line 1, in IOError: [Errno 22] invalid mode ('wb') or filename: '|boggle.txt|' Sorry, but i don't know where those pipes came from : P The proper path is "C:\\Users\\Ryniek's WinSe7en\\MyNewGGBackup(2009-08-23 14:59:02).tar.bz2" and that string literal is "\U", without any pipes :) The truth is that script works on linux (ubuntu) but not on windows (neither Win7 nor WinXP). Maybe it's good idea to use raw string for specifing those paths? As i mentioned later, some python users had the same problem with this IOError ( like here: http://www.daniweb.com/forums/thread174552.html or here: http://groups.google.com/group/sympy/browse_thread/thread/c42aca3eb532928c ). -- http://mail.python.org/mailman/listinfo/python-list