Skip to content

Commit 9898f7b

Browse files
authored
Merge pull request #66 from gisce/copilot/fix-177beaab-36d0-4722-93b6-e4068b93ef41
Adapt CI to use Docker container for Python 2.7 testing, add Python 3.11 support, and fix MIME type detection
2 parents 8127e67 + d031e6a commit 9898f7b

File tree

3 files changed

+33
-22
lines changed

3 files changed

+33
-22
lines changed

.github/workflows/python-app.yml

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,33 @@ on:
1010
branches: [ "master" ]
1111

1212
jobs:
13-
run-tests:
14-
runs-on: ubuntu-22.04
15-
strategy:
16-
fail-fast: false
17-
matrix:
18-
python-version: [ "2.7", "3.11" ]
19-
13+
test-python3:
14+
runs-on: ubuntu-latest
2015
steps:
2116
- uses: actions/checkout@v3
22-
- name: Set up Python 3
23-
if: matrix.python-version == '3.11'
17+
- name: Set up Python 3.11
2418
uses: actions/setup-python@v4
2519
with:
26-
python-version: ${{ matrix.python-version }}
27-
28-
- name: Install Python 2
29-
if: matrix.python-version == '2.7'
20+
python-version: "3.11"
21+
- name: Install dependencies
3022
run: |
31-
sudo apt update
32-
sudo apt install python2 python-pip
33-
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1
34-
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2
35-
printf '1\n' | sudo update-alternatives --config python
36-
cd /usr/bin
37-
sudo ln -s /usr/bin/pip2 ./pip
23+
python -m pip install --upgrade pip
24+
pip install -r requirements-dev.txt
25+
pip install -e .
26+
- name: Tests
27+
run: |
28+
mamba
3829
30+
test-python2:
31+
runs-on: ubuntu-latest
32+
container: python:2.7-slim
33+
steps:
34+
- uses: actions/checkout@v3
3935
- name: Install dependencies
4036
run: |
4137
python -m pip install --upgrade pip
4238
pip install -r requirements-dev.txt
4339
pip install -e .
44-
4540
- name: Tests
4641
run: |
47-
mamba
42+
mamba

qreu/email.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,21 @@ def add_attachment(self, input_buff, attname=False):
388388

389389
# Guess MIME type
390390
filetype = mimetypes.guess_type(filename)[0]
391+
392+
# Ensure common Microsoft Office MIME types are available (especially for Python 2.7)
393+
if not filetype:
394+
office_extensions = {
395+
'.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
396+
'.xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
397+
'.pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
398+
'.doc': 'application/msword',
399+
'.xls': 'application/vnd.ms-excel',
400+
'.ppt': 'application/vnd.ms-powerpoint'
401+
}
402+
file_ext = filename.lower().split('.')[-1] if '.' in filename else ''
403+
if '.' + file_ext in office_extensions:
404+
filetype = office_extensions['.' + file_ext]
405+
391406
maintype, subtype = 'application', 'octet-stream'
392407
if filetype:
393408
maintype, subtype = filetype.split('/')

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
classifiers=[
2020
'Programming Language :: Python :: 2.7',
2121
'Programming Language :: Python :: 3.5',
22+
'Programming Language :: Python :: 3.11',
2223
'Topic :: Software Development :: Libraries',
2324
'Topic :: Communications :: Email'
2425
]

0 commit comments

Comments
 (0)