Skip to content

Adventures with Tanish

Evan Ugarte edited this page Jul 9, 2023 · 3 revisions

Add argparse

create a file called test.py with the below contents:

import argparse

parser.add_argument("--sce", help="here is some help text for what this argument does")

args = parser.parse_args()

print(args)
print(args.sce)
  1. what does python test.py -h do?
  2. what does python test.py --sce hello do?

add new argument

add an argument called --printer-names. it will take aprinter names that are separated by commas like

--printer-names=printer1,printer2

write code that parses args.printer_names, and returns a list of strings like ["printer1", "printer2"]

Add logging

todo add evan snippets here, also --verbose arg

Run a mock printing command

todo evan add explanation beyond os.system(sleep 1)

Delete files after printing

after the above command finishes and is successful, delete the file

Passing all args from the website to the print server

todo evan to explan beyond we send raw, also need 2 sided, copies and print range

Add Prometheus Metrics

Follow the below tutorial, make a separate api.

https://www.youtube.com/watch?v=x3bSuGH8R28&pp=ygUScHJvbWV0aGV1cyBmYXN0YXBp

After doing so discuss with Evan on what metrics we care about

Talk to the printer via SNMP

Before doing so, install OpenVPN on your computer:

brew install --cask openvpn

Evan will make a file so you can connect to the SCE network to query the printer's metrics like:

  • ink level
  • pages printed

Create PrintJob Class

first we will just print a page as soon as we get it and be dumb

after the above works, we will push each request

todo evan will explain this

Finalize logic for printing

  1. recieve page
  2. save page locally to disk
  3. ensure snmp connection can be established to printers
  4. query printer for ink level
  5. send pages to printer with highest ink level
  6. delete file after print successful
  7. if we couldnt connect to either printer, dont do anything