Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ftplib storbinary/storlines callback function #42089

Closed
philschwartz mannequin opened this issue Jun 15, 2005 · 9 comments
Closed

ftplib storbinary/storlines callback function #42089

philschwartz mannequin opened this issue Jun 15, 2005 · 9 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@philschwartz
Copy link
Mannequin

philschwartz mannequin commented Jun 15, 2005

BPO 1221598
Nosy @birkenfeld, @gpshead, @giampaolo
Files
  • ftplib.py: ftplib.FTP storbinary and storlines accept a callback func parameter
  • ftplib.py.patch: ftplib.py patched (based on python 2.4.3-8 FC5 x86_64 rpm)
  • unnamed
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/gpshead'
    closed_at = <Date 2008-01-22.00:20:20.574>
    created_at = <Date 2005-06-15.23:15:18.000>
    labels = ['library']
    title = 'ftplib storbinary/storlines callback function'
    updated_at = <Date 2008-01-22.22:28:34.632>
    user = 'https://bugs.python.org/philschwartz'

    bugs.python.org fields:

    activity = <Date 2008-01-22.22:28:34.632>
    actor = 'giampaolo.rodola'
    assignee = 'gregory.p.smith'
    closed = True
    closed_date = <Date 2008-01-22.00:20:20.574>
    closer = 'gregory.p.smith'
    components = ['Library (Lib)']
    creation = <Date 2005-06-15.23:15:18.000>
    creator = 'phil_schwartz'
    dependencies = []
    files = ['6694', '6695', '9267']
    hgrepos = []
    issue_num = 1221598
    keywords = ['patch']
    message_count = 9.0
    messages = ['48472', '48473', '48474', '48475', '48476', '61470', '61529', '61537', '61542']
    nosy_count = 6.0
    nosy_names = ['nnorwitz', 'georg.brandl', 'gregory.p.smith', 'giampaolo.rodola', 'tcarroll', 'phil_schwartz']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1221598'
    versions = ['Python 2.5']

    @philschwartz
    Copy link
    Mannequin Author

    philschwartz mannequin commented Jun 15, 2005

    The ftplib.FTP class currently allows the ability to
    provide a callback function for the retrbinary &
    retrlines methods to invoke. However, the
    corresponding storbinary and storlines methods do not.

    My ReleaseForge application currently uses the ftplib
    to send files (rather than retrieve) and it's helpful
    to know the percentage of the file that has been sent.
    For my app I subclassed ftplib.FTP and reimplemented
    storbinary to optionally accept a callback function as
    a parameter.

    However, I think this would be a useful method to
    include in the standard python distribution. I've
    attached a modified version of ftplib.py which adds
    this functionality. Unlike the retrX methods, the
    storX methods only invoke the callback function if it's
    not None so that it will not interfere with existing
    code. For completeness, the retrX methods invoke
    print_line if a callback function is not provided and
    doing so for the storX functions may be undesired.

    @philschwartz philschwartz mannequin added stdlib Python modules in the Lib dir labels Jun 15, 2005
    @birkenfeld
    Copy link
    Member

    Logged In: YES
    user_id=849994

    Please provide your patch as a diff between the original
    ftplib.py and your version. It greatly helps reviewers.

    @philschwartz
    Copy link
    Mannequin Author

    philschwartz mannequin commented Jul 3, 2006

    Logged In: YES
    user_id=420501

    Attached patch of ftplib.py (of Python 2.4.3)

    @tcarroll
    Copy link
    Mannequin

    tcarroll mannequin commented Apr 25, 2007

    I'd like to voice some support for this patch, if that's not out of line. I've used it myself in at least one app, and it would be nice to have it as a standard feature in 2.6.

    It seems odd that the callback feature is in the two retrieval methods, but not the store methods. Ruby, for example, supports it in both. Not that Python has to do everything Ruby does, but there doesn't seem to be any obstacle to adding this support.

    @nnorwitz
    Copy link
    Mannequin

    nnorwitz mannequin commented Apr 25, 2007

    Terry, your comment is definitely *not* out of line! The more people comment on patches the easier it is for us to make a decision. It would be great to comment on other patches or bugs that affect you. Thanks.

    @gpshead
    Copy link
    Member

    gpshead commented Jan 22, 2008

    accepted, committed as svn r60188 for 2.6. I also cleaned up the retr*
    and stor* doc strings.

    @giampaolo
    Copy link
    Contributor

    Could I propose the following docstring corrections?

    @@ -313,7 +313,7 @@
             expected size may be None if it could not be determined.
     
             Optional `rest' argument can be a string that is sent as the
    -        argument to a RESTART command.  This is essentially a server
    +        argument to a REST(art) command.  This is essentially a server
             marker used to tell the server to skip over any data up to the
             given marker.
             """
    @@ -403,7 +403,7 @@
             """Retrieve data in line mode.  A new port is created for you.
     
             Args:
    -          cmd: A RETR or LIST command.
    +          cmd: A RETR, LIST, NLST or MLSD command.
               callback: An optional single parameter callable that is called
                         for each line with the trailing CRLF stripped.
                         [default: print_line()]

    @gpshead
    Copy link
    Member

    gpshead commented Jan 22, 2008

    thanks. applied (well, they will be when svn.python.org comes back)

    On 1/22/08, Giampaolo Rodola' <report@bugs.python.org> wrote:

    Giampaolo Rodola' added the comment:

    Could I propose the following docstring corrections?

    @giampaolo
    Copy link
    Contributor

    Another one. On line 542:

    •    # Note that the RFC doesn't say anything about 'SIZE'
      

    + # SIZE command is defined in RFC-3659

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants