def receipt():
    if request.method == 'POST':
        # Get endpoints: sudo lsusb -v -d 0416:5011
        p = printer.Usb(0x0416, 0x5011, out_ep=0x03)
        #p = printer.File("/dev/usb/lp0")
        # p.charcode('WPC1251')
        p._raw('\x1c\x2e')
        p._raw('\x1b\x74\x17')
        p.set(align='CENTER', font='a', type='normal', width=1, height=1)
        p.image("logo.png")
        m = Markup(p)
        m.read_text(request.form['data'])
        return 'Ok'
    else:
        return render_template('receipt.html')
Exemple #2
0
from inline_markup import InlineMarkup

from util import st_col

from handle_keyboard import handle_keyboard
from handle_inline_keyboard import handle_inline_keyboard
from templates import tpl_cmd

TOKEN = '<YOUR_TOKEN>'  # полученный у @BotFather

bot = telebot.TeleBot(TOKEN)

# соединение с базой данных
db = SPCB_DB('localhost', '<user>', '<password>', 'spcart_bot')

markup = Markup()
inline_markup = InlineMarkup()

if __name__ == '__main__':
    db.connect()


@bot.message_handler(commands=['start', ''])
def start(message):

    try:

        msg = u'SPCartBot — Калькулятор покупок.\n\r'
        msg += u'Основные команды:\n\r'
        msg += u'/new —  Добавить товар через форму (псевдоним: "+", "new")\n\r'
        msg += u'/del — Удалить товар выбрав его из списка товаров (псевдоним: "-", "del")\n\r'
Exemple #3
0
# coding=utf-8

from escpos import *
from markup import Markup

p = printer.File("/dev/usb/lp0")
p.charcode('WPC1251')
p.set(align='CENTER', font='a', type='normal', width=1, height=1)
p.image("logo.png")

m = Markup(p)
with open('test.txt', 'r') as textfile:
    text = textfile.read().decode('utf8')
m.read_text(text)
def test_renders_titled_section():
    assert Markup().section(3, 'title', '''body 1
body 2''').as_markdown() == '''### title
def test_renders_code_block():
    code = '''first line
second line
'''
    assert Markup().code_block(code).as_markdown() == '''```
def test_renders_header_and_code_block():
    assert Markup().header(2, "header 2").code_block('''line 1
line 2''').as_markdown() == '''## header 2
def test_renders_headers():
    assert Markup().header(1, "header 1").as_markdown() == '# header 1\n'
    assert Markup().header(2, "header 2").as_markdown() == '## header 2\n'
    assert Markup().header(3, "header 3").as_markdown() == '### header 3\n'
Exemple #8
0
def _as_markup(index, interaction) -> Markup:
    return Markup().header(2, _interaction_header(index, interaction)) \
        .section(3, REQ_HEADER_TITLE, _headers_to_string(interaction.request_headers)) \
        .section(3, REQ_BODY_TITLE, interaction.request_body if not '' else '\n') \
        .section(3, RESPONSE_HEADER_TITLE, _headers_to_string(interaction.response_headers)) \
        .section(3, _response_body_title(interaction), interaction.response_body)