From fd6a0e4bda7fe96e592d656aa84cf1a13eb13a9f Mon Sep 17 00:00:00 2001 From: Davis Goglin Date: Mon, 28 Mar 2016 15:15:53 -0700 Subject: [PATCH] Add an automatic newline for some methods --- escpos/cli.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/escpos/cli.py b/escpos/cli.py index 0f2f55a..21b884b 100644 --- a/escpos/cli.py +++ b/escpos/cli.py @@ -15,6 +15,9 @@ import sys import six from . import config +# A list of functions that work better with a newline to be sent after them. +REQUIRES_NEWLINE = ('qr', 'barcode', 'text', 'block_text') + # Used in demo method # Key: The name of escpos function and the argument passed on the CLI. Some # manual translation is done in the case of barcodes_a -> barcode. @@ -477,12 +480,13 @@ def main(): if not printer: raise Exception('No printers loaded from config') - target_command = command_arguments.pop('func') if hasattr(printer, target_command): # print command with args getattr(printer, target_command)(**command_arguments) + if target_command in REQUIRES_NEWLINE: + printer.text("\n") else: command_arguments['printer'] = printer globals()[target_command](**command_arguments)