Merge remote-tracking branch 'origin/master'

This commit is contained in:
Eduardo 2024-12-11 12:48:12 +01:00
commit 85cacaddfd
77 changed files with 267 additions and 82 deletions

View File

@ -7,7 +7,7 @@
width="678.40002"
height="420.79999"
viewBox="0 0 678.40002 420.79999"
sodipodi:docname="07N131597.svg"
sodipodi:docname="07N.131.597.A.svg"
inkscape:version="1.3.2 (091e20e, 2023-11-25, custom)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
@ -27,10 +27,10 @@
inkscape:deskcolor="#d1d1d1"
showgrid="false"
inkscape:zoom="1.8882664"
inkscape:cx="339.72961"
inkscape:cx="340.25919"
inkscape:cy="210.51055"
inkscape:window-width="1920"
inkscape:window-height="1009"
inkscape:window-height="1017"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
@ -50,13 +50,13 @@
height="59.835232"
preserveAspectRatio="none"
xlink:href="img/arw-yel-down.png"
id="sensor_7"
id="sensor_3"
x="275.9704"
y="130.87033"
transform="rotate(1.16503)"
inkscape:transform-center-x="-7.8692923"
inkscape:transform-center-y="-13.339455"
inkscape:label="sensor_7"
inkscape:label="sensor_3"
inkscape:svg-dpi="1" />
<image
width="59.486801"
@ -64,8 +64,8 @@
preserveAspectRatio="none"
xlink:href="img/arw-yel-down.png"
id="sensor_8_inv"
x="169.81544"
y="234.4705"
x="398.26419"
y="202.62436"
transform="rotate(1.7410682)"
inkscape:label="sensor_8_inv"
inkscape:svg-dpi="1" />
@ -75,8 +75,8 @@
preserveAspectRatio="none"
xlink:href="img/arw-yel-down.png"
id="sensor_9_inv"
x="79.781105"
y="252.23251"
x="166.68855"
y="204.02055"
transform="rotate(-0.68766539)"
inkscape:label="sensor_9_inv"
inkscape:svg-dpi="1" />
@ -86,8 +86,8 @@
preserveAspectRatio="none"
xlink:href="img/arw-yel-down.png"
id="sensor_10_inv"
x="395.57346"
y="243.8483"
x="83.801674"
y="218.56264"
transform="rotate(-0.36448987)"
inkscape:label="sensor_10_inv"
inkscape:svg-dpi="1" />
@ -110,8 +110,8 @@
preserveAspectRatio="none"
xlink:href="img/arw-yel-down.png"
id="sensor_6"
x="319.75986"
y="175.38869"
x="296.45807"
y="84.299843"
inkscape:label="sensor_6"
inkscape:svg-dpi="1" />
<image
@ -130,8 +130,8 @@
preserveAspectRatio="none"
xlink:href="img/arw-yel-down.png"
id="sensor_4"
x="292.57666"
y="92.217812"
x="216.31624"
y="103.86871"
inkscape:label="sensor_4"
inkscape:svg-dpi="1" />
<image
@ -139,10 +139,10 @@
height="59.835232"
preserveAspectRatio="none"
xlink:href="img/arw-yel-down.png"
id="sensor_3"
x="221.80165"
y="109.07567"
inkscape:label="sensor_3"
id="sensor_7"
x="331.9556"
y="171.03726"
inkscape:label="sensor_7"
inkscape:svg-dpi="1" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 297 KiB

After

Width:  |  Height:  |  Size: 297 KiB

View File

@ -7,8 +7,8 @@
width="874"
height="610"
viewBox="0 0 874 610"
sodipodi:docname="07N131628.svg"
inkscape:version="1.3.2 (1:1.3.2+202311252150+091e20ef0f)"
sodipodi:docname="07N.131.628.A.svg"
inkscape:version="1.3.2 (091e20e, 2023-11-25, custom)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
@ -26,14 +26,15 @@
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="1.3377049"
inkscape:cx="436.9424"
inkscape:cy="305"
inkscape:window-width="2490"
inkscape:window-height="1016"
inkscape:window-x="70"
inkscape:window-y="27"
inkscape:cx="436.94241"
inkscape:cy="304.62623"
inkscape:window-width="1920"
inkscape:window-height="1017"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="g1" />
inkscape:current-layer="g1"
showgrid="false" />
<g
inkscape:groupmode="layer"
inkscape:label="Image"
@ -100,8 +101,8 @@
preserveAspectRatio="none"
xlink:href="img/arw-yel-down.png"
id="sensor_4"
x="239.01573"
y="136.1367"
x="176.96916"
y="126.41856"
inkscape:label="sensor_4"
inkscape:svg-dpi="1" />
<image
@ -110,8 +111,8 @@
preserveAspectRatio="none"
xlink:href="img/arw-yel-down.png"
id="sensor_3"
x="175.77347"
y="121.68994"
x="245.29553"
y="146.35905"
inkscape:label="sensor_3"
inkscape:svg-dpi="1"
inkscape:transform-center-x="-182.43217"

