4.3.1. StandaloneTools package

Submodules

StandaloneTools.GenerateSecretKey module

GenerateSecretKey.py - program to generate a secret key.

StandaloneTools.LoadLocationData module

LoadLocationData.py - Load location data into Row/Bin/Tier and Location tables.

Although the Constraints table has the min/max or list values this program needs, the values are hard coded here because the records in the Constraints table are about to go away.

The philosophy used here is that there are certain essential rows, bins, and tiers that make up the components of warehouse locations. This program will add those rows, bins, tiers and locations to the database. This program doesn’t care if the descriptions for these records have changed, but requires that records with specific keys must be present in the database. Once the database has been pre-loaded, the users are free to make changes as desired.

StandaloneTools.LoadLocationData.BIN_MAX = 9

Maximum bin number

StandaloneTools.LoadLocationData.BIN_MIN = 1

Minimum bin number

StandaloneTools.LoadLocationData.ECHO_SQL_TO_LOG = True

Indicator of if the SQL statements should be copied to the log

class StandaloneTools.LoadLocationData.LoadLocationDataClass[source]

Bases: object

LoadLocationDataClass - Load location data into location tables.

class LocBin(**kwargs)[source]

Bases: sqlalchemy.ext.automap.Base

Location Bin table definition

class LocRow(**kwargs)[source]

Bases: sqlalchemy.ext.automap.Base

Location Row table definition

class LocTier(**kwargs)[source]

Bases: sqlalchemy.ext.automap.Base

Location Tier table definition

class Location(**kwargs)[source]

Bases: sqlalchemy.ext.automap.Base

Location table definition

connect(user: str, password: str, db: str, host: str = 'localhost', port: int = 5432) → <module ‘sqlalchemy.engine’ from ‘/home/docs/checkouts/readthedocs.org/user_builds/food-pantry-inventory/envs/latest/lib/python3.7/site-packages/sqlalchemy/engine/__init__.py’>[source]

Establish a connection to the desired PostgreSQL database.

Parameters
  • user

  • password

  • db

  • host

  • port

Returns

load_bin_table(session: sessionmaker(class_=’Session’, bind=None, autoflush=True, autocommit=False, expire_on_commit=True))[source]

Load the bin table with values from min to max.

Returns

load_location_table(session: sessionmaker(class_=’Session’, bind=None, autoflush=True, autocommit=False, expire_on_commit=True))[source]

Construct location records from the row/bin/tier records.

The location code consists of the row code, bin code, and tier code jammed together into a six character id.

Returns

load_row_table(session: sessionmaker(class_=’Session’, bind=None, autoflush=True, autocommit=False, expire_on_commit=True))[source]

Load the row table with values from min to max.

Session

Returns

load_tier_table(session: sessionmaker(class_=’Session’, bind=None, autoflush=True, autocommit=False, expire_on_commit=True))[source]

Load the tier table with values from the list.

Returns

run_load_loc_data()[source]

Top method for running Load location data into tables.

Returns

class StandaloneTools.LoadLocationData.Main[source]

Bases: object

Main class to start things rolling.

run_load_loc_data()[source]

Prepare to run Load location data into tables.

Returns

static start_logging(work_dir: pathlib.Path, debug_name: str)[source]

Establish the logging for all the other scripts.

Parameters
  • work_dir

  • debug_name

Returns

(nothing)

StandaloneTools.LoadLocationData.ROW_MAX = 4

Maximum row number

StandaloneTools.LoadLocationData.ROW_MIN = 1

Minimum row number

StandaloneTools.LoadLocationData.TIER_LIST = ['A1', 'A2', 'B1', 'B2', 'C1', 'C2']

List of valid tier names

StandaloneTools.LoadLocationData.log = None

# # # # # Constants # # # # #

StandaloneTools.LoadLocationData.session_scope(*args, **kwds)[source]

Provide a transactional scope around a series of operations.

StandaloneTools.QRCodePrinter module

Standalone tool to print QR codes.

Usage:

QRCodePrinter.py -p=<URL_prefix> -s <nnn> -c <nnn> -o <file> QRCodePrinter.py -h | –help QRCodePrinter.py –version

Options:

-p <URL_prefix>, --prefix=<URL_prefix>

The URL prefix for the box number

-s <nnn>, --start=<nnn>

