Login, default anonymous.
(self, user = '', passwd = '', acct = '')
| 393 | return self.ntransfercmd(cmd, rest)[0] |
| 394 | |
| 395 | def login(self, user = '', passwd = '', acct = ''): |
| 396 | '''Login, default anonymous.''' |
| 397 | if not user: |
| 398 | user = 'anonymous' |
| 399 | if not passwd: |
| 400 | passwd = '' |
| 401 | if not acct: |
| 402 | acct = '' |
| 403 | if user == 'anonymous' and passwd in {'', '-'}: |
| 404 | # If there is no anonymous ftp password specified |
| 405 | # then we'll just use anonymous@ |
| 406 | # We don't send any other thing because: |
| 407 | # - We want to remain anonymous |
| 408 | # - We want to stop SPAM |
| 409 | # - We don't want to let ftp sites to discriminate by the user, |
| 410 | # host or country. |
| 411 | passwd = passwd + 'anonymous@' |
| 412 | resp = self.sendcmd('USER ' + user) |
| 413 | if resp[0] == '3': |
| 414 | resp = self.sendcmd('PASS ' + passwd) |
| 415 | if resp[0] == '3': |
| 416 | resp = self.sendcmd('ACCT ' + acct) |
| 417 | if resp[0] != '2': |
| 418 | raise error_reply(resp) |
| 419 | return resp |
| 420 | |
| 421 | def retrbinary(self, cmd, callback, blocksize=8192, rest=None): |
| 422 | """Retrieve data in binary mode. A new port is created for you. |