Before

Width:  |  Height:  |  Size: 320 KiB

After

Width:  |  Height:  |  Size: 320 KiB

Binary file not shown.

View File

@ -0,0 +1,18 @@
SIZE 27.5 mm, 50 mm
GAP 3 mm, 0 mm
SPEED 2
DENSITY 7
DIRECTION 0,0
REFERENCE 0,0
OFFSET 0 mm
SET PEEL OFF
SET CUTTER OFF
SET PARTIAL_CUTTER OFF
SET TEAR ON
CLS
DMATRIX 82,230,138,138,x3,22,22,"{RECIPE}-{DD}{MO}{YY}{SN5}"
CODEPAGE 1252
TEXT 212,357,"ROMAN.TTF",180,1,7,"{RECIPE}-{DD}{MO}{YY}{SN5}"
DMATRIX 82,129,138,138,x3,22,22,"{RECIPE}-{DD}{MO}{YY}{SN5}"
DMATRIX 82,28,138,138,x3,22,22,"{RECIPE}-{DD}{MO}{YY}{SN5}"
PRINT 1,1

View File

@ -0,0 +1,45 @@
CT~~CD,~CC^~CT~
^XA
~TA000
~JSN
^LT0
^MNW
^MTT
^PON
^PMN
^LH0,0
^JMA
^PR2,2
~SD22
^JUS
^LRN
^CI27
^PA0,1,1,0
^XZ
^XA
^MMT
^PW320
^LL1119
^LS0
^FT57,105^A0N,39,38^FH\^CI28^FDERRECINQUE^FS^CI27
^FT58,148^A0N,20,20^FH\^CI28^FDVia Meucci 31/A^FS^CI27
^FT58,173^A0N,20,20^FH\^CI28^FD10079 Mappano(TO)^FS^CI27
^FT18,758^A0N,23,20^FH\^CI28^FD{DD}/{MO}/{YY}^FS^CI27
^FT183,758^A0N,23,20^FH\^CI28^FD{HH}:{MI}:{SS}^FS^CI27
^FT18,981^A0N,31,30^FH\^CI28^FDESITO:^FS^CI27
^FT144,981^A0N,31,30^FH\^CI28^FDCONFORME^FS^CI27
^FT24,471^A0N,25,25^FH\^CI28^FDPart number:^FS^CI27
^FT24,513^A0N,23,23^FH\^CI28^FD{PART}^FS^CI27
^FT24,555^A0N,25,25^FH\^CI28^FDSequential number:^FS^CI27
^FT24,598^A0N,23,23^FH\^CI28^FD{SN4}^FS^CI27
^FT18,833^A0N,23,23^FH\^CI28^FDOperatore:^FS^CI27
^FT157,674^A0N,23,23^FH\^CI28^FD{RESLEAK} mbar^FS^CI27
^FT18,674^A0N,23,23^FH\^CI28^FD{TTEST} s^FS^CI27
^FT18,724^A0N,23,23^FH\^CI28^FD{PTEST} mbar^FS^CI27
^BY1,3,64^FT58,384^BCN,,N,N
^FH\^FD>:{PART}^FS
^FT58,241^A0N,25,25^FH\^CI28^FD{DESCRIPTION}^FS^CI27
^FT58,292^A0N,45,46^FH\^CI28^FDLEAK TEST^FS^CI27
^FT165,833^A0N,23,23^FH\^CI28^FD{BADGE_NUM}^FS^CI27
^PQ1,0,1,Y
^XZ

View File

