Fixed label print copies and added sleep after print

This commit is contained in:
2022-04-22 17:55:17 +02:00
parent fe24a5972d
commit 7e977881b4
3 changed files with 10 additions and 3 deletions

View File

@@ -1,3 +1,5 @@
import time
from django.views import generic
from .models import Container, ContainerType
import logging, json, re
@@ -152,8 +154,12 @@ class ContainerPrintLabelView(LoginRequiredMixin, generic.DetailView):
be_class = backend_factory(selected_backend)['backend_class']
be = be_class(config['PRINTER']['PRINTER'])
context['logs'].append('Got backend driver')
for i in range(1, num_copies):
context['logs'].append(f'Start printing {num_copies} labels')
for i in range(0, num_copies):
context['logs'].append(f'printing #{i}')
be.write(qlr.data)
if 'WAIT_AFTER_PRINT_s' in config['LABEL']:
time.sleep(config['LABEL']['WAIT_AFTER_PRINT_s'])
context['logs'].append('Data sent to printer')
be.dispose()