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

Support UTF-8 filenames/folders #26

Open
Nottt opened this issue Jul 12, 2019 · 6 comments
Open

Support UTF-8 filenames/folders #26

Nottt opened this issue Jul 12, 2019 · 6 comments

Comments

@Nottt
Copy link

Nottt commented Jul 12, 2019

The current script will fail with lots of folders and filenames.

I can get past the UnicodeEncodeError: with this:

reload(sys)
sys.setdefaultencoding('utf-8')

But then it goes on but nothing is shared/changed

python transfer.py "Téáóçãú" backup@.email false
Changing all files at path "Téáóçãú" to owner "backup@.email"
Prefix: [u'T\xe9\xe1\xf3\xe7\xe3\xfa']
Use this link for authorization: link
Verification code: code
User backup@.email is permission ID 05411747774099128436.
Gathering file listings for prefix []...
Folder: Téáóçãú ([], 1CkIpP7rvMP5R1AKaLNEzjRhMGKr2tcPf)
Gathering file listings for prefix [u'T\xe9\xe1\xf3\xe7\xe3\xfa']...
Folder: solto ([], 1aHUnS8GV4TGI_j5CAhuAOHYl4-5kwT8s)

Any chance we can get this? This is still the best method to change permissions with google drive but it chokes with lots of characters :(

@davidstrauss
Copy link
Owner

Do you have any guidance on the best way to add the support? I'm happy to look at Pull Requests, but it's been years since I've looked deeply at the Google Drive APIs that would be applicable to this situation.

@Nottt
Copy link
Author

Nottt commented Jul 12, 2019

It's not the Google Drive API, it's a python language issue. Python is notorious for sucking with UTF-8.

I have the script working locally now as far as changing ownership and everything, but you are still printing this wrong:

Prefix: [u'T\xe9\xe1\xf3\xe7\xe3\xfa']

I can do a PR if you want, but I'm no developer by any means and the quick stuff I found to try to fix this didn't work.

Previously I thought the script didn't work, but I didn't have any files in that folder so that's why nothing was happening. I thought it would just change the root folder permission too.

@davidstrauss
Copy link
Owner

Thanks. It would still be helpful to know how you're working around the issue, even if it's not the right thing to commit to the code here.

@Nottt
Copy link
Author

Nottt commented Jul 12, 2019

I just added this after the imports

reload(sys)
sys.setdefaultencoding('utf-8')

@lesantos
Copy link

I had the same problem, but I noticed that the error is only when printing the drive_item['title'], so I commented the prints and it is working fine.
I'd tried to fix with some unicode magic, but I failed. I read it should be simpler with python 3.

@davidstrauss
Copy link
Owner

From @Nottt's comment:

reload(sys)
sys.setdefaultencoding('utf-8')

I don't have much time to devote to this project, but I'm happy to take a pull request that adds this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants