codebynumbers / ftpretty Goto Github PK
View Code? Open in Web Editor NEWA wrapper for simple FTP operations: get, put, list etc.
License: MIT License
A wrapper for simple FTP operations: get, put, list etc.
License: MIT License
Hi, I love the syntax of the library over Python's own implementation, could you consider adding a get_tree
or get(recursive=True)
function?
Need to handle exception
I am not able to
>>> from ftpretty import ftpretty
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/adain/projects/transfers/exp/ftpretty.py", line 2, in <module>
from ftpretty import ftpretty
ImportError: cannot import name 'ftpretty' from 'ftpretty' (/home/adain/projects/transfers/exp/ftpretty.py)
FYI,
pip freeze
ftpretty==0.4.0
python-dateutil==2.8.2
six==1.16.0
python --version
Python 3.7.16
Line 295 in bd2104f
12:XX pm will cause issue because it doesn't overflow
12:XX pm will become 24:XX instead of 00:XX
I seem to be getting a problem using ftpretty (in this case on Py 2.7):
Traceback (most recent call last):
File "<builtin>/app_main.py", line 75, in run_toplevel
File "arinc767.py", line 11, in <module>
import edal
File "/Users/bivald/epic-data-access-layer/edal/__init__.py", line 20, in <module>
from ftpretty import ftpretty
File "build/bdist.macosx-10.10-x86_64/egg/ftpretty.py", line 25, in <module>
from compat import buffer_type, file_type
ImportError: No module named compat
When installing via pypi or git (in this case via easy_install on pypy). From what I'm seeing this can be resolved by changing setup.py from:
py_modules=['ftpretty'],
to:
py_modules=['ftpretty', 'compat'],
Not sure if that would make setuptools think you are defining the package 'compat' outside of ftpretty. Another solution would be to put the ftpretty.py in a folder named ftpretty with the code in a init.py I guess.
Not sure which is the best way to go, and it could just be me having this issue
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32
pip install ftpretty
Downloading/unpacking ftpretty
Downloading ftpretty-0.1.8.tar.gz
Running setup.py egg_info for package ftpretty
Downloading/unpacking python-dateutil (from ftpretty)
Downloading python-dateutil-2.2.tar.gz (259kB): 259kB downloaded
Running setup.py egg_info for package python-dateutil
Downloading/unpacking six (from python-dateutil->ftpretty)
Downloading six-1.7.2.tar.gz
Running setup.py egg_info for package six
no previously-included directories found matching 'documentation\_build'
Installing collected packages: ftpretty, python-dateutil, six
Running setup.py install for ftpretty
SyntaxError: ('invalid syntax', ('c:\\test\\Lib\\site-packages\\ftpretty.py', 26, 26, " relative_paths = {'.', '..'}\n"))
Running setup.py install for python-dateutil
Running setup.py install for six
no previously-included directories found matching 'documentation\_build'
Successfully installed ftpretty python-dateutil six
Cleaning up...
There is a way? get function only get freeze until the file is downloaded
Thanks.
Same as #12: TFP_TLS is new in 2.7:
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ftpretty import ftpretty
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\test\lib\site-packages\ftpretty.py", line 15, in <module>
from ftplib import FTP, FTP_TLS
ImportError: cannot import name FTP_TLS
Return true/false
Hello! I have recently downloaded the "ftpretty.py" and "compat.py" files and made a bunch of changes to it, e.g. adding checks to see if something is a file or not, adding support for the "with" keyword and getting the server welcome message.
Is it possible to integrate my changes into ftpretty?
Add an abstraction layer so this can also be used to wrap pysftp
I'm running into this when using ftpretty with secure=True
:
File "C:\Program Files\Python37\lib\site-packages\ftpretty.py", line 110, in put
self.conn.storbinary('STOR %s' % remote_file, local_file)
File "C:\Program Files\Python37\lib\ftplib.py", line 514, in storbinary
conn.unwrap()
File "C:\Program Files\Python37\lib\ssl.py", line 1094, in unwrap
s = self._sslobj.shutdown()
OSError: [Errno 0] Error
I understand this is related to https://bugs.python.org/issue10808. Is there a way to better handle this in ftpretty's put
method?
When creating a file and it fails, like in the case of writing a file to a directory, you should not be left in the destination folder.
When using put() with a path having more than one slash, i have had EOFErrror.
File ftpretty.py
It happens on line 135 self.conn.cwd(back)
It was a python issue: .cwd('..') works, .cwd('../..') works, but .cwd('../../..') and longer does'nt
I replaced lines 134 & 135 with for _ in range(depth):self.conn.cwd('..') and don't have any issue since
Hi,
For replacing static html after building a site it would be great if we could delete all files and folders recursively in one step
e.g.
f.delete_tree('.')
I tried passing port as port=22.. It doesn't work..
A directory that looks like this, with the list(extra=True)
...
...yields the exception below.
In [6]: f.list('.')
Out[6]: ['.python-version', 'myfile.txt', 'pacfile.txt', 'Site_OUT', 'Site_OUtt']
In [7]: f.list('.', extra=True)
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-7-0a3c54f93c62> in <module>
----> 1 f.list('.', extra=True)
/usr/local/lib/python3.7/site-packages/ftpretty.py in list(self, remote, extra, remove_relative_paths)
168 self.tmp_output = []
169 self.conn.dir(remote, self._collector)
--> 170 directory_list = split_file_info(self.tmp_output)
171 else:
172 directory_list = self.conn.nlst(remote)
/usr/local/lib/python3.7/site-packages/ftpretty.py in split_file_info(fileinfo)
253 )
254
--> 255 date = parts[7]
256 time = parts[8] if ':' in parts[8] else '00:00'
257 year = parts[8] if ':' not in parts[8] else current_year
IndexError: list index out of range
If you supply a trailing slash on remote dir, assume it you want use same file name
I've encountered a problem in listing contents of a ftp server:
sample code:
from ftpretty import ftpretty
ftp = ftpretty(host, user, password)
print ftp.list(extra=True)
The output is
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.4\helpers\pydev\pydevd.py", line 1741, in <module>
main()
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.4\helpers\pydev\pydevd.py", line 1735, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.4\helpers\pydev\pydevd.py", line 1135, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "<cut>ftp.py", line 8, in <module>
print ftp.list(extra=True)
File "C:\Python27\lib\site-packages\ftpretty.py", line 160, in list
directory_list = split_file_info(self.tmp_output)
File "C:\Python27\lib\site-packages\ftpretty.py", line 245, in split_file_info
date = parts[7]
IndexError: list index out of range
The line it has problems is
'drwxrwxrwt 2 999 999 4096 Sep 9 11:15 tmp'
what I've found about it is
So what is the sticky bit?
I think changing
r'([\-rwxs]{9})\s+' + # Permissions [2]
to
r'([\-rwxst]{9})\s+' + # Permissions [2]
should fix it.
Unfortunately it's still not working, the 't' letter is 9th letter of permissions (or 8th in computer speech), the test should be
drwxr-xr-t
instead of
drwxr-xr-xt
the 't' isn't an extra letter, it replaces the 'x'. I've made additional research, it turns out uppercase 'T' also exists, but even that is not all because uppercase 'S' is also possible, my suggestion would therefore be:
r'((?:[r-][w-][-xsStT]){3})\s+' + # Permissions [2]
as seen here: regexr.com/4klno
Thanks for the quick response, after creating that issue I've had some fun with ftpretty and it's great.
Originally posted by @d4os in #29 (comment)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.