o d@s@dZddlZddlZddlZddlZddlmZ dddZdS) z' Implementation for FTP upload method. N) dputhelperc Cszt}||||rtjd|Wn tjy6} ztjd| tdWYd} ~ nd} ~ ww|d|d} |dkrFd} nt| } z| || Wn(tj yhtjd tdYnt y{tjd tdYnw| |dkz| |Wn.tj y} z!| jr| jd dd d krtjdtdnWYd} ~ nd} ~ ww|rtjd||D]} tj| \} }zc|rtjd| |rzt| j}Wntyd}|rtjd| Ynwt| d}|r tj||tj|d}tjd|tj|d||d|tjdtjWqtjy} zetjd| t| tjro| jro| jd dd dkrotjd|tjdWYd} ~ qt| tjr| jr| jd dddkrtjd|rtjdtdWYd} ~ qd} ~ wwz|WdSty} z|rtjd | WYd} ~ dSd} ~ ww)!zU Upload the files via FTP. (Could need a bit more error-checking.) zD: FTP-Connection to host: %s z3Connection failed, aborting. Check your network %s N@z password: anonymouszdput@packages.debian.orgzWrong Password zServer closed the connection r550z'Directory to upload to does not exist. zD: Directory to upload to: %s zD: Uploading File: %s z(D: Determining size of file '%s' failed rb)ptype progressfsizez Uploading %s: zSTOR izdone. z%s 553z1Leaving existing %s on the server and continuing aNOTE: This existing file may have been previously uploaded partially. For official Debian upload queues, the dcut(1) utility can be used to remove this file, and after an acknowledgement mail is received in response to dcut, the upload can be re-initiated. 5zNote: This error might indicate a problem with your passive_ftp setting. Please consult dput.cf(5) for details on this configuration option. zAD: Should exit silently now, but will throw exception for debug. zgD: Exception %s while attempting to quit ftp session. D: Throwing an exception for debugging purposes. )ftplibFTPconnectsysstdoutwrite all_errorsexitgetpasslogin error_permEOFErrorset_pasvcwdargsospathsplitstatst_size ExceptionopenrFileWithProgressflush storbinaryclose isinstanceErrorquit)fqdnrincomingfiles_to_uploaddebugftp_modeprogressportftp_connectionepromptpassword file_pathfile_directory file_namerfr=#/usr/share/dput/dput/methods/ftp.pyuploads                r?)rr)__doc__rrr rhelperrr?r=r=r=r>s