Ejemplo n.º 1
0
def print_order(id_, order):
    pnc = PrinterNetCalls()
    if len(sys.argv) == 2:
        serial_port = sys.argv[1]
    else:
        serial_port = thermal.ThermalPrinter.SERIALPORT
    p = thermal.ThermalPrinter(serialport=serial_port)

    print("Attempting to print ord er_id: ", id_)
    lines = order
    print("initial paper check")
    printer_paper_status(p)
    print("---NEW--ORDER----!!")
    print("printing order_id", id_)
    p.print_text("---NEW--ORDER----!!")
    p.print_text("\n")
    for line in lines:
        printer_paper_status(p)
        print("printing line", line[:])
        p.print_text(line[:]+'\n')

    p.linefeed(5)

    check_printer_status(p)

    pnc.post_that_order_was_printed(int(id_))
    print("Sending message to server for order id: ", id_)
    time.sleep(5)
Ejemplo n.º 2
0
# coding: utf-8
import requests
import sys
import thermal
import time
from network import PrinterNetCalls, InternetConnection
import sys
import os
import greeklish
__author__ = 'gpamfilis'
import os
import shutil


pnc = PrinterNetCalls()

ids = pnc.get_orders_to_print()


def create_deltio(id_):
    try:
        # int.check_internet()
        json = pnc.get_order(id_)
    except Exception, e:
        print("This is the create_deltio exception", e)

    if json is None:
        return None
    else:    
        order = []
Ejemplo n.º 3
0
# coding: utf-8
import requests
import sys
import thermal
import time
from network import PrinterNetCalls, InternetConnection
import sys
import os
import greeklish
__author__ = 'gpamfilis'
import os
import shutil
from utils import Create


pnc = PrinterNetCalls()

ids = pnc.get_orders_to_print()


def create_deltio(id_):
    try:
        # int.check_internet()
        json = pnc.get_order(id_)
    except Exception, e:
        print("This is the create_deltio exception", e)

    if json is None:
        return None
    else:    
        order = []
Ejemplo n.º 4
0
            break


def check_printer_status(p):
    printer_status = p.has_printed()
    while printer_status is False:
        print("not done printing")
        printer_status = [p.has_printed() for i in range(10)][-1]
        time.sleep(2)
        if printer_status:
            print("printer free")
            time.sleep(5)
            break

if __name__ == '__main__':
    pnc = PrinterNetCalls()
    if len(sys.argv) == 2:
        serial_port = sys.argv[1]
    else:
        serial_port = thermal.ThermalPrinter.SERIALPORT
    p = thermal.ThermalPrinter(serialport=serial_port)

    for fil in os.listdir("./order_txt"):
        print("Attempting to print ord er_id: ", fil.split("_")[1])
        lines = read_items(fil)
        print("initial paper check")
        printer_paper_status(p)
        print("---NEW--ORDER----!!")
        print("printing order_id", fil.split("_")[1])
        p.print_text("---NEW--ORDER----!!")
        p.print_text("\n")
Ejemplo n.º 5
0
import os
import shutil


def empty_directory(folder):
    for the_file in os.listdir(folder):
        file_path = os.path.join(folder, the_file)
        try:
            if os.path.isfile(file_path):
                os.unlink(file_path)
            #elif os.path.isdir(file_path): shutil.rmtree(file_path)
        except Exception as e:
            print(e)


pnc = PrinterNetCalls()


def create_deltio():
    ids = pnc.get_orders_to_print()
    if os.path.exists("./order_txt/"):
        print("yes")
        empty_directory('./order_txt')
    else:
        print("not")
        os.mkdir("order_txt")

    for i in ids:
        print(i, len(ids))
        try:
            json = pnc.get_order(i)
Ejemplo n.º 6
0
    p.linefeed(10)

    check_printer_status(p)

    pnc.post_that_checkout_was_printed(int(id_))
    print("Sending message to server for checkout id: ", id_)

    time.sleep(5)


if __name__ == '__main__':
    get_configuration()
    with open('values.json') as data_file:
        data = json.load(data_file)
    values = data
    pnc = PrinterNetCalls(**values)
    serial_port = thermal.ThermalPrinter.SERIALPORT
    p = thermal.ThermalPrinter(serialport=serial_port)
    create = Create()
    while True:
        pnc.check_internet()
        print('New Order Section')
        order_ids = pnc.get_orders_to_print()
        print(order_ids)
        for order_id in order_ids:
            order_list = pnc.get_order3(order_id)
            print('Order List: ', order_list)
            if order_list is None:
                pass
            else:
                print_order2(order_id, order_list, p=p, pnc=pnc)