Compare commits

...

2 Commits

Author SHA1 Message Date
Ross Scroggs
f29c697455 Updated code that uses the Domain Shared Contacts API with an HTTPS proxy to avoid a trap:
Some checks are pending
Build and test GAM / build (Win64, build, 9, VC-WIN64A, windows-2022) (push) Waiting to run
Build and test GAM / build (aarch64, build, 3, linux-aarch64, [self-hosted linux arm64]) (push) Waiting to run
Build and test GAM / build (aarch64, build, 5, linux-aarch64, [self-hosted linux arm64], yes) (push) Waiting to run
Build and test GAM / build (aarch64, build, 7, darwin64-arm64, macos-14) (push) Waiting to run
Build and test GAM / build (aarch64, build, 8, darwin64-arm64, macos-15) (push) Waiting to run
Build and test GAM / build (x86_64, build, 1, linux-x86_64, ubuntu-22.04) (push) Waiting to run
Build and test GAM / build (x86_64, build, 2, linux-x86_64, ubuntu-24.04) (push) Waiting to run
Build and test GAM / build (x86_64, build, 4, linux-x86_64, ubuntu-22.04, yes) (push) Waiting to run
Build and test GAM / build (x86_64, build, 6, darwin64-x86_64, macos-13) (push) Waiting to run
Build and test GAM / build (x86_64, test, 10, ubuntu-24.04, 3.9) (push) Waiting to run
Build and test GAM / build (x86_64, test, 11, ubuntu-24.04, 3.10) (push) Waiting to run
Build and test GAM / build (x86_64, test, 12, ubuntu-24.04, 3.11) (push) Waiting to run
Build and test GAM / build (x86_64, test, 13, ubuntu-24.04, 3.12) (push) Waiting to run
Build and test GAM / merge (push) Blocked by required conditions
Build and test GAM / publish (push) Blocked by required conditions
CodeQL / Analyze (python) (push) Waiting to run
Check for Google Root CA Updates / check-apis (push) Waiting to run
2024-11-26 13:43:55 -08:00
Ross Scroggs
a1238c6397 Added option positivecountsonly to gam <UserTypeEntity> print|show filecomments 2024-11-26 13:09:44 -08:00
5 changed files with 39 additions and 15 deletions

View File

