**Note: this is an old version**

UiT provides a mobile print service accessible throug a web page
(powered by YSoft SAFEQ 6<sup>®</sup>). If you do not have a computer
with a UiT-image, this is the only way to access UiT-printers. To make
this less cumbersome I have made a small Python program than can be
used to print documents to UiT-printers. It has been tested on macOS
and Windows, but it should be possible to install and use on other
systems (e.g., Linux). It is implemented using my Python module
[webinteract](https://blog.pg12.org/web-page-interaction-in-python)
(available with `pip` from [PyPi](https://pypi.org/project/webinteract/)) 
and it consists of two files: The Python program `uitprint.py` and the 
web interaction actions script `uitprint.wia`.

[Python](https://www.python.org/) has to be installed on your computer
to use the program `uitprint`. It is recommended to install the
`webinteract` module, and other Python modules used by the program
(`keyring` or `onepw`), with the package installer for Python,
[`pip`](https://pip.pypa.io/):

```bash
pip install webinteract
```

The easiest way to use the Python program is to install it as the file
`uitprint` together with the wia script `uitprint.wia` somewhere where
your shell finds it (e.g., `~/bin` if you have included it in your
`PATH`). You *can* install a JSON config file `.uitprintconfig.json`
in your home directory where you can set values for *account*,
*service*, *url*, *driver* (these values can also be set by command
line arguments). A [sample](dot.uitprintconfig.json) of the config
file is found in this folder.

In the addition, you can install the macOS application `UiTPrint.app`
(distributed in the zip file `UiTPrint.zip`) in the Applications
folder on your Mac (if you are a Mac user). Update the file based on
your UiT account. `UiTPrint.app` is a simple macOS application just
calling the Python program with the `-i` argument (opens a file
selector). Be aware that to use the program in ineractive mode
(including using the `UiTPrint.app`),
[Qt](https://www.qt.io/download-qt-installer-oss) and the
[PySide6](https://wiki.qt.io/Qt_for_Python) Python module have to be
installed on your computer.

On Windows computers, I suggest to install `uitprint.py` together with
the wia script `uitprint.wia` in the folder `~/Scripts` and create the
following batch file `uitprint.bat` in the `~/bin` folder (add the
`bin` folder to `PATH` and replace the file path of `uitprint.py` with
the one matching your system):

```bat
@echo off
python "C:\Users\abc012\Scripts\uitprint.py" %*
```

It is recommended to store the credentials used by the program in a
keyring or keychain (secure storage). `uitprint` uses either the
[`keyring`](https://pypi.org/project/keyring/) module or the
[`onepw`](https://pypi.org/project/onepw/) module to implement
this.

When `keyring` is installed and used, you can use the `keyring`
console script to populate the keyring with your UiT password (replace
`abc012@uit.no` with your UiT account):

```bash
keyring set UiTprint abc012@uit.no
```

The command will prompt you for the password, and the password will be
stored in the keyring accessible for the program. The first time you
use the program, the system might ask you if the program should have
access to this entry in the keyring (keychain).

When `onepw` is installed and the `--one-password` argument is used,
the credentials are handled by 1Password, and you can use the `onepw`
console script to populate 1Password with your UiT password and
account (replace `abc012@uit.no` with your UiT account):

```bash
onepw add --title UiTprint --username abc012@uit.no
```

The command will prompt you for the password, and the password and
username will be stored in 1Password. 1Password might ask you to
authenticate when the program later access this entry.

For more information use the `-h` argument of the program. As always, the
[source code](https://www.pg12.org/dist/tools/uitprint/uitprint.py.html)
is the ultimate documentation.

All use of this software is at your own risk.

**Note**

Since version 1.22, the program has embedded the wia-script as a
backup. This means that it should work even if the `uitprint.wia` file
is not available or not found. This simplifies installation. You only
*need* to install one file. The program will still try to locate the
`uitprint.wia` file, but if not found, the embedded backup will be
used instead.

Since version 1.26, 1Password integration is supported (use the
`--one-password` argument).
