MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / parse229

Function parse229

tools/python-3.11.9-amd64/Lib/ftplib.py:853–871  ·  view source on GitHub ↗

Parse the '229' response for an EPSV request. Raises error_proto if it does not contain '(|||port|)' Return ('host.addr.as.numbers', port#) tuple.

(resp, peer)

Source from the content-addressed store, hash-verified

851
852
853def parse229(resp, peer):
854 '''Parse the '229' response for an EPSV request.
855 Raises error_proto if it does not contain '(|||port|)'
856 Return ('host.addr.as.numbers', port#) tuple.'''
857 if resp[:3] != '229':
858 raise error_reply(resp)
859 left = resp.find('(')
860 if left < 0: raise error_proto(resp)
861 right = resp.find(')', left + 1)
862 if right < 0:
863 raise error_proto(resp) # should contain '(|||port|)'
864 if resp[left + 1] != resp[right - 1]:
865 raise error_proto(resp)
866 parts = resp[left + 1:right].split(resp[left+1])
867 if len(parts) != 5:
868 raise error_proto(resp)
869 host = peer[0]
870 port = int(parts[3])
871 return host, port
872
873
874def parse257(resp):

Callers 1

makepasvMethod · 0.85

Calls 4

error_replyClass · 0.85
error_protoClass · 0.70
findMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected