Skip to content

Commit 5b56894

Browse files
authored
Merge pull request #94 from mathoudebine/feature/workflow-save-screenshot
Save screenshot from Github actions, improve simulated mode with temporary file
2 parents c61f58c + ae06111 commit 5b56894

File tree

9 files changed

+95
-19
lines changed

9 files changed

+95
-19
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ assignees: ''
77

88
---
99

10+
<!---
11+
⚠️ Do not open bug reports for UsbMonitor.exe or ExtendScreen.exe here!
12+
Please read the disclaimer on the front page.
13+
-->
14+
1015
**Describe the bug**
1116
A clear and concise description of what the bug is.
1217

@@ -25,9 +30,9 @@ Add screenshots or photos of the rendering on the Turing screen to help explain
2530
You can drag and drop photos here to add them to the description.
2631

2732
**Environment:**
28-
- Release or branch of this project [e.g. 1.1.1, 2.0.0-alpha4, `feature/system-monitor` branch]
33+
- Revision of this project [e.g. 1.1.1, `main` branch, specific commit]
2934
- OS with version [e.g. Windows 11, Ubuntu 22.04]
30-
- Python version [e.g. Python 3.8, to get it run `python3 --version`]
35+
- Python version [e.g. Python 3.8]
3136
- Hardware [e.g. Intel CPU, Nvidia GPU, Raspberry Pi 3 B+ ...]
3237

3338
**Additional context**

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ assignees: ''
77

88
---
99

10+
<!---
11+
⚠️ Do not open feature requests for UsbMonitor.exe or ExtendScreen.exe here!
12+
Please read the disclaimer on the front page.
13+
-->
14+
1015
**Is your feature request related to a problem? If so, please describe the problem.**
1116
A description of what the problem is. E.g. I cannot display this data the way I want [...]
1217

@@ -21,9 +26,9 @@ Add screenshots or photos/mockups of the rendering on the Turing screen to help
2126
You can drag and drop photos here to add them to the description.
2227

2328
**Environment:**
24-
- Release or branch of this project [e.g. 1.1.1, 2.0.0-alpha4, `feature/system-monitor` branch]
29+
- Revision of this project [e.g. 1.1.1, `main` branch, specific commit]
2530
- OS with version [e.g. Windows 11, Ubuntu 22.04]
26-
- Python version [e.g. Python 3.8, to get it run `python3 --version`]
31+
- Python version [e.g. Python 3.8]
2732
- Hardware [e.g. Intel CPU, Nvidia GPU, Raspberry Pi 3 B+ ...]
2833

2934
**Additional context**

.github/workflows/simple-program-linux.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v3
1717
- name: Set up Python ${{ matrix.python-version }}
18-
uses: actions/setup-python@v3
18+
uses: actions/setup-python@v4
1919
with:
2020
python-version: ${{ matrix.python-version }}
2121

@@ -47,4 +47,14 @@ jobs:
4747
elif grep -qi "exception" output.log; then
4848
echo "Program failed to run, see output above"
4949
false
50-
fi
50+
fi
51+
52+
- name: Prepare screenshot for archiving
53+
run: |
54+
cp screencap.png screenshot-py${{ matrix.python-version }}.png
55+
56+
- name: Archive a screenshot
57+
uses: actions/upload-artifact@v3
58+
with:
59+
name: screenshot-py${{ matrix.python-version }}
60+
path: screenshot-*.png

.github/workflows/simple-program-macos.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v3
1717
- name: Set up Python ${{ matrix.python-version }}
18-
uses: actions/setup-python@v3
18+
uses: actions/setup-python@v4
1919
with:
2020
python-version: ${{ matrix.python-version }}
2121

@@ -47,4 +47,14 @@ jobs:
4747
elif grep -qi "exception" output.log; then
4848
echo "Program failed to run, see output above"
4949
false
50-
fi
50+
fi
51+
52+
- name: Prepare screenshot for archiving
53+
run: |
54+
cp screencap.png screenshot-py${{ matrix.python-version }}.png
55+
56+
- name: Archive a screenshot
57+
uses: actions/upload-artifact@v3
58+
with:
59+
name: screenshot-py${{ matrix.python-version }}
60+
path: screenshot-*.png

.github/workflows/simple-program-windows.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v3
1717
- name: Set up Python ${{ matrix.python-version }}
18-
uses: actions/setup-python@v3
18+
uses: actions/setup-python@v4
1919
with:
2020
python-version: ${{ matrix.python-version }}
2121

@@ -54,3 +54,13 @@ jobs:
5454
{
5555
throw "Program failed to run, see output above"
5656
}
57+
58+
- name: Prepare screenshot for archiving
59+
run: |
60+
cp screencap.png screenshot-py${{ matrix.python-version }}.png
61+
62+
- name: Archive a screenshot
63+
uses: actions/upload-artifact@v3
64+
with:
65+
name: screenshot-py${{ matrix.python-version }}
66+
path: screenshot-*.png

