Hi guys,
Apologies for posting this here instead of logging an issue on the Google Code page, but I'm having issues with it accepting my issue submission.
In GAM 3.2, calling the following command will fail:
gam user
f...@example.com update drivefileacl y7fqhiurqh8q9
b...@example.com role writer
With the following stack trace:
Traceback (most recent call last):
File "gam.py", line 7340, in <module>
File "gam.py", line 1755, in updateDriveFileACL
NameError: global name 'perm_type' is not defined
GAM Version:Dito GAM 3.2
Python 2.7.6 64-bit final
google-api-python-client 1.2
Windows-7-6.1.7601-SP1 AMD64
I've taken a look at the source, and the issue here is that when the body dict is instantiated in the updateDriveFileAcl function, the 'type' key is assigned the variable perm_type - this variable isn't defined anywhere in the code.
I've fixed the issue in the code (line 1755) by replacing the following line:
body = {u'type': perm_type}
with:
body = {}
This instantiates an empty dict (the original dict instantiation looks like it might have been copy/pasted in from the addDriveFileACL function above it?). I can't see how the 'type' key/value pair would be used in a permissions update, so this should be fine, although there may be a nicer way to fix the issue.
I've tested this with variety of ACL updates (writer, reader, etc) and the command listed at the top of this now works with no issues.
Also, it's not noted anywhere in the documentation that for an ownership transfer to be successful using the updateFileACL command, you need to pass "TransferOwnership True" as part of the command (otherwise it'll fail with a "You don't have permission to transfer ownership" error.) This could maybe be handled in the code by setting TransferOwnership to True implicitly if the new role passed is "owner."
Otherwise, the command winds up looking like:
gam user
f...@example.com update drivefileacl y7fqhiurqh8q9
b...@example.com role owner transferownership true
Which seems a little redundant :)