Why an error message is considered an error in ftplib

import ftplib
server = '192.168.1.109'
user = 'bob'
password = 'likes_sandwiches'

box = ftplib.FTP(server)
box.login(user, password)

s = box.mkd('\\a\\this4\\')
box.close()

x = raw_input('done, eat sandwiches now')

This returns:

Traceback (last last call): File "C: \ scripts \ ftp_test.py", line 25, in s = box.mkd ('\ E \ this4 \') File "C: \ Python26 \ lib \ ftplib.py" , line 553, in mkd return parse257 (resp) File "C: \ Python26 \ lib \ ftplib.py", line 651, in parse257 raise error_reply, resp error_reply: 250 directory was created successfully.

He successfully created the directory, but he considers his mistake! WTF?

I plan to create many directories in a loop, how can I do this without interrupting it every time it successfully creates one directory?

+3
source share
2 answers

RFC 959 (FTP), MKD 257. , , FTP-, .

, ftplib:

if resp[:3] != '257':
    raise error_reply, resp
+1

ftplib 257, "", <pathname> ; 250 , mkd, , .

voidcmd, MKD /your/path - , , , .

+1

Source: https://habr.com/ru/post/1759220/


All Articles