@ -0,0 +1,46 @@
CT~~CD,~CC^~CT~
^XA
~TA000
~JSN
^LT0
^MNW
^MTT
^PON
^PMN
^LH0,0
^JMA
^PR2,2
~SD26
^JUS
^LRN
^CI27
^PA0,1,1,0
^XZ
^XA
^MMT
^PW320
^LL1119
^LS0
^FT57,105^A0N,39,38^FH\^CI28^FDERRECINQUE^FS^CI27
^FT58,148^A0N,20,20^FH\^CI28^FDVia Meucci 31/A^FS^CI27
^FT58,173^A0N,20,20^FH\^CI28^FD10079 Mappano(TO)^FS^CI27
^FT18,758^A0N,23,20^FH\^CI28^FD{DD}/{MO}/{YY}^FS^CI27
^FT183,758^A0N,23,20^FH\^CI28^FD{HH}:{MI}:{SS}^FS^CI27
^FT18,981^A0N,31,30^FH\^CI28^FDESITO:^FS^CI27
^FT144,981^A0N,31,30^FH\^CI28^FDCONFORME^FS^CI27
^FT24,439^A0N,25,25^FH\^CI28^FDPart number:^FS^CI27
^FT24,481^A0N,23,23^FH\^CI28^FD{LABELTXT_2}^FS^CI27
^FT24,555^A0N,25,25^FH\^CI28^FDSequential number:^FS^CI27
^FT24,598^A0N,23,23^FH\^CI28^FD{SN4}^FS^CI27
^FT18,833^A0N,23,23^FH\^CI28^FDOperatore:^FS^CI27
^FT157,674^A0N,23,23^FH\^CI28^FD{RESLEAK} mbar^FS^CI27
^FT18,674^A0N,23,23^FH\^CI28^FD{TTEST} s^FS^CI27
^FT18,724^A0N,23,23^FH\^CI28^FD{PTEST} mbar^FS^CI27
^BY1,3,64^FT25,384^BCN,,N,N
^FH\^FD>:{PART}^FS
^FT58,241^A0N,25,25^FH\^CI28^FD{LABELTXT_1}^FS^CI27
^FT58,292^A0N,45,46^FH\^CI28^FDLEAK TEST^FS^CI27
^FT165,833^A0N,23,23^FH\^CI28^FD{BADGE_NUM}^FS^CI27
^FT24,512^A0N,23,23^FH\^CI28^FD{LABELTXT_3}^FS^CI27
^PQ1,0,1,Y
^XZ

View File

@ -56,18 +56,20 @@ status_root:api/device-info-update/
download_root:media/uploads/
images_path: data/images
poll_time: 60
hold_time: 30
poll_time: 10
hold_time: 10
service_account_json: config/machine_settings/gcloud_default.json
bucket_id: st_ten_img
[archive_synchronizer_extra]
archive_endpoint: https://r5portal.it/api/st-ten-save/
portal_address: https://r5portal.it/
archive_root:api/st-ten-save/
status_root:api/device-info-update/
download_root:media/uploads/
archive_endpoint: http://172.20.3.13/api/st-ten-save/
images_path: data/images
poll_time: 60
hold_time: 30
service_account_json: config/machine_settings/gcloud_default.json
bucket_id: st_ten_img
poll_time: 10
hold_time: 10
[label_printer]
platform: windows

View File

@ -5,6 +5,7 @@ image_for_warning= st-ten-1
[hardware_config]
archive_synchronizer: present
archive_synchronizer_extra: present
galaxy_camera: absent
uvc_camera: absent
label_printer: present
@ -18,6 +19,12 @@ screwdriver: absent
digital_io: present
external_flush_blow: absent
# VERO PROJECT LOCAL SERVER
[archive_synchronizer_extra]
portal_address: http://172.20.3.13:45006/
poll_time: 10
hold_time: 10
[tecna_t3]
port: COM4
model: t3l

View File

@ -5,6 +5,7 @@ image_for_warning= st-ten-14
[hardware_config]
archive_synchronizer: present
archive_synchronizer_extra: present
uvc_camera: absent
label_printer: present
neo_pixels: absent
@ -19,13 +20,19 @@ fixture_id: absent
discard_box: absent
enforce_piece_removal: no
# VERO PROJECT LOCAL SERVER
[archive_synchronizer_extra]
portal_address: http://172.20.3.13:45007/
poll_time: 10
hold_time: 10
[tecna_t3]
port: /dev/ttyUSB0
model: t3l
[label_printer]
platform: linux
printer: ZTC-ZD421-203dpi-ZPL
printer: Zebra_Technologies_ZTC_ZD421-203dpi_ZPL
[digital_io]
# OUTPUT MAP FOR FIXTURE CONNECTOR

View File

