def ean12_to_ean13(): """ calculate the checksum of an ean12 to create an ean13 """ value = raw_input( 'Ean12: ' ) if not( value.isdigit() ) or not ( len(value)== 12 ): print 'EAN12 must have 12 digits!' return print( 'Ean13: %s' % calculate_ean13( value ) )
def ean12_to_ean13(): """ calculate the checksum of an ean12 to create an ean13 """ value = raw_input('Ean12: ') if not (value.isdigit()) or not (len(value) == 12): print 'EAN12 must have 12 digits!' return print('Ean13: %s' % calculate_ean13(value))
def product_id_to_ean13(): """ Create an ean13 from the mchobby product id """ value = raw_input( 'Product ID: ' ) if not( value.isdigit() ): print 'Product ID can only have digits!' return product_ean = '32321%07i' % int(value) # prefix 3232 + product 1 + id_product product_ean = calculate_ean13( product_ean ) # Add the checksum to 12 positions print( 'Ean13: %s' % product_ean )
def product_id_to_ean13(): """ Create an ean13 from the mchobby product id """ value = raw_input('Product ID: ') if not (value.isdigit()): print 'Product ID can only have digits!' return product_ean = '32321%07i' % int( value) # prefix 3232 + product 1 + id_product product_ean = calculate_ean13( product_ean) # Add the checksum to 12 positions print('Ean13: %s' % product_ean)
def print_quantity_doc(): """ Print the ean13 document IN MULTIPLE QUANTITY on Zebra. """ # 3232 is used for belgian courrier, let say the following '1' to identify product and 576 for id_product ean_base = '323210000576' ean13 = calculate_ean13(ean_base) print ean13 print('Print the EAN13 (%02i) ZPL document' % PRINTER_QUANTITY) print('----------------------------------') medium = PrinterCupsAdapter(printer_queue_name=PRINTER_QUEUE_NAME) d = ZplDocument(target_encoding=PRINTER_ENCODING, printer_adapter=medium, title='Barcode doc x %i' % PRINTER_QUANTITY) # Start a Print format d.format_start() # Set Quantity d.print_quantity(PRINTER_QUANTITY) # Write a BarCode field d.field(origin=(120, 11), font=d.font('E'), data=u'RASPBERRY.') d.field(origin=(120, 42), font=d.font('E'), data=u'Pi.2......') d.ean13(origin=(130, 80), ean=unicode(ean13), height_dots=50) d.field(origin=(140, 160), font=d.font('C'), data=u'MC Hobby sprl') d.field(origin=(130, 180), font=d.font('C'), data=u'shop.mchobby.be') # End Print format d.format_end() medium.open() # Open the media for transmission. # With CUPS medium this open a temporary file try: d.send() # With CUPS medium this send the data to the temporary file medium.flush() # With CUPS medium this close the temporary file and # sends to file to the print queue finally: medium.close() del (medium)
def print_quantity_doc( ): """ Print the ean13 document IN MULTIPLE QUANTITY on Zebra. """ # 3232 is used for belgian courrier, let say the following '1' to identify product and 576 for id_product ean_base = '323210000576' ean13 = calculate_ean13( ean_base ) print ean13 print( 'Print the EAN13 (%02i) ZPL document' % PRINTER_QUANTITY ) print( '----------------------------------' ) medium = PrinterCupsAdapter( printer_queue_name = PRINTER_QUEUE_NAME ) d = ZplDocument( target_encoding = PRINTER_ENCODING, printer_adapter = medium, title = 'Barcode doc x %i' % PRINTER_QUANTITY ) # Start a Print format d.format_start() # Set Quantity d.print_quantity( PRINTER_QUANTITY ) # Write a BarCode field d.field( origin=(120,11), font=d.font('E'), data=u'RASPBERRY.' ) d.field( origin=(120,42), font=d.font('E'), data=u'Pi.2......' ) d.ean13( origin=(130,80), ean=unicode(ean13), height_dots = 50 ) d.field( origin=(140,160), font=d.font('C'), data=u'MC Hobby sprl' ) d.field( origin=(130,180), font=d.font('C'), data=u'shop.mchobby.be' ) # End Print format d.format_end() medium.open() # Open the media for transmission. # With CUPS medium this open a temporary file try: d.send() # With CUPS medium this send the data to the temporary file medium.flush() # With CUPS medium this close the temporary file and # sends to file to the print queue finally: medium.close() del( medium )
def print_for_product( cachedphelper, id ): """ GO TO print the labels for a given ID product """ item = cachedphelper.products.product_from_id( id ) if item == None: print( 'Oups, %i is not a valid product' % id ) return # Detection de la largeur de l'étiquette dans LS:S (label size=small) params = get_product_params_dic( cachedphelper, id ) label_size = 'large' if 'LS' in params: if params['LS']=='S': label_size = 'small' else: label_size = 'large' if len( item.ean13 )>0 and (item.ean13 != '0') : product_ean = item.ean13 print( '%i : %s - %s ' % (id,item.reference,product_ean) ) else: product_ean = '32321%07i' % id # prefix 3232 + product 1 + id_product product_ean = calculate_ean13( product_ean ) # Add the checksum to 12 positions print( '%i : %s - %s *generated*' % (id,item.reference,product_ean) ) while True: print( '-'*20 ) print( '+ : switch label size ' ) print( '+q: quit this print | 0: quit this print ' ) print( '' ) print( 'Label format: %s' % label_size.upper() ) value = raw_input( 'How many label for %s: ' % item.reference ) if len(value)==0: value = '1' if value=='0': return if value=='+': # change label size label_size = 'large' if label_size == 'small' else 'small' continue if value=='+q': #user abord return if not value.isdigit(): print( '%s is not a numeric value' % value ) return if int(value) > 25: value2 = raw_input( 'Quantity > 25! Please confirm: ' ) if not value2.isdigit(): print( '%s is not a numeric value, ABORT!' % value2 ) return elif int(value2) != int(value): print( 'inconsistant quantities %s & %s' % (value, value2) ) return # collect the needed data to print the label product_id = id product_ref = item.reference if label_size == 'small': # Print a SMALL label on the PRINTER_SHORTLABEL_QUEUE_NAME print_product_label( product_id, product_ref, product_ean, int(value) ) else: # Print a LARGE label on the PRINTER_LARGELABEL_QUEUE_NAME print_product_label_large( product_id, product_ref, product_ean, int(value) ) return
def print_for_product(cachedphelper, id): """ GO TO print the labels for a given ID product """ item = cachedphelper.products.product_from_id(id) if item == None: print('Oups, %i is not a valid product' % id) return # Detection de la largeur de l'étiquette dans LS:S (label size=small) params = get_product_params_dic(cachedphelper, id) label_size = 'large' if 'LS' in params: if params['LS'] == 'S': label_size = 'small' else: label_size = 'large' if len(item.ean13) > 0 and (item.ean13 != '0'): product_ean = item.ean13 print('%i : %s - %s ' % (id, item.reference, product_ean)) else: product_ean = '32321%07i' % id # prefix 3232 + product 1 + id_product product_ean = calculate_ean13( product_ean) # Add the checksum to 12 positions print('%i : %s - %s *generated*' % (id, item.reference, product_ean)) while True: print('-' * 20) print('+ : switch label size ') print('+q: quit this print | 0: quit this print ') print('') print('Label format: %s' % label_size.upper()) value = raw_input('How many label for %s: ' % item.reference) if len(value) == 0: value = '1' if value == '0': return if value == '+': # change label size label_size = 'large' if label_size == 'small' else 'small' continue if value == '+q': #user abord return if not value.isdigit(): print('%s is not a numeric value' % value) return if int(value) > 25: value2 = raw_input('Quantity > 25! Please confirm: ') if not value2.isdigit(): print('%s is not a numeric value, ABORT!' % value2) return elif int(value2) != int(value): print('inconsistant quantities %s & %s' % (value, value2)) return # collect the needed data to print the label product_id = id product_ref = item.reference if label_size == 'small': # Print a SMALL label on the PRINTER_SHORTLABEL_QUEUE_NAME print_product_label(product_id, product_ref, product_ean, int(value)) else: # Print a LARGE label on the PRINTER_LARGELABEL_QUEUE_NAME print_product_label_large(product_id, product_ref, product_ean, int(value)) return