Add rmd() (remove directory command); fix comment in parse257.
In login(), force passwd and acct to '' when they are None (this can happen in the test program!).
This commit is contained in:
parent
0d530cedd7
commit
9824509d3e
|
@ -287,6 +287,8 @@ class FTP:
|
||||||
def login(self, user = '', passwd = '', acct = ''):
|
def login(self, user = '', passwd = '', acct = ''):
|
||||||
'''Login, default anonymous.'''
|
'''Login, default anonymous.'''
|
||||||
if not user: user = 'anonymous'
|
if not user: user = 'anonymous'
|
||||||
|
if not passwd: passwd = ''
|
||||||
|
if not acct: acct = ''
|
||||||
if user == 'anonymous' and passwd in ('', '-'):
|
if user == 'anonymous' and passwd in ('', '-'):
|
||||||
thishost = socket.gethostname()
|
thishost = socket.gethostname()
|
||||||
# Make sure it is fully qualified
|
# Make sure it is fully qualified
|
||||||
|
@ -450,6 +452,10 @@ class FTP:
|
||||||
resp = self.sendcmd('MKD ' + dirname)
|
resp = self.sendcmd('MKD ' + dirname)
|
||||||
return parse257(resp)
|
return parse257(resp)
|
||||||
|
|
||||||
|
def rmd(self, dirname):
|
||||||
|
'''Remove a directory.'''
|
||||||
|
return self.voidcmd('RMD ' + dirname)
|
||||||
|
|
||||||
def pwd(self):
|
def pwd(self):
|
||||||
'''Return current working directory.'''
|
'''Return current working directory.'''
|
||||||
resp = self.sendcmd('PWD')
|
resp = self.sendcmd('PWD')
|
||||||
|
@ -508,8 +514,8 @@ def parse227(resp):
|
||||||
|
|
||||||
|
|
||||||
def parse257(resp):
|
def parse257(resp):
|
||||||
'''Parse the '257' response for a MKD or RMD request.
|
'''Parse the '257' response for a MKD or PWD request.
|
||||||
This is a response to a MKD or RMD request: a directory name.
|
This is a response to a MKD or PWD request: a directory name.
|
||||||
Returns the directoryname in the 257 reply.'''
|
Returns the directoryname in the 257 reply.'''
|
||||||
|
|
||||||
if resp[:3] <> '257':
|
if resp[:3] <> '257':
|
||||||
|
|
Loading…
Reference in New Issue