.github/workflows/system-monitor-linux.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v3
1818
- name: Set up Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v3
19+
uses: actions/setup-python@v4
2020
with:
2121
python-version: ${{ matrix.python-version }}
2222

@@ -53,4 +53,14 @@ jobs:
5353
elif grep -qi "exception" output.log; then
5454
echo "Program failed to run, see output above"
5555
false
56-
fi
56+
fi
57+
58+
- name: Prepare screenshot for archiving
59+
run: |
60+
cp screencap.png screenshot-py${{ matrix.python-version }}-${{ matrix.theme }}.png
61+
62+
- name: Archive a screenshot
63+
uses: actions/upload-artifact@v3
64+
with:
65+
name: screenshot-py${{ matrix.python-version }}-${{ matrix.theme }}
66+
path: screenshot-*.png

.github/workflows/system-monitor-macos.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v3
1818
- name: Set up Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v3
19+
uses: actions/setup-python@v4
2020
with:
2121
python-version: ${{ matrix.python-version }}
2222

@@ -53,4 +53,14 @@ jobs:
5353
elif grep -qi "exception" output.log; then
5454
echo "Program failed to run, see output above"
5555
false
56-
fi
56+
fi
57+
58+
- name: Prepare screenshot for archiving
59+
run: |
60+
cp screencap.png screenshot-py${{ matrix.python-version }}-${{ matrix.theme }}.png
61+
62+
- name: Archive a screenshot
63+
uses: actions/upload-artifact@v3
64+
with:
65+
name: screenshot-py${{ matrix.python-version }}-${{ matrix.theme }}
66+
path: screenshot-*.png

.github/workflows/system-monitor-windows.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v3
1818
- name: Set up Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v3
19+
uses: actions/setup-python@v4
2020
with:
2121
python-version: ${{ matrix.python-version }}
2222

@@ -60,3 +60,13 @@ jobs:
6060
{
6161
throw "Program failed to run, see output above"
6262
}
63+
64+
- name: Prepare screenshot for archiving
65+
run: |
66+
cp screencap.png screenshot-py${{ matrix.python-version }}-${{ matrix.theme }}.png
67+
68+
- name: Archive a screenshot
69+
uses: actions/upload-artifact@v3
70+
with:
71+
name: screenshot-py${{ matrix.python-version }}-${{ matrix.theme }}
72+
path: screenshot-*.png

library/lcd_simulated.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import mimetypes
2+
import shutil
23
from http.server import BaseHTTPRequestHandler, HTTPServer
34

45
from library.lcd_comm import *
56

7+
SCREENSHOT_FILE = "screencap.png"
8+
69

710
# This webserver offer a blank page displaying simulated screen with auto-refresh
811
class SimulatedLcdWebServer(BaseHTTPRequestHandler):
@@ -22,8 +25,8 @@ def do_GET(self):
2225
self.wfile.write(bytes("}, 250);", "utf-8"))
2326
self.wfile.write(bytes("</script>", "utf-8"))
2427
elif self.path.startswith("/screencap.png"):
25-
imgfile = open("screencap.png", 'rb').read()
26-
mimetype = mimetypes.MimeTypes().guess_type("screencap.png")[0]
28+
imgfile = open(SCREENSHOT_FILE, 'rb').read()
29+
mimetype = mimetypes.MimeTypes().guess_type(SCREENSHOT_FILE)[0]
2730
self.send_response(200)
2831
self.send_header('Content-type', mimetype)
2932
self.end_headers()
@@ -36,7 +39,8 @@ def __init__(self, com_port: str = "AUTO", display_width: int = 320, display_hei
3639
update_queue: queue.Queue = None):
3740
LcdComm.__init__(self, com_port, display_width, display_height, update_queue)
3841
self.screen_image = Image.new("RGB", (self.get_width(), self.get_height()), (255, 255, 255))
39-
self.screen_image.save("screencap.png", "PNG")
42+
self.screen_image.save("tmp", "PNG")
43+
shutil.copyfile("tmp", SCREENSHOT_FILE)
4044
self.orientation = Orientation.PORTRAIT
4145

4246
webServer = HTTPServer(("localhost", 5678), SimulatedLcdWebServer)
@@ -74,7 +78,8 @@ def SetOrientation(self, orientation: Orientation = Orientation.PORTRAIT):
7478
# Just draw the screen again with the new width/height based on orientation
7579
with self.update_queue_mutex:
7680
self.screen_image = Image.new("RGB", (self.get_width(), self.get_height()), (255, 255, 255))
77-
self.screen_image.save("screencap.png", "PNG")
81+
self.screen_image.save("tmp", "PNG")
82+
shutil.copyfile("tmp", SCREENSHOT_FILE)
7883

7984
def DisplayPILImage(
8085
self,
@@ -102,4 +107,5 @@ def DisplayPILImage(
102107

103108
with self.update_queue_mutex:
104109
self.screen_image.paste(image, (x, y))
105-
self.screen_image.save("screencap.png", "PNG")
110+
self.screen_image.save("tmp", "PNG")
111+
shutil.copyfile("tmp", SCREENSHOT_FILE)

0 commit comments

Comments
 (0)