Starting box number to use

-c <nnn>, --count=<nnn>

Number of QR codes to print

-o <file>, --output=<file>

Output file name

-h, --help

Show this help and quit.

-v, --version

Show the version of this program and quit.

class StandaloneTools.QRCodePrinter.LabelPosition(page_offset: dataclasses.InitVar, lower_left_offset: StandaloneTools.QRCodePrinter.Point = Point(x=0, y=0), lower_right_offset: StandaloneTools.QRCodePrinter.Point = Point(x=0, y=0), upper_left_offset: StandaloneTools.QRCodePrinter.Point = Point(x=0, y=0), upper_right_offset: StandaloneTools.QRCodePrinter.Point = Point(x=0, y=0), offset_on_page: StandaloneTools.QRCodePrinter.Point = Point(x=0, y=0), image_start: StandaloneTools.QRCodePrinter.Point = Point(x=0, y=0), title_start: StandaloneTools.QRCodePrinter.Point = Point(x=0, y=0))[source]

Bases: object

Container for measurements for one label.

All measurements are in points. x denotes horizontal measurement y denotes vertical origin is in lower left corner label is assumed to be 2 in x 2 in ( 144 pt x 144 pt)

image_start: StandaloneTools.QRCodePrinter.Point = Point(x=0, y=0)
lower_left_offset: StandaloneTools.QRCodePrinter.Point = Point(x=0, y=0)
lower_right_offset: StandaloneTools.QRCodePrinter.Point = Point(x=0, y=0)
offset_on_page: StandaloneTools.QRCodePrinter.Point = Point(x=0, y=0)
page_offset: InitVar[Point]
title_start: StandaloneTools.QRCodePrinter.Point = Point(x=0, y=0)
upper_left_offset: StandaloneTools.QRCodePrinter.Point = Point(x=0, y=0)
upper_right_offset: StandaloneTools.QRCodePrinter.Point = Point(x=0, y=0)
class StandaloneTools.QRCodePrinter.Main[source]

Bases: object

Main class to start things rolling.

run_QRCodePtr(arguments: dict)[source]

Prepare to run Run the QR code printer..

Returns

start_logging(work_dir: pathlib.Path, debug_name: str)[source]

Establish the logging for all the other scripts.

Parameters
  • work_dir

  • debug_name

Returns

(nothing)

class StandaloneTools.QRCodePrinter.Point(x: int, y: int)[source]

Bases: object

Horizontal (x) and vertical (y) coordinate.

x: int
y: int
class StandaloneTools.QRCodePrinter.QRCodePrinterClass(workdir: pathlib.Path)[source]

Bases: object

QRCodePrinterClass - Print QR Codes

compute_box_dimensions()[source]

Compute the dimensions and bounding boxes for each label on the page. :return:

connect(user, password, db, host='localhost', port=5432)[source]

Establish a connection to the desired PostgreSQL database.

Parameters
  • user

  • password

  • db

  • host

  • port

Returns

connect_to_generate_labels()[source]

Connect to the database and generate labels. :return:

draw_bounding_box(label_pos: int)[source]

Draw a bounding box around the specified label.

Parameters

label_pos – position in the labels locations list.

Returns

fill_pdf_pages()[source]

Fill one or more pages with labels.

Returns

finalize_pdf_file()[source]

All pages have been generated so flush all buffers and close.

Returns

finish_page()[source]

Finish off the prefious page before starting a new one

generate_label_pdf()[source]

Generate the pdf file with the requested labels in it. :return:

get_next_box_number() -> (<class 'str'>, <class 'int'>)[source]

Search for the next box number to go on a label.

Returns

get_next_box_url() -> (<class 'str'>, <class 'str'>)[source]

Build the URL for the next box. :return:

get_next_qr_img() -> (<class 'str'>, <class 'str'>)[source]

Build the QR image for the next box label.

Returns

a QR code image ready to print

initialize_pdf_file()[source]

Setup the pdf to receive labels.

Returns

place_label(file_name: str, label_name: str, pos: int)[source]

Place the label in the appropriate location on the page.

Parameters
  • file_name

  • label_name

  • pos

Returns

run_QRPrt(parameters: dict)[source]

Top method for running Run the QR code printer..

Parameters

parameters – dictionary of command line arguments

Returns