molinav / gsync Goto Github PK
View Code? Open in Web Editor NEWThis project forked from iwonbigbro/gsync
RSync for Google Drive - GSync
License: BSD 3-Clause "New" or "Revised" License
This project forked from iwonbigbro/gsync
RSync for Google Drive - GSync
License: BSD 3-Clause "New" or "Revised" License
The basestring
builtin does not exist anymore in Python 3. It can be still found in libgsync.drive
.
Similarly to #1, the unicode
builtin is not available anymore in Python 3, so it should be translated properly. However, this builtin is everywhere, so it should be handled with care.
The scenario is the upload of the folder testdata
with two files into my Google Drive:
python3 bin/gsync -r -v --progress testdata/ drive://testdata
The traceback is the following:
DEBUG: TypeError("cannot convert 'SyncFileInfoDatetime' object to bytes"):
cannot convert 'SyncFileInfoDatetime' object to bytes
DEBUG: TypeError("cannot convert 'SyncFileInfoDatetime' object to bytes"):
File "/home/vic/github/python-gsync/libgsync/crawler.py",
line 194, in run
self._walk(srcpath, self._walk_callback, self._dev)
File "/home/vic/github/python-gsync/libgsync/crawler.py",
line 165, in _walk
self._sync(absfile)
File "/home/vic/github/python-gsync/libgsync/sync/__init__.py",
line 262, in __call__
self._sync(path)
File "/home/vic/github/python-gsync/libgsync/sync/__init__.py",
line 314, in _sync
self.dst.create(dst_path, src_file)
File "/home/vic/github/python-gsync/libgsync/sync/file/__init__.py",
line 468, in create
self.__create_file(path, src_obj)
File "/home/vic/github/python-gsync/libgsync/sync/file/__init__.py",
line 369, in __create_file
self._create_file(path, src)
File "/home/vic/github/python-gsync/libgsync/sync/file/remote.py",
line 113, in _create_file
info = drive.create(path, src.get_info())
File "/home/vic/github/python-gsync/libgsync/drive/__init__.py",
line 840, in create
body[key] = Drive.utf8(val)
File "/home/vic/github/python-gsync/libgsync/drive/__init__.py",
line 343, in utf8
return Drive.unicode(strval).encode("utf-8")
File "/home/vic/github/python-gsync/libgsync/drive/__init__.py",
line 319, in unicode
strval = unicode(bytes(strval))
Error: TypeError("cannot convert 'SyncFileInfoDatetime' object to bytes")
sent 0 bytes received 0 bytes 0.00 bytes/sec
As I wrote in issue #3, if I try to run gsync
with Python 3 after commit b44dfdf, I get the following traceback:
vic@onyx:~/github/python-gsync$ python3 bin/gsync --help
Traceback (most recent call last):
File "bin/gsync", line 97, in <module>
sys.exit(main())
File "bin/gsync", line 39, in main
if GsyncOptions.verbose:
AttributeError: type object 'GsyncOptions' has no attribute 'verbose'
Steps to reproduce the bug:
gsync
using Python 3:python3 bin/gsync -r -v --progress testdata/ drive://testdata
gsync
but using Python 2:python2 bin/gsync -r -v --progress testdata/ drive://testdata
DEBUG: TypeError("'NoneType' object is not iterable",):
'NoneType' object is not iterable
DEBUG: TypeError("'NoneType' object is not iterable",):
File "/home/vic/github/python-gsync/libgsync/crawler.py",
line 194, in run
self._walk(srcpath, self._walk_callback, self._dev)
File "/home/vic/github/python-gsync/libgsync/crawler.py",
line 154, in _walk
self._sync(dirpath)
File "/home/vic/github/python-gsync/libgsync/sync/__init__.py",
line 262, in __call__
self._sync(path)
File "/home/vic/github/python-gsync/libgsync/sync/__init__.py",
line 320, in _sync
self.dst.update_attrs(dst_path, src_file)
File "/home/vic/github/python-gsync/libgsync/sync/file/__init__.py",
line 482, in update_attrs
self.__update_attrs(path, src_obj)
File "/home/vic/github/python-gsync/libgsync/sync/file/__init__.py",
line 413, in __update_attrs
self._update_attrs(path, src, attrs)
File "/home/vic/github/python-gsync/libgsync/sync/file/remote.py",
line 165, in _update_attrs
st_info = list(tuple(info.statInfo))
Error: TypeError("'NoneType' object is not iterable",)
sent 0 bytes received 0 bytes 0.00 bytes/sec
So I am trying the opposite test execution from previous issues, I have a testdata
folder with two files in Google Drive and I try to sync it to my local disk:
python3 bin/gsync -r -v --progress drive://testdata ./
This is the traceback:
DEBUG: TypeError('write() argument must be str, not bytes'):
write() argument must be str, not bytes
DEBUG: TypeError('write() argument must be str, not bytes'):
File "/home/vic/github/python-gsync/libgsync/crawler.py",
line 194, in run
self._walk(srcpath, self._walk_callback, self._dev)
File "/home/vic/github/python-gsync/libgsync/crawler.py",
line 165, in _walk
self._sync(absfile)
File "/home/vic/github/python-gsync/libgsync/sync/__init__.py",
line 262, in __call__
self._sync(path)
File "/home/vic/github/python-gsync/libgsync/sync/__init__.py",
line 317, in _sync
self.dst.update_data(dst_path, src_file)
File "/home/vic/github/python-gsync/libgsync/sync/file/__init__.py",
line 479, in update_data
self.__update_data(path, src_obj)
File "/home/vic/github/python-gsync/libgsync/sync/file/__init__.py",
line 381, in __update_data
self._update_data(path, src)
File "/home/vic/github/python-gsync/libgsync/sync/file/local.py",
line 206, in _update_data
fd.write(chunk)
Error: TypeError('write() argument must be str, not bytes')
sent 0 bytes received 0 bytes 0.00 bytes/sec
Again it is a problem with handling of str
and bytes
.
This is the traceback if I force to run gsync
with Python 3:
vic@onyx:~/github/python-gsync$ python3 bin/gsync
Traceback (most recent call last):
File "bin/gsync", line 19, in <module>
from libgsync.output import verbose, debug, critical
File "/home/vic/github/python-gsync/libgsync/output.py", line 20, in <module>
sys.stdout = WRITER(os.fdopen(sys.stdout.fileno(), "w", 0), "replace")
File "/usr/lib/python3.8/os.py", line 1023, in fdopen
return io.open(fd, *args, **kwargs)
ValueError: can't have unbuffered text I/O
Steps to reproduce the issue:
gsync
using Python 3 (in my case I was using Python 3.8).gsync --authenticate
gsync
to have access to our Google Drive. After typing in the verification code, the console shows the following:Exception ignored in: <function Drive.__del__ at 0x7ff572a1ca60>
Traceback (most recent call last):
File "/home/vic/python-gsync/libgsync/drive/__init__.py",
line 415, in __del__
File "/usr/local/lib/python3.8/dist-packages/oauth2client/client.py",
line 423, in put
File "/usr/local/lib/python3.8/dist-packages/oauth2client/file.py",
line 96, in locked_put
NameError: name 'open' is not defined
This issue probably comes because of including the storage of the credentials in the destructor of the Drive
class. Maybe Python is destroying the builtins before the Drive
object is destroyed.
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.