protocol.ftp.util Module

Utils

exception wpull.protocol.ftp.util.FTPServerError[source]

Bases: wpull.errors.ServerError

reply_code

Return reply code.

class wpull.protocol.ftp.util.ReplyCodes[source]

Bases: object

bad_sequence_of_commands = 503
cant_open_data_connection = 425
closing_data_connection = 226
command_not_implemented = 502
command_not_implemented_for_that_parameter = 504
command_not_implemented_superfluous_at_this_site = 202
command_okay = 200
connection_closed_transfer_aborted = 426
data_connection_already_open_transfer_starting = 125
data_connection_open_no_transfer_in_progress = 225
directory_status = 212
entering_passive_mode = 227
file_status = 213
file_status_okay_about_to_open_data_connection = 150
help_message = 214
name_system_type = 215
need_account_for_login = 332
need_account_for_storing_files = 532
not_logged_in = 530
pathname_created = 257
requested_action_aborted_local_error_in_processing = 451
requested_action_aborted_page_type_unknown = 551
requested_action_not_taken_file_name_not_allowed = 553
requested_action_not_taken_file_unavailable = 550
requested_action_not_taken_insufficient_storage_space = 452
requested_file_action_aborted = 552
requested_file_action_not_taken = 450
requested_file_action_okay_completed = 250
requested_file_action_pending_further_information = 350
restart_marker_reply = 110
service_closing_control_connection = 221
service_not_available_closing_control_connection = 421
service_ready_for_new_user = 220
service_ready_in_nnn_minutes = 120
syntax_error_command_unrecognized = 500
syntax_error_in_parameters_or_arguments = 501
system_status_or_system_help_reply = 211
user_logged_in_proceed = 230
user_name_okay_need_password = 331
wpull.protocol.ftp.util.convert_machine_list_time_val(text: str) → datetime.datetime[source]

Convert RFC 3659 time-val to datetime objects.

wpull.protocol.ftp.util.convert_machine_list_value(name: str, value: str) → typing.Union[source]

Convert sizes and time values.

Size will be int while time value will be datetime.datetime.

wpull.protocol.ftp.util.machine_listings_to_file_entries(listings: typing.Iterable) → typing.Iterable[source]

Convert results from parsing machine listings to FileEntry list.

wpull.protocol.ftp.util.parse_address(text: str) → typing.Tuple[source]

Parse PASV address.

wpull.protocol.ftp.util.parse_machine_listing(text: str, convert: bool=True, strict: bool=True) → typing.List[source]

Parse machine listing.

Parameters:
  • text – The listing.
  • convert – Convert sizes and dates.
  • strict – Method of handling errors. True will raise ValueError. False will ignore rows with errors.
Returns:

A list of dict of the facts defined in RFC 3659. The key names must be lowercase. The filename uses the key name.

Return type:

list

wpull.protocol.ftp.util.reply_code_tuple(code: int) → typing.Tuple[source]

Return the reply code as a tuple.

Parameters:code – The reply code.
Returns:Each item in the tuple is the digit.