@ -2,8 +2,10 @@
description = ST-TEN-4 - REPARTO PREFORMATURA - MAPPANO
instruction_folder = st-ten-4
image_for_warning= st-ten-4
[hardware_config]
archive_synchronizer: present
archive_synchronizer_extra: present
uvc_camera: absent
label_printer: present
neo_pixels: absent
@ -13,6 +15,12 @@ vision_saver: absent
vision: absent
screwdriver: absent
# VERO PROJECT LOCAL SERVER
[archive_synchronizer_extra]
portal_address: http://172.20.3.13:45008/
poll_time: 10
hold_time: 10
[tecna_t3]
port: COM4
model: t3p

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

View File

@ -46,10 +46,11 @@ class ArchiveSynchronizer(Component):
self._do_set_period({"period": float(self.config[self.name]["poll_time"])})
self.hold_time = round(float(self.config[self.name]["hold_time"]) * 1000)
self.gcs_client = storage.Client.from_service_account_json(self.config[self.name]["service_account_json"])
self.gcs_client._http.mount("", HTTPAdapter(max_retries=Retry(total=0))) # this seems to be useless
self.gcs_client._http.adapters.move_to_end("", last=False) # this seems to be useless
self.bucket_id = self.config[self.name]["bucket_id"]
if self.name == "archive_synchronizer":
self.gcs_client = storage.Client.from_service_account_json(self.config[self.name]["service_account_json"])
self.gcs_client._http.mount("", HTTPAdapter(max_retries=Retry(total=0))) # this seems to be useless
self.gcs_client._http.adapters.move_to_end("", last=False) # this seems to be useless
self.bucket_id = self.config[self.name]["bucket_id"]
self.gcs_bucket = None
@db.connection_context()
@ -57,16 +58,36 @@ class ArchiveSynchronizer(Component):
if self.main_window is None:
self.main_window = get_main_window()
for record in list(Archive.select().where((Archive.archived != True) | (Archive.uploaded != True))): # using "is not True" breaks the query.. # list() forces the complete execution of the query unlocking the db unlike __enter__()
if self.name != "archive_synchronizer_extra":
# MAIN SERVER
bit_pos = 0
unsaved_records = Archive.select().where((Archive.archived == 0) |
(Archive.archived == 2) |
(Archive.uploaded == 0))
else:
# EXTRA SERVER (VERO PROJECT SPA)
bit_pos = 1
unsaved_records = Archive.select().where((Archive.archived == 0) |
(Archive.archived == 1))
for record in unsaved_records:
if not self.simulate:
if record.archived is not True:
record.archived = self.remote_archive(record) is True
s = time.time()
save_ok = self.remote_archive(record) is True
e = time.time()
else:
save_ok=True
if record.uploaded is not True:
record.uploaded = self.remote_store(record) is True
else:
self.log.info("simulated archive synchronizer cycle")
#record.save()
save_ok=True
if save_ok:
record.archived |= (1 << bit_pos)
self.log.info(f"({self.name}) id {record.id}: archived remotely")
else:
self.log.info(f"({self.name}) id {record.id}: failed to archive remotely")
self.main_window.run_request.emit(record.save, [], {})
if self.hold_time > 0:
@ -77,7 +98,9 @@ class ArchiveSynchronizer(Component):
self.machine_status="working"
super()._get()
self.update_machine_status()
if self.name == "archive_synchronizer":
self.update_machine_status()
def update_machine_status(self):
status_call = f"{self.status_endpoint}?machine-id={self.machine_id.upper()}&status={self.machine_status}"
@ -141,16 +164,28 @@ class ArchiveSynchronizer(Component):
if not self.simulate:
with requests.Session() as s:
s.mount("", HTTPAdapter(max_retries=Retry(total=0))) # this disables retries
r = requests.post(self.archive_endpoint, params={
"data": json.dumps(record.test_data),
"machine_id": self.machine_id,
"overridden": record.overridden,
"recipe": record.test_data.get("recipe", {}).get("name", None),
"result": "OK" if record.result else "KO",
"serial": record.id,
"time": record.time.isoformat(),
"user": record.user.username,
}, timeout=5, verify=False)
if self.name == "archive_synchronizer":
r = requests.post(self.archive_endpoint, params={
"data": json.dumps(record.test_data),
"machine_id": self.machine_id,
"overridden": record.overridden,
"recipe": record.test_data.get("recipe", {}).get("name", None),
"result": "OK" if record.result else "KO",
"serial": record.id,
"time": record.time.isoformat(),
"user": record.user.username,
}, timeout=5, verify=False)
else:
r = requests.get(self.archive_endpoint, params={
"machine_id": self.machine_id,
"overridden": record.overridden,
"recipe": record.test_data.get("recipe", {}).get("name", None),
"result": "OK" if record.result else "KO",
"serial": record.id,
"time": record.time.isoformat(),
"user": record.user.username,
}, timeout=5, verify=False)
if r.status_code != 200:
raise AssertionError("bad status response")
except AssertionError as e:
@ -198,22 +233,26 @@ class ArchiveSynchronizer(Component):
def remote_fetch(self, remote_path=None, local_path=None):
"""
Download a single file from the server.
Download a single file from the server and retrieve the last update time and response status.
:param remote_path: Path of where to download the file from
:param local_path: Path of where to save the file to
:return: A dictionary with errors if any occur.
:return: A dictionary with errors if any occur, and last update information.
"""
if remote_path is None:
raise ValueError("remote_path cannot be None")
if local_path is None:
raise ValueError("local_path cannot be None")
call_url = f"https://dev.r5portal.it/{remote_path}"
if "--dev-portal" in sys.argv:
call_url = f"https://dev.r5portal.it/{remote_path}"
else:
call_url = f"https://r5portal.it/{remote_path}"
log_info_type = "Download"
log_time = datetime.now()
log_info = f"Attempted to download from {call_url}"
last_update_info = None
try:
if not self.simulate:
with requests.Session() as s:
@ -223,21 +262,26 @@ class ArchiveSynchronizer(Component):
self.log.info(f"HTTP Status Code: {response.status_code}")
last_update_info = {
"last_update_time": log_time.isoformat(),
"response_status": response.status_code
}
if response.status_code == 404:
log_info += " - File not found"
self.log.warning(log_info)
self.log_to_db(log_time, log_info_type, log_info)
return {"error": "File not found"}
return {"error": "File not found", "last_update_info": last_update_info}
elif response.status_code in [403, 401]:
log_info += " - Access forbidden or not logged in"
self.log.warning(log_info)
self.log_to_db(log_time, log_info_type, log_info)
return {"error": "Access forbidden or not logged in"}
return {"error": "Access forbidden or not logged in", "last_update_info": last_update_info}
elif response.status_code != 200:
log_info += f" - Unexpected HTTP response status: {response.status_code}"
self.log.error(log_info)
self.log_to_db(log_time, log_info_type, log_info)
return {"error": "Unexpected HTTP response status"}
return {"error": "Unexpected HTTP response status", "last_update_info": last_update_info}
os.makedirs(local_path, exist_ok=True)
@ -248,23 +292,23 @@ class ArchiveSynchronizer(Component):
log_info += f" - File downloaded successfully: {local_file_path}"
self.log.info(log_info)
self.log_to_db(log_time, log_info_type, log_info)
return {"downloaded_file": local_file_path}
return {"downloaded_file": local_file_path, "last_update_info": last_update_info}
except requests.ConnectionError as e:
log_info += f" - Connection error: {str(e)}"
self.log.error(log_info)
self.log_to_db(log_time, log_info_type, log_info)
return {"error": "Connection error"}
return {"error": "Connection error", "last_update_info": last_update_info}
except requests.Timeout as e:
log_info += f" - Timeout error: {str(e)}"
self.log.error(log_info)
self.log_to_db(log_time, log_info_type, log_info)
return {"error": "Timeout error"}
return {"error": "Timeout error", "last_update_info": last_update_info}
except Exception as e:
log_info += f" - Unexpected error: {str(e)}"
self.log.error(log_info)
self.log_to_db(log_time, log_info_type, log_info)
return {"error": "Unexpected error"}
return {"error": "Unexpected error", "last_update_info": last_update_info}
def log_to_db(self, log_time, log_info_type, log_info):
"""Save log information to the database."""

