diff --git a/.travis.yml b/.travis.yml index 0257d015..889c2a9a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,65 +16,65 @@ cache: jobs: fast_finish: true include: -# - os: linux -# name: "Linux 64-bit Focal" -# dist: focal -# language: shell -# env: -# - DIST_UPGRADE=true -# - os: linux -# name: "Linux 64-bit Bionic" -# dist: bionic -# language: shell -# env: -# - DIST_UPGRADE=true -# - os: linux -# name: "Linux 64-bit Xenial" -# dist: xenial -# language: shell -# env: -# - DIST_UPGRADE=false -# - os: linux -# name: "Linux 64-bit Trusty" -# dist: trusty -# language: shell -# env: -# - DIST_UPGRADE=true -# - os: linux -# name: "Linux 64-bit Precise" -# dist: precise -# language: shell -# env: -# - DIST_UPGRADE=false -# - PATCHELF_VERSION=0.9 -# - os: linux -# name: "Linux ARM64 Focal" -# dist: focal -# arch: arm64 -# language: shell -# env: -# - DIST_UPGRADE=false -# filter_secrets: false -# - os: linux -# name: "Linux ARM64 Bionic" -# dist: bionic -# arch: arm64 -# language: shell -# env: -# - DIST_UPGRADE=false -# filter_secrets: false -# - os: linux -# name: "Linux ARM64 Xenial" -# dist: xenial -# arch: arm64 -# language: shell -# env: -# - DIST_UPGRADE=true -# filter_secrets: false -# - os: osx -# name: "MacOS" -# language: generic -# osx_image: xcode12.4 + - os: linux + name: "Linux 64-bit Focal" + dist: focal + language: shell + env: + - DIST_UPGRADE=true + - os: linux + name: "Linux 64-bit Bionic" + dist: bionic + language: shell + env: + - DIST_UPGRADE=true + - os: linux + name: "Linux 64-bit Xenial" + dist: xenial + language: shell + env: + - DIST_UPGRADE=false + - os: linux + name: "Linux 64-bit Trusty" + dist: trusty + language: shell + env: + - DIST_UPGRADE=true + - os: linux + name: "Linux 64-bit Precise" + dist: precise + language: shell + env: + - DIST_UPGRADE=false + - PATCHELF_VERSION=0.9 + - os: linux + name: "Linux ARM64 Focal" + dist: focal + arch: arm64 + language: shell + env: + - DIST_UPGRADE=false + filter_secrets: false + - os: linux + name: "Linux ARM64 Bionic" + dist: bionic + arch: arm64 + language: shell + env: + - DIST_UPGRADE=false + filter_secrets: false + - os: linux + name: "Linux ARM64 Xenial" + dist: xenial + arch: arm64 + language: shell + env: + - DIST_UPGRADE=true + filter_secrets: false + - os: osx + name: "MacOS" + language: generic + osx_image: xcode12.4 - os: windows name: "Windows 64-bit" language: shell diff --git a/src/GamCommands.txt b/src/GamCommands.txt index 6ed926de..1bab47fa 100644 --- a/src/GamCommands.txt +++ b/src/GamCommands.txt @@ -5354,6 +5354,7 @@ gam print messages|threads [todrive *] [countsonly|positivecountsonly] [useronly] [headers all|] [showlabels] [showbody] [showsize] [showsnippet] + [showattachments [attachmentnamepattern ]] [convertcrnl] [delimiter ] # Users - Gmail - Profile diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index 7356c01a..0f66aa9b 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -1,6 +1,9 @@ 6.03.19 -Rebuild pyinstaller bootloader on Windows to avoid false positive virus detection. +Added option `showattachments [attachmentnamepattern ]` to +`gam print messages|threads`. This adds the column `Attachments` +that shows the number of attachments and columns `Attachments.n` that show the +attachment names. 6.03.18 diff --git a/src/gam/__init__.py b/src/gam/__init__.py index c5d772ce..c8a84aea 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -51096,6 +51096,21 @@ def _showMessage(result, j, jcount): Ind.Decrement() parameters['messagesProcessed'] += 1 + def _getAttachmentNames(messageId, payload, attachmentNamePattern, attachmentNames): + for part in payload.get('parts', []): + if 'attachmentId' in part['body']: + for header in part['headers']: + if header['name'] in {'Content-Type', 'Content-Disposition'}: + mg = ATTACHMENT_NAME_PATTERN.match(header['value']) + if not mg: + continue + attachmentName = mg.group(1) + if (not attachmentNamePattern) or attachmentNamePattern.match(attachmentName): + attachmentNames.append(attachmentName) + break + else: + _getAttachmentNames(messageId, part, attachmentNamePattern, attachmentNames) + def _printMessage(user, result): if parameters['maxToProcess'] and parameters['messagesProcessed'] == parameters['maxToProcess']: return @@ -51134,6 +51149,12 @@ def _printMessage(user, result): row['Body'] = _getMessageBody(result['payload']) else: row['Body'] = escapeCRsNLs(_getMessageBody(result['payload'])) + if show_attachments: + attachmentNames = [] + _getAttachmentNames(result['id'], result['payload'], attachmentNamePattern, attachmentNames) + row['Attachments'] = len(attachmentNames) + for i, attachmentName in enumerate(attachmentNames): + row[f'Attachments.{i}'] = attachmentName csvPF.WriteRowTitles(row) parameters['messagesProcessed'] += 1 @@ -51277,9 +51298,9 @@ def _batchPrintShowMessagesThreads(service, user, jcount, messageIds): show_size = True elif myarg == 'showsnippet': show_snippet = True - elif showMode and myarg == 'showattachments': + elif myarg == 'showattachments': show_attachments = True - elif showMode and myarg == 'attachmentnamepattern': + elif myarg == 'attachmentnamepattern': attachmentNamePattern = getREPattern(re.IGNORECASE) elif showMode and myarg == 'saveattachments': save_attachments = True @@ -51426,12 +51447,15 @@ def _batchPrintShowMessagesThreads(service, user, jcount, messageIds): # gam print message|messages # (((query ) (matchlabel ) [or|and])* [quick|notquick] [max_to_print ] [includespamtrash])|(ids ) # [labelmatchpattern ] -# [headers all|] [showlabels] [showbody] [showsize] [showsnippet] [convertcrnl] [delimiter ] [todrive *] +# [headers all|] [showlabels] [showbody] [showsize] [showsnippet] +# [showattachments [attachmentnamepattern ]] +# [convertcrnl] [delimiter ] [todrive *] # [countsonly|positivecountsonly] [useronly] # gam show message|messages # (((query ) (matchlabel ) [or|and])* [quick|notquick] [max_to_show ] [includespamtrash])|(ids ) # [labelmatchpattern ] -# [headers all|] [showlabels] [showbody] [showsize] [showsnippet] [showattachments [attachmentnamepattern ]] +# [headers all|] [showlabels] [showbody] [showsize] [showsnippet] +# [showattachments [attachmentnamepattern ]] # [countsonly|positivecountsonly] [useronly] # [saveattachments [attachmentnamepattern ]] [targetfolder ] [overwrite []] def printShowMessages(users): @@ -51440,12 +51464,15 @@ def printShowMessages(users): # gam print thread|threads # (((query ) (matchlabel ) [or|and])* [quick|notquick] [max_to_print ] [includespamtrash])|(ids ) # [labelmatchpattern ] -# [headers all|] [showlabels] [showbody] [showsize] [showsnippet] [convertcrnl] [delimiter ] [todrive *] +# [headers all|] [showlabels] [showbody] [showsize] [showsnippet] +# [showattachments [attachmentnamepattern ]] +# [convertcrnl] [delimiter ] [todrive *] # [countsonly|positivecountsonly] [useronly] # gam show thread|threads # (((query ) (matchlabel ) [or|and])* [quick|notquick] [max_to_show ] [includespamtrash])|(ids ) # [labelmatchpattern ] -# [headers all|] [showlabels] [showbody] [showsize] [showsnippet] [showattachments [attachmentnamepattern ]] +# [headers all|] [showlabels] [showbody] [showsize] [showsnippet] +# [showattachments [attachmentnamepattern ]] # [countsonly|positivecountsonly] [useronly] # [saveattachments [attachmentnamepattern ]] [targetfolder ] [overwrite []] def printShowThreads(users): diff --git a/src/travis/windows-before-install.sh b/src/travis/windows-before-install.sh index f3ff8090..dc529b69 100755 --- a/src/travis/windows-before-install.sh +++ b/src/travis/windows-before-install.sh @@ -63,26 +63,25 @@ cd $mypath $pip install --upgrade pip $pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 $pip install -U $pip install --upgrade -r src/requirements.txt -#$pip install --upgrade pyinstaller +$pip install --upgrade pyinstaller # Install PyInstaller from source and build bootloader # to try and avoid getting flagged as malware since # lots of malware uses PyInstaller default bootloader # https://stackoverflow.com/questions/53584395/how-to-recompile-the-bootloader-of-pyinstaller -echo "Downloading PyInstaller..." -wget --quiet https://github.com/pyinstaller/pyinstaller/archive/$PYINSTALLER_COMMIT.tar.gz -tar xf $PYINSTALLER_COMMIT.tar.gz -mv pyinstaller-$PYINSTALLER_COMMIT pyinstaller -cd pyinstaller/bootloader -echo "bootloader before:" -md5sum ../PyInstaller/bootloader/Windows-${BITS}bit/* - -$python ./waf all --target-arch=${BITS}bit --msvc_version "msvc 14.0" - -echo "bootloader after:" -md5sum ../PyInstaller/bootloader/Windows-${BITS}bit/* -echo "PATH: $PATH" -cd .. -$python setup.py install +#echo "Downloading PyInstaller..." +#wget --quiet https://github.com/pyinstaller/pyinstaller/archive/$PYINSTALLER_COMMIT.tar.gz +#tar xf $PYINSTALLER_COMMIT.tar.gz +#mv pyinstaller-$PYINSTALLER_COMMIT pyinstaller +#cd pyinstaller/bootloader +#echo "bootloader before:" +#md5sum ../PyInstaller/bootloader/Windows-${BITS}bit/* +# +#$python ./waf all --target-arch=${BITS}bit --msvc_version "msvc 14.0" +# +#echo "bootloader after:" +#md5sum ../PyInstaller/bootloader/Windows-${BITS}bit/* +#echo "PATH: $PATH" +#cd .. +#$python setup.py install echo "cd to $mypath" cd $mypath -ls -l pyinstaller diff --git a/src/travis/windows-install.sh b/src/travis/windows-install.sh index 2dc2ca4d..2e2983b4 100755 --- a/src/travis/windows-install.sh +++ b/src/travis/windows-install.sh @@ -4,11 +4,7 @@ export gampath="dist/gamadv-xtd3" rm -rf $gampath mkdir -p $gampath export gampath=$(readlink -e $gampath) -export python=/c/python/python.exe -echo "Python Version" -$python -V -echo "Compile: $python -OO -v -c pyinstaller/pyinstaller.py --clean --noupx -F --distpath $gampath gam.spec" -$python -OO -v -c pyinstaller/pyinstaller.py --clean --noupx -F --distpath $gampath gam.spec +pyinstaller --clean --noupx -F --distpath $gampath gam.spec export gam="${gampath}/gam" echo "running compiled GAM..." $gam version