Simplify exception declarations

This commit is contained in:
Ross Scroggs
2016-07-30 08:29:22 -07:00
parent e39d441d01
commit e85e54b86a
3 changed files with 98 additions and 109 deletions

View File

@ -711,7 +711,7 @@ gam <UserTypeEntity> delete|del license <SKUID>
gam <UserTypeEntity> update photo <FileNamePattern> gam <UserTypeEntity> update photo <FileNamePattern>
gam <UserTypeEntity> delete|del photo gam <UserTypeEntity> delete|del photo
gam <UserTypeEntity> get photo [drivedir|(targetfolder <FilePath>)] gam <UserTypeEntity> get photo [drivedir|(targetfolder <FilePath>)] [noshow]
gam <UserTypeEntity> profile share|shared|unshare|unshared gam <UserTypeEntity> profile share|shared|unshare|unshared
gam <UserTypeEntity> show profile gam <UserTypeEntity> show profile

View File

@ -847,14 +847,7 @@ def waitOnFailure(n, retries, errMsg):
if n > 3: if n > 3:
sys.stderr.write(u'attempt {0}/{1}\n'.format(n+1, retries)) sys.stderr.write(u'attempt {0}/{1}\n'.format(n+1, retries))
class GData_exception(Exception): class GData_serviceNotApplicable(Exception): pass
def __init__(self, value):
super(GData_exception, self).__init__(value)
self.value = value
def __str__(self):
return repr(self.value)
class GData_serviceNotApplicable(GData_exception): pass
def callGData(service, function, def callGData(service, function,
soft_errors=False, throw_errors=[], soft_errors=False, throw_errors=[],
@ -934,14 +927,7 @@ def checkGAPIError(e, soft_errors=False, silent_errors=False, retryOnHttpError=F
reason = http_status reason = http_status
return (http_status, reason, message) return (http_status, reason, message)
class GAPI_exception(Exception): class GAPI_serviceNotAvailable(Exception): pass
def __init__(self, value):
super(GAPI_exception, self).__init__(value)
self.value = value
def __str__(self):
return repr(self.value)
class GAPI_serviceNotAvailable(GAPI_exception): pass
def callGAPI(service, function, def callGAPI(service, function,
silent_errors=False, soft_errors=False, throw_reasons=[], retry_reasons=[], silent_errors=False, soft_errors=False, throw_reasons=[], retry_reasons=[],

View File

@ -2,170 +2,173 @@ GAM 3.66
See GamCommands.txt for a complete syntax description. See GamCommands.txt for a complete syntax description.
Added arguments to gam info group to suppress aliases listing and include groups of which this group is a member. Added arguments to gam info group to suppress aliases listing and include groups of which this group is a member.
`gam info group <Group> ... [noaliases] [groups]` gam info group <Group> ... [noaliases] [groups]
Added argument to gam print cros to limit number of activeTimeRanges and recentUsers entries Added argument to gam print cros to limit number of activeTimeRanges and recentUsers entries
`gam print cros ... [listlimit <Number>]` gam print cros ... [listlimit <Number>]
Added argument to `gam <UserTypeEntity> signature` and `gam <UserTypeEntity> vacation` to allow specification of file character set so that extended characters can be read. Added argument to gam <UserTypeEntity> signature and gam <UserTypeEntity> vacation to allow specification of file character set so that extended characters can be read.
Credit to Steve Main for suggesting the following enhancement. Credit to Steve Main for suggesting the following enhancement.
Added argument to `gam <UserTypeEntity> signature` and `gam <UserTypeEntity> vacation` to allow pattern substitution in the signature and vacation message. Added argument to gam <UserTypeEntity> signature and gam <UserTypeEntity> vacation to allow pattern substitution in the signature and vacation message.
`gam <UserTypeEntity> signature <String>|(file <FileName> [charset <Charset>]) (replace <Tag> <String>)*` gam <UserTypeEntity> signature <String>|(file <FileName> [charset <Charset>]) (replace <Tag> <String>)*
`gam <UserTypeEntity> vacation <TrueValues> subject <String> (message <String>)|(file <FileName> [charset <CharSet>]) (replace <Tag> <String>)* gam <UserTypeEntity> vacation <TrueValues> subject <String> (message <String>)|(file <FileName> [charset <CharSet>]) (replace <Tag> <String>)*
[contactsonly] [domainonly] [startdate <Date>] [enddate <Date>]` [contactsonly] [domainonly] [startdate <Date>] [enddate <Date>]
Every instance of `{<Tag>}` in the signature/message will be replaced by `<String>`. Instances of the form `{RT}...{Text}...{/RT}` will be eliminated Every instance of {<Tag>} in the signature/message will be replaced by <String>. Instances of the form {RT}...{Text}...{/RT} will be eliminated
if there was no `<Tag>` specified that matches `Text` or if a `<Tag>` matching `Text` was specified but the matching `<String>` is empty. if there was no <Tag> specified that matches Text or if a <Tag> matching Text was specified but the matching <String> is empty.
This is especially useful with CSV files. This is especially useful with CSV files.
`gam csv Users.csv gam user "~User" signature file SignatureTemplate.txt replace "#User#" "~User" replace "#Title#" "~Title"` gam csv Users.csv gam user "~User" signature file SignatureTemplate.txt replace "#User#" "~User" replace "#Title#" "~Title"
Added argument to `gam <UserTypeEntity> show signature` to format the signature. Added argument to gam <UserTypeEntity> show signature to format the signature.
`gam <UserTypeEntity> show signature [format]` gam <UserTypeEntity> show signature [format]
Added argument to gam add/update calendar to allow specification of event notifications Added argument to gam add/update calendar to allow specification of event notifications
`gam <UserTypeEntity> add/update calendar <Calendar> notification email|sms eventcreation|eventchange|eventcancellation|eventresponce|agenda` gam <UserTypeEntity> add/update calendar <Calendar> notification email|sms eventcreation|eventchange|eventcancellation|eventresponce|agenda
Added option to reminder and notification arguments of update calendar to allowing clearing of reminders/notifications. Added option to reminder and notification arguments of update calendar to allowing clearing of reminders/notifications.
`gam <UserTypeEntity> update calendar <Calendar> [reminder clear] [notification clear]` gam <UserTypeEntity> update calendar <Calendar> [reminder clear] [notification clear]
Added arguments to `gam print group-members` to allow selecting subsets of groups. Added arguments to gam print group-members to allow selecting subsets of groups.
Added argument to `gam print group-members` to add member full name to output, Added argument to gam print group-members to add member full name to output,
Added argument to `gam print group-members` to allow output field selection. Added argument to gam print group-members to allow output field selection.
`gam print group-members [todrive] ([domain <DomainName>] [member <UserItem>])|[group <GroupItem>] [membernames] [fields <MembersFieldNameList>]` gam print group-members [todrive] ([domain <DomainName>] [member <UserItem>])|[group <GroupItem>] [membernames] [fields <MembersFieldNameList>]
`MembersFieldNameList` is a comma separated list of field names: `email | group | id | name | role | type` MembersFieldNameList is a comma separated list of field names: email | group | id | name | role | type
Added argument to `gam info user` to specify SKUs for which license information is desired. Added argument to gam info user to specify SKUs for which license information is desired.
`gam info user [<UserItem>] ... [skus <SKUIDList>]` gam info user [<UserItem>] ... [skus <SKUIDList>]
Added argument to `gam print printjobs` and `gam printjob <PrinterID> fetch` to allow specifying the maximum number of print jobs to retrieve. Added argument to gam print printjobs and gam printjob <PrinterID> fetch to allow specifying the maximum number of print jobs to retrieve.
`gam printjob <PrinterID> fetch ... [limit <Number>]` gam printjob <PrinterID> fetch ... [limit <Number>]
`gam print printjobs ... [limit <Number>]` gam print printjobs ... [limit <Number>]
`limit <Number>` specifies the maximum number of print jobs to retrieve; defaults to 25, set limit to 0 to retrieve all print jobs. limit <Number> specifies the maximum number of print jobs to retrieve; defaults to 25, set limit to 0 to retrieve all print jobs.
Credit to Seth Stein for the following enhancements. Credit to Seth Stein for the following enhancements.
Added argument to `gam <UserTypeEntity> get drivefile` to allow downloading a specific revision of a drive file. Added argument to gam <UserTypeEntity> get drivefile to allow downloading a specific revision of a drive file.
`gam <UserTypeEntity> get drivefile (id <DriveFileID>)|(query <Query>) [format <FileFormatList>] [targetfolder <FilePath>] [revision <Number>]` gam <UserTypeEntity> get drivefile (id <DriveFileID>)|(query <Query>) [format <FileFormatList>] [targetfolder <FilePath>] [revision <Number>]
Added command to show drive file revisions. Added command to show drive file revisions.
`gam <UserTypeEntity> show filerevisions <DriveFileID>` gam <UserTypeEntity> show filerevisions <DriveFileID>
Added argument to `gam print adminroles` to allow uploading to Google Drive. Added argument to gam print adminroles to allow uploading to Google Drive.
`gam print adminroles [todrive]` gam print adminroles [todrive]
Added `group, groups, mobile` arguments to `gam report`. Added group, groups, mobile arguments to gam report.
`gam report admin|calendar|calendars|drive|docs|doc|groups|group|logins|login|mobile|tokens|token ...` gam report admin|calendar|calendars|drive|docs|doc|groups|group|logins|login|mobile|tokens|token ...
Added command to show user Google+ profile. Added command to show user Google+ profile.
`gam <UserTypeEntity> show gplusprofile [todrive]` gam <UserTypeEntity> show gplusprofile [todrive]
To enable this command, visit: https://github.com/jay0lee/GAM/wiki/CreatingClientSecretsFile To enable this command, visit: https://github.com/jay0lee/GAM/wiki/CreatingClientSecretsFile
In step 3.v, enable the Google+ API In step 3.v, enable the Google+ API
In step 6.iii.d, add `https://www.googleapis.com/auth/plus.me` to the API scopes - Service Account list, then remove and re-add the authorization. In step 6.iii.d, add https://www.googleapis.com/auth/plus.me to the API scopes - Service Account list, then remove and re-add the authorization.
Added argument to `gam <UserTypeEntity> show labels` to allow seeing message counts for each label. Added argument to gam <UserTypeEntity> show labels to allow seeing message counts for each label.
`gam <UserTypeEntity> show labels|label [onlyuser] [showcounts]` gam <UserTypeEntity> show labels|label [onlyuser] [showcounts]
Added argument to `gam <UserTypeEntity> show fileinfo` to allow field selection. Added argument to gam <UserTypeEntity> show fileinfo to allow field selection.
`gam <UserTypeEntity> show fileinfo <DriveFileID> [allfields|<DriveFieldName>*]` gam <UserTypeEntity> show fileinfo <DriveFileID> [allfields|<DriveFieldName>*]
Added argument to `gam update group` to allow removing members by role. Added argument to gam update group to allow removing members by role.
`gam update group <Group> clear [members] [managers] [owners]` gam update group <Group> clear [members] [managers] [owners]
If no option follows clear, all members will removed. If no option follows clear, all members will removed.
Changed `gam print admins` to include 'id:' in OrgUnitID column as with other `gam print` commands. Changed gam print admins to include 'id:' in OrgUnitID column as with other gam print commands.
Fixed GAM to handle both future date error messages in `gam report` Fixed GAM to handle both future date error messages in gam report
Fixed `gam <UserTypeEntity> show delegates` to handle Unicode characters in delagator name. Fixed gam <UserTypeEntity> show delegates to handle Unicode characters in delagator name.
Fixed `gam <UserTypeEntity> get drivefile` to properly handle file extension. Fixed gam <UserTypeEntity> get drivefile to properly handle file extension.
Fixed `gam create alias <Name> target <Group>`. Fixed gam create alias <Name> target <Group>.
2016/07/29 2016/07/29
Added command to empty drive drive trash. Added command to empty drive drive trash.
`gam <UserTypeEntity> empty drivetrash` gam <UserTypeEntity> empty drivetrash
Added alternative command to add delegates and command to print delegates. Added alternative command to add delegates and command to print delegates.
`gam <UserTypeEntity> add delegate|delegates <UserEntity>` gam <UserTypeEntity> add delegate|delegates <UserEntity>
`gam <UserTypeEntity> print delegates [todrive]` gam <UserTypeEntity> print delegates [todrive]
Improved Gmail filter processing. Improved Gmail filter processing.
`gam <UserTypeEntity> [add] filter [from <EmailAddress>] [to <EmailAddress>] [subject <String>] [haswords|query <List>] [nowords|negatedquery <List>] [musthaveattachment|hasattachment] [excludechats] [size larger|smaller <ByteCount>] gam <UserTypeEntity> [add] filter [from <EmailAddress>] [to <EmailAddress>] [subject <String>] [haswords|query <List>] [nowords|negatedquery <List>] [musthaveattachment|hasattachment] [excludechats] [size larger|smaller <ByteCount>]
[label <LabelID>] [important|notimportant] [star] [trash] [markread] [archive] [neverspam] [forward <EmailAddress>]` [label <LabelID>] [important|notimportant] [star] [trash] [markread] [archive] [neverspam] [forward <EmailAddress>]
`gam <UserTypeEntity> delete filters <FilterIDEntity>` gam <UserTypeEntity> delete filters <FilterIDEntity>
`gam <UserTypeEntity> show filters` gam <UserTypeEntity> show filters
`gam <UserTypeEntity> info filters <FilterIDEntity>` gam <UserTypeEntity> info filters <FilterIDEntity>
`gam <UserTypeEntity> print filters [todrive]` gam <UserTypeEntity> print filters [todrive]
Added commands to process Gmail forwarding addresses. Added commands to process Gmail forwarding addresses.
`gam <UserTypeEntity> add forwardingaddress|forwardingaddresses <EmailAddressEntity>` gam <UserTypeEntity> add forwardingaddress|forwardingaddresses <EmailAddressEntity>
`gam <UserTypeEntity> delete forwardingaddress|forwardingaddresses <EmailAddressEntity>` gam <UserTypeEntity> delete forwardingaddress|forwardingaddresses <EmailAddressEntity>
`gam <UserTypeEntity> show forwardingaddress|forwardingaddresses` gam <UserTypeEntity> show forwardingaddress|forwardingaddresses
`gam <UserTypeEntity> info forwardingaddress|forwardingaddresses <EmailAddressEntity>` gam <UserTypeEntity> info forwardingaddress|forwardingaddresses <EmailAddressEntity>
`gam <UserTypeEntity> print forwardingaddress|forwardingaddresses [todrive]` gam <UserTypeEntity> print forwardingaddress|forwardingaddresses [todrive]
Improved Gmail forward processing. Improved Gmail forward processing.
`gam <UserTypeEntity> forward <FalseValues>` gam <UserTypeEntity> forward <FalseValues>
`gam <UserTypeEntity> forward <TrueValues> keep|leaveininbox|archive|delete|trash|markread <EmailAddress>` gam <UserTypeEntity> forward <TrueValues> keep|leaveininbox|archive|delete|trash|markread <EmailAddress>
`gam <UserTypeEntity> show forward` gam <UserTypeEntity> show forward
`gam <UserTypeEntity> print forward [todrive]` gam <UserTypeEntity> print forward [todrive]
Improved Gmail sendas processing. Improved Gmail sendas processing.
`gam <UserTypeEntity> [add] sendas <EmailAddress> <Name> [replyto <EmailAddress>] [default] [treatasalias <Boolean>] [signature|sig <String>|(file <FileName> [charset <CharSet>]) (replace <REPattern> <String>)*]` gam <UserTypeEntity> [add] sendas <EmailAddress> <Name> [replyto <EmailAddress>] [default] [treatasalias <Boolean>] [signature|sig <String>|(file <FileName> [charset <CharSet>]) (replace <REPattern> <String>)*]
`gam <UserTypeEntity> update sendas <EmailAddress> [name <Name>] [replyto <EmailAddress>] [default] [treatasalias <Boolean>] [signature|sig <String>|(file <FileName> [charset <CharSet>]) (replace <REPattern> <String>)*]` gam <UserTypeEntity> update sendas <EmailAddress> [name <Name>] [replyto <EmailAddress>] [default] [treatasalias <Boolean>] [signature|sig <String>|(file <FileName> [charset <CharSet>]) (replace <REPattern> <String>)*]
`gam <UserTypeEntity> delete sendas <EmailAddressEntity>` gam <UserTypeEntity> delete sendas <EmailAddressEntity>
`gam <UserTypeEntity> show sendas [format]` gam <UserTypeEntity> show sendas [format]
`gam <UserTypeEntity> info sendas <EmailAddressEntity> [format]` gam <UserTypeEntity> info sendas <EmailAddressEntity> [format]
`gam <UserTypeEntity> print sendas [todrive]` gam <UserTypeEntity> print sendas [todrive]
Improved Gmail signature processing. Improved Gmail signature processing.
`gam <UserTypeEntity> signature|sig <String>|(file <FileName> [charset <Charset>]) (replace <Tag> <String>)* [name <String>] [replyto <EmailAddress>] ` gam <UserTypeEntity> signature|sig <String>|(file <FileName> [charset <Charset>]) (replace <Tag> <String>)* [name <String>] [replyto <EmailAddress>]
`gam <UserTypeEntity> show signature|sig [format]` gam <UserTypeEntity> show signature|sig [format]
Use Gmail API for POP/IMAP/Vacation processing. Use Gmail API for POP/IMAP/Vacation processing.
`gam <UserTypeEntity> imap|imap4 <Boolean> [noautoexpunge] [expungebehavior archive|deleteforever|trash] [maxfoldersize 0|1000|2000|5000|10000]` gam <UserTypeEntity> imap|imap4 <Boolean> [noautoexpunge] [expungebehavior archive|deleteforever|trash] [maxfoldersize 0|1000|2000|5000|10000]
`gam <UserTypeEntity> pop|pop3 <Boolean> [for allmail|newmail|mailfromnowon|fromnowown] [action keep|leaveininbox|archive|delete|trash|markread]` gam <UserTypeEntity> pop|pop3 <Boolean> [for allmail|newmail|mailfromnowon|fromnowown] [action keep|leaveininbox|archive|delete|trash|markread]
`gam <UserTypeEntity> vacation <FalseValues>` gam <UserTypeEntity> vacation <FalseValues>
`gam <UserTypeEntity> vacation <TrueValues> subject <String> (message <String>)|(file <FileName> [charset <CharSet>]) (replace <Tag> <String>)* [html] gam <UserTypeEntity> vacation <TrueValues> subject <String> (message <String>)|(file <FileName> [charset <CharSet>]) (replace <Tag> <String>)* [html]
[contactsonly] [domainonly] [startdate <Date>] [enddate <Date>]` [contactsonly] [domainonly] [startdate <Date>] [enddate <Date>]
`gam <UserTypeEntity> show vacation [format]` gam <UserTypeEntity> show vacation [format]
Added command toGet information about a specific calendar. Added command toGet information about a specific calendar.
`gam <UserTypeEntity> info calendar <EmailAddress>` gam <UserTypeEntity> info calendar <EmailAddress>
Added command to print calendars to CSV file, dropped all arguments from gam show calendars. Added command to print calendars to CSV file, dropped all arguments from gam show calendars.
`gam <UserTypeEntity> print calendars [todrive]` gam <UserTypeEntity> print calendars [todrive]
`gam <UserTypeEntity> show calendars` gam <UserTypeEntity> show calendars
Added command to print Gmail Profiles to CSV file, dropped all arguments from gam show gmailprofile. Added command to print Gmail Profiles to CSV file, dropped all arguments from gam show gmailprofile.
`gam <UserTypeEntity> print gmailprofile [todrive]` gam <UserTypeEntity> print gmailprofile [todrive]
`gam <UserTypeEntity> show gmailprofile` gam <UserTypeEntity> show gmailprofile
Added command to print Gplus Profiles to CSV file, dropped all arguments from gam show gplusprofile. Added command to print Gplus Profiles to CSV file, dropped all arguments from gam show gplusprofile.
`gam <UserTypeEntity> print gplusprofile [todrive]` gam <UserTypeEntity> print gplusprofile [todrive]
`gam <UserTypeEntity> show gplusprofile` gam <UserTypeEntity> show gplusprofile
Added command to print user schemas to CSV file, renamed command to display formatted user schemas to gam show schemas. Added command to print user schemas to CSV file, renamed command to display formatted user schemas to gam show schemas.
`gam print schemas [todrive]` gam print schemas [todrive]
`gam show schemas` gam show schemas
Added command to print user access tokens to CSV file. Added command to print user access tokens to CSV file.
`gam <UserTypeEntity> print tokens|token|3lo|oauth [todrive]` gam <UserTypeEntity> print tokens|token|3lo|oauth [todrive]
Added arguments to gam info cros to allow specification of desired output fields. Added arguments to gam info cros to allow specification of desired output fields.
`gam info cros <CrosDeviceEntity> [nolists] [listlimit <Number>] gam info cros <CrosDeviceEntity> [nolists] [listlimit <Number>]
[basic|full|allfields] <CrOSFieldName>* [fields <CrOSFieldNameList>]` [basic|full|allfields] <CrOSFieldName>* [fields <CrOSFieldNameList>]
Added drivedir and targetfolder <FilePath> arguments to gam printjob fetch and gam get photo to Added drivedir and targetfolder <FilePath> arguments to gam printjob fetch and gam get photo to
allow specification of the destination folder for the file retrieved from Google. The default allow specification of the destination folder for the file retrieved from Google. The default
location for these commands is the current working directory, drivedir specifies the value of the environment variable GAMDRIVEDIR and location for these commands is the current working directory, drivedir specifies the value of the environment variable GAMDRIVEDIR and
targetfolder <FilePath> specifies a user-choosen path. targetfolder <FilePath> specifies a user-choosen path.
`gam printjob <PrinterID>|any fetch gam printjob <PrinterID>|any fetch
[olderthan|newerthan <PrintJobAge>] [query <QueryPrintJob>] [olderthan|newerthan <PrintJobAge>] [query <QueryPrintJob>]
[status <PrintJobStatus>] [status <PrintJobStatus>]
[orderby <PrintJobOrderByFieldName> [ascending|descending]] [orderby <PrintJobOrderByFieldName> [ascending|descending]]
[owner|user <EmailAddress>] [owner|user <EmailAddress>]
[limit <Number>] [drivedir|(targetfolder <FilePath>)]` [limit <Number>] [drivedir|(targetfolder <FilePath>)]
`gam <UserTypeEntity> get photo [drivedir|(targetfolder <FilePath>)]` gam <UserTypeEntity> get photo [drivedir|(targetfolder <FilePath>)]
Added noshow argument to gam get photo to suppress displaying of photo data
gam <UserTypeEntity> get photo [drivedir|(targetfolder <FilePath>)] [noshow]
Commands that produce CSV file output have been changed to make the leftmost column(s) be the key fields. Commands that produce CSV file output have been changed to make the leftmost column(s) be the key fields.
If you have scripts that process the CSV files as flat files, expecting the columns to be in a particular If you have scripts that process the CSV files as flat files, expecting the columns to be in a particular