Giter Site home page Giter Site logo

labello's Introduction

ABOUT

A printing service for the Brother QL-720NW and similar label printer.
The brotherprint library is from: https://github.com/fozzle/python-brotherprint

RUN

You only need Python 2.7 or Python 3!
Change the labelprinterServeConf.py to yor needs or create a labelprinterServeConf_local.py, all variables set there will overwrite the default config.

run

python labelprinterServe.py

or: use Docker

POSSIBLE PROBLEMS AND POSSIBLE SOLUTIONS

weird behaviour on old Python versions

The main deployment of this software uses a relatively current version of Python (take a look at Dockerfile to see which one).

If you experience weird bugs (especially encoding-related ones) while using an older version of Python, please file an issue and try to use a newer version of Python.

can't bind to socket

Labello tries to bind itself to :: by default. This means it will respond to all requests regardless of the client's ip address, the used network interface or the used version of the internet protocol.

On some systems this might fail. Please file an issue in this case. If you get an error message stating something like socket.gaierror: [Errno -9] Address family for hostname not supported on startup, you can try to set SERVER_ADDRESS to 0.0.0.0 in the config file. This should restore the old behaviour and just listen on IPv4.

labello's People

Contributors

bison-- avatar dependabot[bot] avatar derf avatar dodonator avatar marudor avatar mraerino avatar nomaster avatar penma avatar ytvwld avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

labello's Issues

Font and size may not match

char_size in brotherprint.py sets the font size to use.

But there's a problem: Not every font works with every size.

We should at least display a proper error message and not print with another size.

(Ideally, we should check if font and size match before submitting the form.)

printing (too big) barcodes results in empty label

barcodes are not being printed.

  1. Goto http://127.0.0.1:8000/barcode
  2. Type in 0250123
  3. PRINT
  4. The label is empty :(
Output:
$ python labelprinterServe.py
started httpserver...
127.0.0.1 - - [01/Mar/2016 15:42:50] "GET / HTTP/1.1" 200 -
self.path /
127.0.0.1 - - [01/Mar/2016 15:43:02] "GET /barcode HTTP/1.1" 200 -
self.path /barcode
127.0.0.1 - - [01/Mar/2016 15:44:26] "POST /barcode HTTP/1.1" 301 -
multipart/form-data {'boundary': '---------------------------1063370951714649856401658044'}
{'text': ['0250123'], 'barcodeType': ['code39'], 'barcodeHeight': ['100'], 'printMode': ['barcode'], 'barcodeRatio': ['3:1'], 'barcodeWidth': ['medium']}
0250123

don't log the printed barcodes by default

Currently, all HTTP requests (and therefore all printed texts) are logged to stdout. Example:

niklas@panzersperre~/d/labello> python labelprinterServe.py 
started httpserver...
127.0.0.1 - - [09/Jun/2017 19:38:04] "GET /magic HTTP/1.1" 200 -
self.path /magic
127.0.0.1 - - [09/Jun/2017 19:38:04] "GET /app.js HTTP/1.1" 200 -
self.path /app.js
127.0.0.1 - - [09/Jun/2017 19:38:05] "GET /4972b1fd89927b8ae18fb74e4efb3c2f.ttf HTTP/1.1" 200 -
self.path /4972b1fd89927b8ae18fb74e4efb3c2f.ttf
127.0.0.1 - - [09/Jun/2017 19:38:09] "POST / HTTP/1.1" 301 -
application/x-www-form-urlencoded {}
{'text': ['abc'], 'align': ['left'], 'font': ['lettergothic'], 'fontSize': ['42']}
abc
start printing: abc
127.0.0.1 - - [09/Jun/2017 19:38:13] "POST / HTTP/1.1" 301 -
application/x-www-form-urlencoded {}
{'text': ['def'], 'align': ['left'], 'font': ['lettergothic'], 'fontSize': ['42']}
def
start printing: def

This should be turned off in production.

=> TODO: Add option to disable this behaviour.

display local ip address

It would be practical to display the ip of the labelprinter somewhere in the web UI, as searching for the ip of the printer every time one needs to automate printing is quite annoying. An endpoint (labello.chaosdorf.space/ip) giving out only the IP might also be practical.

Support Python 3

Currently, Labello requires Python 2.7.

What needs to be changed?

  • use print as a function (using __future__)
  • importing the library
  • config parser
  • the web server
  • the connection to the printer

"base" printing doesn't work on Python 3.7

The resulting error message is not very helpful:

172.17.0.1 - - [22/Nov/2018 19:21:00] "POST /base HTTP/1.1" 301 -
multipart/form-data {'boundary': '---------------------------94047808817135404431800418516'}
<_io.BufferedReader name=4>
ERROR: 'CONTENT-LENGTH'

error pages look weird

We're starting the response too early, so when we transmit an error page, it won't be rendered correctly.

As an example, the timeout error looks like this:

POST OK.
start printing: foo
HTTP/1.0 500 ERROR: timed out
Server: BaseHTTP/0.6 Python/3.8.10
Date: Tue, 24 Aug 2021 16:18:10 GMT
Connection: close
Content-Type: text/html;charset=utf-8
Content-Length: 453

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
        <title>Error response</title>
    </head>
    <body>
        <h1>Error response</h1>
        <p>Error code: 500</p>
        <p>Message: ERROR: timed out.</p>
        <p>Error code explanation: 500 - Server got itself in trouble.</p>
    </body>
</html>

If we don't send the first two lines, we'll get the HTML rendered.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.