Browse Source

remove results count

english-french
manetta 6 years ago
parent
commit
f8843bbb02
  1. 13
      printer.py
  2. 11
      start.py
  3. 2
      templates/en/results.html
  4. 2
      templates/fr/results.html

13
printer.py

@ -47,7 +47,7 @@ def insert_linebreaks(string, linelength):
count += 1
return new
def printNow(query, results, results_count):
def printNow(query, results):
if connected == True:
printerpath = check_printer_path()
try:
@ -58,16 +58,10 @@ def printNow(query, results, results_count):
print(escpos['justify_center'], file=print_pointer, flush=True)
printed = False
if results_count == None or results_count == 'None':
results_count = 0
results_count_max = results_count + 5
current_count = 0
for x, document in results.items():
for n, sentence in enumerate(document['matches']):
if current_count == results_count:
printed = True
if results_count < results_count_max:
if results_count < 4:
results_count += 1
sentence = str(sentence) # Turn Flask Markup object back to normal python string
sentence = char_swap(sentence)
@ -124,12 +118,9 @@ def printNow(query, results, results_count):
results_count = 0
# printNow(query, results, results_count)
return results_count
except:
e = sys.exc_info()[0]
print("Could not print: {}".format(e))
return 0
# query = 'noise'
# results, _, _ = readings.request_results(query)

11
start.py

@ -47,22 +47,15 @@ def index_lang(lang):
else:
connection = 'connected'
# Check if print command
if request.args.get('results_count', ''):
results_count = int(request.args.get('results_count', ''))
print('results_count', results_count)
else:
results_count = 0
if request.args.get('q', ''):
results, filenames, analytics = readings.request_results(query)
# print commands
if request.args.get('print', '') == 'now':
if connection == 'connected':
results_count = printer.printNow(query, results, results_count)
printer.printNow(query, results)
return flask.render_template(lang+'/results.html', query=query, results=results, filenames=filenames, connection=connection, suggestions=suggestions, analytics=analytics, lang=lang, results_count=results_count)
return flask.render_template(lang+'/results.html', query=query, results=results, filenames=filenames, connection=connection, suggestions=suggestions, analytics=analytics, lang=lang)
else:
index = readings.load_index()

2
templates/en/results.html

@ -3,7 +3,7 @@
{% block nav %}
<div id="print" class="blink {{ connection }}">
<a href="?q={{ query }}&print=now&results_count={{ results_count }}"><img src="/static/images/epson.png"></a>
<a href="?q={{ query }}&print=now"><img src="/static/images/epson.png"></a>
</div>
<script>
(function () {

2
templates/fr/results.html

@ -3,7 +3,7 @@
{% block nav %}
<div id="print" class="blink {{ connection }}">
<a href="?q={{ query }}&print=now&results_count={{ results_count }}"><img src="/static/images/epson.png"></a>
<a href="?q={{ query }}&print=now"><img src="/static/images/epson.png"></a>
</div>
<script>
(function () {

Loading…
Cancel
Save