@@ -1059,6 +1059,7 @@ Specify a collection of items by directly specifying them; the item type is dete
all_shortcuts |
all_3p_shortcuts |
all_items |
my_commentable_items |
my_docs |
my_files |
my_folders |
@@ -6779,12 +6780,12 @@ gam print ownership <DriveFileID>|(drivefilename <DriveFileName>) [todrive <ToDr
gam <UserTypeEntity> show filecomments <DriveFileEntity>
[showdeleted] [start <Date>|<Time>]
[fields <CommentsFieldNameList>] [showphotolinks]
[countsonly]
[countsonly|positivecountsonly]
[formatjson]
gam <UserTypeEntity> print filecomments <DriveFileEntity> [todrive <ToDriveAttribute>*]
[showdeleted] [start <Date>|<Time>]
[fields <CommentsFieldNameList>] [showphotolinks]
[countsonly]
[countsonly|positivecountsonly]
(addcsvdata <FieldName> <String>)*
[formatjson [quotechar <Character>]]

View File

@@ -1,3 +1,19 @@
7.01.02
Added option `positivecountsonly` to `gam <UserTypeEntity> print|show filecomments` that causes
GAM to display the number of comments and replies only for files that have comments.
Added `my_commentable_items` to `<DriveFileQueryShortcut>` that can be used with
`gam <UserTypeEntity> print|show filecomments my_commentable_items` to speed up processing.
Updated code that uses the Domain Shared Contacts API with an HTTPS proxy to avoid a trap:
```
Traceback (most recent call last):
...
File "atom/http.py", line 250, in _prepare_connection
AttributeError: module 'ssl' has no attribute 'wrap_socket'
```
7.01.01
Fixed bug in `gam <UserTypeEntity> print|show filetree` where no error message was generated

View File

@@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki
"""
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
__version__ = '7.01.01'
__version__ = '7.01.02'
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
#pylint: disable=wrong-import-position
@@ -51946,6 +51946,7 @@ QUERY_SHORTCUTS_MAP = {
'allshortcuts': f"mimeType = '{MIMETYPE_GA_SHORTCUT}'",
'all3pshortcuts': f"mimeType = '{MIMETYPE_GA_3P_SHORTCUT}'",
'allitems': 'allitems',
'mycommentableitems': ME_IN_OWNERS_AND+f"(mimeType = '{MIMETYPE_GA_DOCUMENT}' or mimeType = '{MIMETYPE_GA_SPREADSHEET}' or mimeType = '{MIMETYPE_GA_PRESENTATION}')",
'mydocs': ME_IN_OWNERS_AND+f"mimeType = '{MIMETYPE_GA_DOCUMENT}'",
'myfiles': ME_IN_OWNERS_AND+f"mimeType != '{MIMETYPE_GA_FOLDER}'",
'myfolders': ME_IN_OWNERS_AND+f"mimeType = '{MIMETYPE_GA_FOLDER}'",
@@ -56233,14 +56234,14 @@ def _showComment(comment, stripPhotoLinks, timeObjects, i=0, count=0, FJQC=None)
Ind.Decrement()
# gam <UserTypeEntity> show filecomments <DriveFileEntity>
# [showdeleted] [start <Date>|<Time>] [countsonly]
# [showdeleted] [start <Date>|<Time>] [countsonly|positivecountsonly]
# [fields <CommentsFieldNameList>] [showphotolinks]
# [countsonly]
# [formatjson]
# gam <UserTypeEntity> print filecomments <DriveFileEntity> [todrive <ToDriveAttribute>*]
# [showdeleted] [start <Date>|<Time>]
# [fields <CommentsFieldNameList>] [showphotolinks]
# [countsonly]
# [countsonly|positivecountsonly]
# (addcsvdata <FieldName> <String>)*
# [formatjson [quotechar <Character>]]
def printShowFileComments(users):
@@ -56265,7 +56266,7 @@ def printShowFileComments(users):
FJQC = FormatJSONQuoteChar(csvPF)
fieldsList = []
fileIdEntity = getDriveFileEntity()
countsOnly = False
countsOnly = positiveCountsOnly = False
stripPhotoLinks = True
kwargs = {}
addCSVData = {}
@@ -56286,6 +56287,8 @@ def printShowFileComments(users):
addCSVData[k] = getString(Cmd.OB_STRING, minLen=0)
elif myarg == 'countsonly':
countsOnly = True
elif myarg == 'positivecountsonly':
countsOnly = positiveCountsOnly = True
else:
FJQC.GetFormatJSONQuoteChar(myarg)
if csvPF:
@@ -56339,7 +56342,8 @@ def printShowFileComments(users):
numReplies += len(comment['replies'])
if not csvPF:
if countsOnly:
printKeyValueList([Ent.Singular(Ent.DRIVE_FILE_ID), fileId, 'comments', kcount, 'replies', numReplies])
if not positiveCountsOnly or kcount > 0:
printKeyValueList([Ent.Singular(Ent.DRIVE_FILE_ID), fileId, 'comments', kcount, 'replies', numReplies])
else:
if not FJQC.formatJSON:
entityPerformActionNumItems([Ent.DRIVE_FILE_ID, fileId], kcount, Ent.DRIVE_FILE_COMMENT, j, jcount)
@@ -56351,12 +56355,13 @@ def printShowFileComments(users):
_showComment(comment, stripPhotoLinks, timeObjects, k, kcount, FJQC)
Ind.Decrement()
elif countsOnly:
row = {'User': user, 'fileId': fileId}
if addCSVData:
row.update(addCSVData)
row['comments'] = kcount
row['replies'] = numReplies
csvPF.WriteRowTitles(row)
if not positiveCountsOnly or kcount > 0:
row = {'User': user, 'fileId': fileId}
if addCSVData:
row.update(addCSVData)
row['comments'] = kcount
row['replies'] = numReplies
csvPF.WriteRowTitles(row)
elif comments:
baserow = {'User': user, 'fileId': fileId}
if addCSVData:

View File

@@ -247,7 +247,9 @@ class ProxiedHttpClient(HttpClient):
# Trivial setup for ssl socket.
sslobj = None
if ssl_imported:
sslobj = ssl.wrap_socket(p_sock, None, None)
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
context.minimum_version = ssl.TLSVersion.TLSv1_2
sslobj = context.wrap_socket(p_sock, server_hostname=url.host)
else:
sock_ssl = socket.ssl(p_sock, None, None)
sslobj = http.client.FakeSocket(p_sock, sock_ssl)

View File

@@ -568,7 +568,7 @@ class ProxiedHttpClient(HttpClient):
context.minimum_version = ssl.TLSVersion.TLSv1_2
sslobj = context.wrap_socket(p_sock, server_hostname=uri.host)
else:
sock_ssl = socket.ssl(p_sock, None, Nonesock_)
sock_ssl = socket.ssl(p_sock, None, None)
sslobj = http.client.FakeSocket(p_sock, sock_ssl)
# Initalize httplib and replace with the proxy socket.
connection = http.client.HTTPConnection(proxy_uri.host)