google-drive-recursive-ownership
google-drive-recursive-ownership copied to clipboard
Support UTF-8 filenames/folders
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éáóçãú" [email protected] false
Changing all files at path "Téáóçãú" to owner "[email protected]"
Prefix: [u'T\xe9\xe1\xf3\xe7\xe3\xfa']
Use this link for authorization: link
Verification code: code
User [email protected] 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 :(
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.
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.
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.
I just added this after the imports
reload(sys)
sys.setdefaultencoding('utf-8')
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.
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.