Giter VIP home page Giter VIP logo

gsync's People

Contributors

benfry avatar iwonbigbro avatar jhkrischel avatar molinav avatar mransley avatar rjferguson21 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

gsync's Issues

Remove unicode from code

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.

TypeError when gsync uploads a file on Python3

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

GsyncOptions throws AttributeError in Python 3

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'

Cannot gsync with Python2 if gsync was used with Python3

Steps to reproduce the bug:

  1. Run gsync using Python 3:
python3 bin/gsync -r -v --progress testdata/ drive://testdata
  1. Run the same command with gsync but using Python 2:
python2 bin/gsync -r -v --progress testdata/ drive://testdata
  1. Profit:
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

TypeError when gsync downloads a file on Python3

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.

Unbuffered stdout incompatible with Python 3

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

Authentication complains on Python 3

Steps to reproduce the issue:

  1. Install gsync using Python 3 (in my case I was using Python 3.8).
  2. Execute the command to set the authentication:
gsync --authenticate
  1. The console prompts the link that we have to follow to allow 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.