View File

@ -1,7 +1,7 @@
from datetime import datetime
from peewee import (AutoField, BooleanField, DateTimeField, ForeignKeyField,
TextField)
TextField, IntegerField)
from playhouse.sqlite_ext import JSONField
from .base_model import BaseModel, db
@ -16,7 +16,7 @@ class Archive(BaseModel):
overridden = BooleanField(null=False)
test_data = JSONField(null=False)
label = TextField(null=True)
archived = BooleanField(null=False, default=False)
archived = IntegerField(null=False, default=False)
uploaded = BooleanField(null=False, default=False)
@classmethod

View File

@ -101,6 +101,7 @@ try:
# INIT COMPONENT
self.components_specs = {
"archive_synchronizer": {"c": ArchiveSynchronizer},
"archive_synchronizer_extra": {"c": ArchiveSynchronizer},
"label_printer": {"c": Os_Label_Printer, "t": False},
"extra_label_printer": {"c": Os_Label_Printer, "t": False},
"label_printer_2": {"c": BrotherLabelPrinter, "t": False},

View File

@ -20,7 +20,7 @@ class TestArchiveSynchronizer(unittest.TestCase):
@patch('os.makedirs')
@patch('builtins.open', new_callable=unittest.mock.mock_open)
def test_remote_fetch_success(self, mock_open, mock_makedirs, mock_session):
remote_path = "img-025.png"
remote_path = "img-001.png"
local_path = "config/warning_images"
mock_response = Mock()
@ -36,7 +36,7 @@ class TestArchiveSynchronizer(unittest.TestCase):
@patch('requests.Session')
def test_remote_fetch_not_found(self, mock_session):
remote_path = "img-025.png"
remote_path = "img-001.png"
local_path = "config/warning_images"
mock_response = Mock()
@ -48,7 +48,7 @@ class TestArchiveSynchronizer(unittest.TestCase):
@patch('requests.Session')
def test_remote_fetch_forbidden(self, mock_session):
remote_path = "img-025.png"
remote_path = "img-001.png"
local_path = "config/warning_images"
mock_response = Mock()
@ -61,7 +61,7 @@ class TestArchiveSynchronizer(unittest.TestCase):
@patch('requests.Session')
@patch('requests.Session.get', side_effect=requests.ConnectionError("Connection error"))
def test_remote_fetch_connection_error(self, mock_get, mock_session):
remote_path = "img-025.png"
remote_path = "img-001.png"
local_path = "config/warning_images"
result = self.synchronizer.remote_fetch(remote_path, local_path)
@ -72,7 +72,7 @@ class TestArchiveSynchronizer(unittest.TestCase):
@patch('requests.Session')
@patch('requests.Session.get', side_effect=requests.Timeout("Timeout error"))
def test_remote_fetch_timeout_error(self, mock_get, mock_session):
remote_path = "img-025.png"
remote_path = "img-001.png"
local_path = "config/warning_images"
result = self.synchronizer.remote_fetch(remote_path, local_path)
@ -85,14 +85,14 @@ class TestArchiveSynchronizer(unittest.TestCase):
mock_response.json.return_value = {
"STATUS": "OK",
"ACTIONS_TO_DO": [
{"remote_path": "img-025.png", "local_path": "config/warning_images"}
{"remote_path": "img-001.png", "local_path": "config/warning_images"}
]
}
with patch.object(self.synchronizer, 'remote_fetch',
return_value={"downloaded_file": "config/warning_images/img-025.png"}) as mock_rf:
return_value={"downloaded_file": "config/warning_images/img-001.png"}) as mock_rf:
self.synchronizer.parse_response_and_execute(mock_response)
mock_rf.assert_called_once_with(remote_path="img-025.png", local_path="config/warning_images")
mock_rf.assert_called_once_with(remote_path="img-001.png", local_path="config/warning_images")
def test_parse_response_and_execute_json_error(self):
mock_response = Mock()

