mirror of
https://github.com/GAM-team/GAM.git
synced 2025-07-09 22:23:35 +00:00
Add untrash argument to gam delete drivefile
This commit is contained in:
15
src/gam.py
15
src/gam.py
@ -25,7 +25,7 @@ For more information, see http://git.io/gam
|
||||
"""
|
||||
|
||||
__author__ = u'Jay Lee <jay0lee@gmail.com>'
|
||||
__version__ = u'3.63'
|
||||
__version__ = u'3.64'
|
||||
__license__ = u'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
|
||||
|
||||
import sys, os, time, datetime, random, socket, csv, platform, re, calendar, base64, string, StringIO, subprocess
|
||||
@ -3478,6 +3478,8 @@ def doDriveSearch(drive, query=None):
|
||||
ids.append(f_file[u'id'])
|
||||
return ids
|
||||
|
||||
DELETE_DRIVEFILE_FUNCTION_TO_ACTION_MAP = {u'delete': u'purging', u'trash': u'trashing', u'untrash': u'untrashing',}
|
||||
|
||||
def deleteDriveFile(users):
|
||||
fileIds = sys.argv[5]
|
||||
function = u'trash'
|
||||
@ -3486,9 +3488,13 @@ def deleteDriveFile(users):
|
||||
if sys.argv[i].lower() == u'purge':
|
||||
function = u'delete'
|
||||
i += 1
|
||||
elif sys.argv[i].lower() == u'untrash':
|
||||
function = u'untrash'
|
||||
i += 1
|
||||
else:
|
||||
print u'ERROR: %s is not a valid argument for "gam <users> delete drivefile"' % sys.argv[i]
|
||||
sys.exit(2)
|
||||
action = DELETE_DRIVEFILE_FUNCTION_TO_ACTION_MAP[function]
|
||||
for user in users:
|
||||
drive = buildGAPIServiceObject(u'drive', user)
|
||||
if fileIds[:6].lower() == u'query:':
|
||||
@ -3500,14 +3506,11 @@ def deleteDriveFile(users):
|
||||
fileIds = fileIds[:fileIds.find(u'/')]
|
||||
file_ids = [fileIds,]
|
||||
if not file_ids:
|
||||
print u'No files to delete for %s' % user
|
||||
print u'No files to %s for %s' % (function, user)
|
||||
i = 0
|
||||
for fileId in file_ids:
|
||||
i += 1
|
||||
if function == u'trash':
|
||||
print u'trashing %s for %s (%s of %s)' % (fileId, user, i, len(file_ids))
|
||||
else:
|
||||
print u'purging %s for %s (%s of %s)' % (fileId, user, i, len(file_ids))
|
||||
print u'%s %s for %s (%s of %s)' % (action, fileId, user, i, len(file_ids))
|
||||
callGAPI(service=drive.files(), function=function, fileId=fileId)
|
||||
|
||||
def printDriveFolderContents(feed, folderId, indent):
|
||||
|
Reference in New Issue
Block a user