Repository navigation
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Mechanical py2 -> py3 changes plus the behaviour that 2to3 does not catch:
* textutil.split_lines(): python 3 str.splitlines() also splits on \f, \v,
\x1c-\x1e and \x85, which shifts every fixed row the parsers address.
Keep the python 2 semantics (\n, \r, \r\n only).
* Regexes over print data use re.ASCII so 8-bit characters are still blanked
as they were for python 2 str, keeping /raw output pure ASCII.
* lpdserver: bytes protocol, payload and control file decoded as latin-1
(one byte, one column). Gather terminator fragments instead of popping the
first one. Fix the unknown-message-type log line.
* httpserver: bytes through the request/response path; handler results may be
str, bytes or a file. Drop cgi/mimetools. POST bodies parsed with parse_qs and
the response is now actually sent.
* Pickles: load python 2 job pickles as latin-1; user entered pickles
(address book, mail results) are utf-8 and converted on load. Write protocol 2
so python 2.7 can still read them during cutover.
* mailer: result_count is an int (comparing int > str crashed at startup).
* printing: sys.platform is 'linux', not 'linux2'; decode lpstat output.
* settings.py: PRINTERFACE_HOME overrides ~/printerface, shared config loading.
* Templates: drop .decode('utf-8'), iteritems.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Runs against a scratch directory; stationary tests no longer write to ~/printerface. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
wsgiref, MarkupSafe 0.19 and reportlab 2.7 cannot be installed on python 3. Replace Travis (python 2.7) with a GitHub Actions test workflow on 3.11. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
compare_corpus.py re-renders stored jobs and diffs PDF text against the PDFs made by the previous release; replay_corpus.py sends stored payloads through the LPD server as a real client would, including the Windows end-of-file-by-close variant. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Compares /recent, /job and /raw over the jobs both instances hold, ignoring the unreliable 'ts' field and JSON key order (python 2 dict order was arbitrary). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The script relied on main.py's shebang and a PATH that found the python 2.7 build first. Default to ~/.venv311/bin/python (a venv of /opt/python311/bin/python3.11), overridable with PRINTERFACE_PYTHON, and refuse to start if it is missing. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
filter() is lazy on python 3 so the page rendered a mako error (as a 200). The integration test fetched the page but only checked for a non-empty body; it now fails on mako error pages and checks one <pre> per printed page. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The row used j['ts'], the loop variable leaked from the filter loop above, so every result carried the same timestamp. Use p['ts']. Adds a test that two jobs get their own timestamps. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The email text offered for an invoice, purchase order or statement now comes from a Mako template (~/printerface/templates/<type>.mako, falling back to the copy in templates/ in the source) that can use the document's fields, the recipients' names and the company details. Settings > Email Templates edits them with a preview against a real document, chosen by document number or account. Mako can run python and the web interface has no authentication, so the editor only accepts a safe subset (field lookups, for/if over documents, comments) and refuses anything else, including in previews. Other document types keep the single default text. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The editor already lists the available fields; the comments were just noise for users editing a template. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The single email text for documents without their own template is now the 'default' template, edited in Settings > Email Templates alongside the others; the old Default Email Text page is removed. It can only use email and job (there are no document fields for those documents). The legacy text from email.pickle is saved to ~/printerface/templates/default.mako the first time this runs, once only. Every job now has a template, so the compose form no longer has a separate path for other documents. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ticked
${email.name} and ${email.address} depend on the recipients, so the form now asks /email_body (read only)
for the text for the ticked contacts and updates the textarea. Text the user has edited is kept, with a
notice offering to replace it, and answers that arrive out of order are ignored.
Also escape contact names and addresses where they are shown and used as checkbox values.
The script is tested with node (skipped where node is absent) and the endpoint and page wiring in
test_integration.py.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…the body
The compose form's Subject box is now filled from the template (and re-rendered, with the text, when contacts
are ticked or unticked; a field the user has edited is kept). The shipped templates start with a subject line,
for example 'Invoice ${doc.ourref} from ${company.name}'. The editor previews the subject separately and says
when the first line renders empty. Migrating the old single email text gives it the shipped default's subject.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The default template now has company.name, company.email and company.website alongside email and job (it still has no doc or docs). The editor lists them for the Default tab. The tests that pinned the exact wording of the shipped templates now check the facts they must state, so that changing the wording of a shipped template doesn't break the suite. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The line no longer says whether the template is customised or what saving will write; the Revert button still only appears for a customised template. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The history goes back years (about 41,000 emails in production's) and rendering all of it makes a page of several MB. The page now shows the newest 100 and says how many there are in total; the history itself is untouched. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A sent item's attachment path names the job and document it was made from (job-YYYYMMDD-HHMMSS-<key>.pdf), so every existing record can be linked without changing the data. Sent Items gets a Document column that links to the job page when the job is still loaded and just names it otherwise. The job page lists the emails sent from it, newest first. /pdf for a job that isn't loaded (a stale link, or after a restart) now says so, with the name escaped, instead of failing with a 500. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The Document column is now the first column and its whole text, '<job> / <key>', is the link. The table is condensed with an 11px font to save horizontal space. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ocument number When an account has several invoices in one print run (about 8% of accounts) 'doc' is only the last, so the email named one invoice and one amount while the PDF held them all. Templates now also have 'all': all.numbers (operations' subject style, '336806/7': the first number in full, then each other from the first digit that differs from the first), all.list, all.total and all.tot_* (summed exactly), all.count, all.many and all.s. It is not available to the default template. The invoice template uses doc_num, as operations do in subjects, not our ref, and reads 'New Invoice 336807' or 'New Invoices 336806/7' with each invoice and the total when there are several. Checked against the real sent history: the generated subject equals what operations typed for 166 of 167 single invoices and 14 of 17 with several; the rest are their own variations in style. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…type in the default subject
default.mako: subject 'Document ${job.doctype} attached', 'To <name>,' and a 'Kind regards' signature.
statement.mako: 'To <name>,'.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ever repeats them Sending an email was a GET carrying the subject and text in the URL, so refreshing the page after sending (to see it under 'Sent from this job') sent it again. The same was true of printing a document (a plain link) and of adding or removing a contact in the address book (GET forms). * httpserver: a handler can return Redirect(location); the server answers 303 See Other. * /pdf: sending is a POST; success redirects back to the job page with a note, a refused send re-renders the form with what was typed and who was ticked. * /print: POST from a hidden form (the Print menu submits it), then back to the job page. GET shows a message. * /settings/email: adding and removing a contact are POSTs that redirect to the list. * /settings/templates: Save and Revert redirect to the editor (a refused save still re-renders with its errors). * A GET carrying the old parameters no longer does anything. * The send button disables itself on submit so a double click cannot queue the email twice. Read-only handlers (recent, job, raw, debug, plaintext, pdf_file, printers, sent, email_body) stay GET. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
plain.html carried a modal with an email form (method=get, action=send) holding hard-coded sample values
('blah blah', 'Name', 'docf'). Nothing opened it and no handler read it. The plain text page keeps its text,
Debug Info and Document Pages buttons.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
CI was failing: delivery notes are auto-printed, lpr does not exist on the GitHub runner or in the python:3.11-slim image, and the FileNotFoundError escaped saveJob before the job was added to the in-memory list, so the job silently vanished (the Docker build runs the same tests and failed the same way). * saveJob: a failure in autoPrint is logged and the job is still registered. It is already saved to disk, and this is a real fault outside CI too: any lpr failure hid the job from the web interface until a restart. * tests: main.printFile is mocked for the integration tests, so they cannot print (on a machine with lpr and a printer called HP_TONY, the default auto_printer, they would have). New tests check that delivery notes are auto-printed and that a printing failure does not lose the job. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
One lpstat -t (C locale, 5s timeout, cached 10s) is parsed into printers and waiting jobs, with device URI credentials masked. The page says which document types are auto-printed and on which queue, gives a plain-English verdict (scheduler down, queue missing, disabled or not accepting, jobs waiting over an hour) and lists the waiting jobs with stale ones highlighted. Read-only; tests never run the machine's lpstat. The print menu on the job page now lists the same CUPS queues. getPrinters() used to return a made-up 'default' on anything but linux, which lpr rejects; it is empty if CUPS can't be reached. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DKcyxWnp9B7ZMfow73wHmP
…document lp reports the queue-and-number a job gets in CUPS, which is the name lpstat knows it by. printFile now runs lp with a timeout, records job, key, printer and request id (or the error) in printer.pickle, a side file like mailer.pickle, and raises if CUPS refused the job, so a failed print is no longer reported as sent. The history keeps the newest result_count records and is flushed from the main loop only when changed. The job page lists what was printed from it, as it does for sent emails. Auto-print carries on with the remaining documents if one fails. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DKcyxWnp9B7ZMfow73wHmP
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DKcyxWnp9B7ZMfow73wHmP
…s does Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DKcyxWnp9B7ZMfow73wHmP
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DKcyxWnp9B7ZMfow73wHmP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.