View File

@ -51,7 +51,7 @@ class Logs_Management(Widget):
# Set a specific column width for columns; for example, set 'Info' column
for column in range(self.crud.db_tw.columnCount()):
self.crud.db_tw.setColumnWidth(column, 200) # Set width to 300 pixels
self.crud.db_tw.setColumnWidth(column, 175) # Set width to 300 pixels
def row_filter(self, row, row_number, crud):
try:

View File

@ -39,6 +39,7 @@
</property>
<addaction name="about_a"/>
<addaction name="download_a"/>
<addaction name="update_a"/>
</widget>
<widget class="QMenu" name="admin_m">
<property name="font">
@ -136,6 +137,11 @@
</property>
</action>
<action name="download_a">
<property name="text">
<string>Storico Attivita</string>
</property>
</action>
<action name="update_a">
<property name="text">
<string>Aggiornamento</string>
</property>

View File

@ -371,7 +371,7 @@ class Test(Widget):
self.archived.label = compiled_label
self.log.info(f"Label printed. Saving...")
#self.archived.save()
self.main_window.run_request.emit(self.archived.save, [], {})
self.main_window.main_window.run_request.emit(self.archived.save, [], {})
self.next_timer.start(500)
elif self.step.step_type == "wait":
self.next_timer.start(500)