Custom Query (104 matches)

Filters
 
Or
 
  
 
Columns

Show under each result:


Results (13 - 15 of 104)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Ticket Resolution Summary Owner Reporter
#106 invalid anonymous user ? schwa ftputiluser
Description

The signature of FTPHost function requires a user and a password.

It would be good if the default was to user an anonymous user (like in basic ftp clients).

I also could not find an example about how to login with anonymous user in the documentation

#102 fixed ftplib.error_reply: 226 Transfer complete. schwa ftputiluser
Description

ftplib version: 3.2

Python version: 2.7.10

FTP server: Synology FTP server ready (this is a NAS appliance)

Client OS version: CentOS linux 6.4 - Linux serverXXX 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

I have implemented a python script using ftplib to transfer several images at night, usually it transfers about 1500 to 2000 images (between 500 Mb to 700 Mb) daily... the thing is that sometimes the script fails and throws the traceback:

Traceback (most recent call last):
  File "/etc/scripts/proyecto_escaneo/envia.py", line 227, in <module>
    main()
  File "/etc/scripts/proyecto_escaneo/envia.py", line 178, in main
    resp_stf = send_to_ftp(local_path,remote_path,row[2])
  File "/etc/scripts/proyecto_escaneo/envia.py", line 100, in send_to_ftp
    transfer = ftp.upload_if_newer(source_file_path, dest_file_path)
  File "/root/.pyenv/versions/2.7.10/lib/python2.7/site-packages/ftputil/host.py", line 471, in upload_if_newer
    callback=callback)
  File "/root/.pyenv/versions/2.7.10/lib/python2.7/site-packages/ftputil/file_transfer.py", line 184, in copy_file
    target_fobj = target_file.fobj()
  File "/root/.pyenv/versions/2.7.10/lib/python2.7/site-packages/ftputil/file_transfer.py", line 94, in fobj
    return self._host.open(self.name, self.mode)
  File "/root/.pyenv/versions/2.7.10/lib/python2.7/site-packages/ftputil/host.py", line 180, in open
    host = self._available_child()
  File "/root/.pyenv/versions/2.7.10/lib/python2.7/site-packages/ftputil/host.py", line 158, in _available_child
    host._session.pwd()
  File "/root/.pyenv/versions/2.7.10/lib/python2.7/ftplib.py", line 587, in pwd
    return parse257(resp)
  File "/root/.pyenv/versions/2.7.10/lib/python2.7/ftplib.py", line 872, in parse257
    raise error_reply, resp
ftplib.error_reply: 226 Transfer complete.

The script runs from cron at a specific time... this is the code I am using to transfer the files:

def send_to_ftp(source_path, dest_path, codigo_reg):
    resp = 0
    files = []
    counter = 0
    error_trans = 0

    if os.path.isdir(source_path):
        for item in os.listdir(source_path):
            files.append(item)

        try:

            ftp = ftputil.FTPHost(HOST_FTP, USER_FTP, PASSWD_FTP)

            if not ftp.path.isdir(dest_path):
                logging.info("Se creara directorio remoto: %s" % (dest_path))
                ftp.makedirs(dest_path)


            for file in files:
                counter += 1
                source_file_path = source_path + file
                dest_file_path = dest_path + file
                transfer = ftp.upload_if_newer(source_file_path, dest_file_path)
                if transfer == True:
                    logging.info("%d Archivo %s tranferido con exito a %s" % (counter, source_file_path, dest_file_path))
                else:
                    logging.warning("%d Archivo %s NO se transfirio con exito (o ya existia en destino) a %s" % (counter, source_file_path, dest_file_path))
                    error_trans += 1

        except ftputil.error.FTPError, e:
            logging.critical("Error send_to_ftp() %s" % (e.args[0]))
            resp = -1
            return [resp, counter, error_trans, e]

        finally:
            if hasattr(ftputil, "ftp"):
                ftp.close()
    else:
        resp = -2

    return [resp, counter, error_trans]

This only happens a sometimes and I can't figure it out!!!

Any help would be very helpful.

#100 fixed Wrong handling of non-ASCII characters in paths under Python 2 schwa schwa
Description

For ticket #96, I was looking into the exact behavior of ftputil when encoding and decoding file system paths for FTPHost.listdir.

It turned out that under Python 2 ftputil doesn't work correctly with paths that contain non-ASCII characters. The intended behavior is:

Path argument is a byte string:

  • Characters are sent as they are, even if they are non-ASCII characters (i. e. character codes greater than 127).
  • Returned lines are byte strings (latin1-encoded, i. e. the data sent by the server) if the listdir argument was a byte string.

Path argument is a unicode string:

  • Unicode strings are assumed to be decoded from latin1. For example, to get the contents of the directory b'\xc3\xa4bc' (corresponding to "äbc"), the unicode string must be b'\xc3\xa4bc'.decode("latin1").
  • Returned lines are unicode strings (decoded assuming latin1 encoding).

This behavior is indeed seen when ftputil runs under Python 3. (By the way, the handling of unicode strings is strange, but it's used to be compatible with Python 3's ftplib.FTP implementation. If ftputil.FTPHost would behave differently, it couldn't work with non-ASCII paths that were created with ftplib.FTP under Python 3.)

Under Python 2, pure ASCII strings work as above regardless of being byte strings or unicode strings. However, when the strings contain characters with codes greater than 127, FTPHost.listdir raises a UnicodeEncodeError, again both for byte strings and unicode strings.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Note: See TracQuery for help on using queries.