mirror of
https://github.com/NaitLee/Cat-Printer.git
synced 2025-05-15 23:00:15 -07:00
scripts for seting up an environment; add MX10
This commit is contained in:
parent
a7dee14c96
commit
2ff61f7b8d
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,6 +1,10 @@
|
|||||||
# python stuffs
|
# python stuffs
|
||||||
__pycache__
|
__pycache__
|
||||||
venv
|
venv
|
||||||
|
.venv
|
||||||
|
wvenv
|
||||||
|
_install.bat
|
||||||
|
server.bat
|
||||||
dist
|
dist
|
||||||
# Compatibility version of script, for old-old webView,
|
# Compatibility version of script, for old-old webView,
|
||||||
# generated by typescript tsc
|
# generated by typescript tsc
|
||||||
|
42
README.md
42
README.md
@ -8,7 +8,7 @@ English | [Deutsch](./readme.i18n/README.de-DE.md) | [中文(简体字)](./r
|
|||||||
|
|
||||||
## Models
|
## Models
|
||||||
|
|
||||||
Known to support: `GB01, GB02, GB03, GT01, YT01, MX05, MX06, MX08`
|
Known to support: `GB01, GB02, GB03, GT01, YT01, MX05, MX06, MX08, MX10`
|
||||||
|
|
||||||
You can test other models with the Web UI, in `Settings -> Test Unknown Device`
|
You can test other models with the Web UI, in `Settings -> Test Unknown Device`
|
||||||
It may work!
|
It may work!
|
||||||
@ -51,6 +51,8 @@ It may work!
|
|||||||
- and Fun!
|
- and Fun!
|
||||||
- Do whatever you like!
|
- Do whatever you like!
|
||||||
|
|
||||||
|
***Didn’t find your feature? Or can’t set it up? Try the simple Web-app, [kitty-printer](https://print.unseen-site.fun/).***
|
||||||
|
|
||||||
## Get Started
|
## Get Started
|
||||||
|
|
||||||
### Android
|
### Android
|
||||||
@ -60,23 +62,36 @@ Get the newest apk release and install, then well done!
|
|||||||
It may ask for background location permission, you can deny it safely.
|
It may ask for background location permission, you can deny it safely.
|
||||||
(Foreground) Location permission is required for scanning Bluetooth devices in newer Android system.
|
(Foreground) Location permission is required for scanning Bluetooth devices in newer Android system.
|
||||||
|
|
||||||
Recommend to set scan time to 1 second.
|
It is recommended to set scan time to 1 second.
|
||||||
|
|
||||||
|
The 3rd-party F-Droid repository [IzzyOnDroid](https://android.izzysoft.de/repo) is known to include Cat-Printer.
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
Get the newest release archive with “windows” in the file name,
|
1. Download [source code](https://github.com/NaitLee/Cat-Printer/archive/refs/heads/main.zip) of this repository and install newest version of [Python](https://www.python.org/).
|
||||||
extract to somewhere and run `start.bat`
|
2. Extract the source code archive, run `install.bat`, wait for it to complete
|
||||||
|
3. After that, you will get `server.bat` for opening the Web interface. Run it and enjoy
|
||||||
|
|
||||||
|
<!-- Build system broken -->
|
||||||
|
<!-- Get the newest release archive with “windows” in the file name,
|
||||||
|
extract to somewhere and run `start.bat` -->
|
||||||
|
|
||||||
Windows typically needs longer scan time. Defaults to 4 seconds, try to find your case.
|
Windows typically needs longer scan time. Defaults to 4 seconds, try to find your case.
|
||||||
|
|
||||||
|
For those who know Python development — see `requirements.txt` to find your way, it’s very simple.
|
||||||
|
|
||||||
### GNU/Linux
|
### GNU/Linux
|
||||||
|
|
||||||
You can get the “pure” release, extract it, fire up a terminal and run:
|
Get source code and run `./install.sh` to set the environment up.
|
||||||
```bash
|
|
||||||
python3 server.py
|
After that, you can always use Cat-Printer inside the given virtual environment:
|
||||||
|
|
||||||
|
```
|
||||||
|
(venv) $ python3 server.py
|
||||||
```
|
```
|
||||||
|
|
||||||
It is recommended to set the scan time to 2 seconds.
|
It is recommended to set the scan time to 2 seconds.
|
||||||
|
|
||||||
On Arch Linux based distros you may install `bluez` first, as it may not be installed by default
|
On Arch Linux based distros you may install `bluez` first, as it may not be installed by default
|
||||||
```bash
|
```bash
|
||||||
sudo pacman -S bluez bluez-utils
|
sudo pacman -S bluez bluez-utils
|
||||||
@ -85,7 +100,11 @@ sudo pacman -S bluez bluez-utils
|
|||||||
<details>
|
<details>
|
||||||
<summary>Further steps</summary>
|
<summary>Further steps</summary>
|
||||||
|
|
||||||
You may want to use the command line interface for hackiness...
|
You may want to use the command line interface for hackiness:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ python printer.py --help
|
||||||
|
```
|
||||||
|
|
||||||
You may or may not need to install ImageMagick and Ghostscript, depending on your distro.
|
You may or may not need to install ImageMagick and Ghostscript, depending on your distro.
|
||||||
|
|
||||||
@ -112,7 +131,7 @@ then install `pyobjc` and `bleak` via `pip` in terminal:
|
|||||||
pip3 install pyobjc bleak
|
pip3 install pyobjc bleak
|
||||||
```
|
```
|
||||||
|
|
||||||
After that, fetch & use a “bare” release:
|
After that, get the source code and run:
|
||||||
```bash
|
```bash
|
||||||
python3 server.py
|
python3 server.py
|
||||||
```
|
```
|
||||||
@ -133,9 +152,10 @@ Please use Issue or Discussion if there’s something in your mind!
|
|||||||
|
|
||||||
Of course Pull Requests are welcome if you can handle them!
|
Of course Pull Requests are welcome if you can handle them!
|
||||||
|
|
||||||
## License
|
## Licensefdroidhowtomarkets
|
||||||
|
|
||||||
Copyright © 2021-2023 NaitLee Soft. Some rights reserved.
|
|
||||||
|
Copyright © 2021-2024 NaitLee Soft. Some rights reserved.
|
||||||
|
|
||||||
```
|
```
|
||||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
16
install.bat
Normal file
16
install.bat
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
@echo off
|
||||||
|
set venv_path=wvenv
|
||||||
|
set inst_next=_install.bat
|
||||||
|
set server_bat=server.bat
|
||||||
|
if not exist %venv_path% (set venv_init=1)
|
||||||
|
if defined venv_init (python -m venv %venv_path%)
|
||||||
|
type .\wvenv\Scripts\activate.bat > %inst_next%
|
||||||
|
if defined venv_init (echo pip install -r requirements.txt >> %inst_next%)
|
||||||
|
set venv_init=
|
||||||
|
echo echo Testing environment >> %inst_next%
|
||||||
|
python -c "print('python -c \x22with open(1, \x27wb\x27) as f: f.write(b\x27P4\\n384 0\\n\x27)\x22 | python printer.py -f MX06 -')" >> %inst_next%
|
||||||
|
type .\wvenv\Scripts\activate.bat > %server_bat%
|
||||||
|
echo python server.py >> %server_bat%
|
||||||
|
echo Run server.bat to start Cat-Printer
|
||||||
|
:: cmd bails out just after activation in batch
|
||||||
|
%inst_next%
|
15
install.sh
Executable file
15
install.sh
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
venv_path=".venv"
|
||||||
|
if [ -d $venv_path ]; then
|
||||||
|
venv_init=false
|
||||||
|
else
|
||||||
|
venv_init=true
|
||||||
|
fi
|
||||||
|
$venv_init && python3 -m venv $venv_path
|
||||||
|
source $venv_path/bin/activate
|
||||||
|
$venv_init && pip3 install -r requirements.txt
|
||||||
|
echo "Testing environment"
|
||||||
|
python3 printer.py -f MX06 - <<EOF
|
||||||
|
P4
|
||||||
|
384 0
|
||||||
|
EOF
|
@ -751,6 +751,7 @@ def _main():
|
|||||||
global Printer
|
global Printer
|
||||||
Printer = printer
|
Printer = printer
|
||||||
return
|
return
|
||||||
|
if not args.fake:
|
||||||
if len(devices) == 0:
|
if len(devices) == 0:
|
||||||
error(i18n('no-available-devices-found'), exception=PrinterError)
|
error(i18n('no-available-devices-found'), exception=PrinterError)
|
||||||
if len(devices) == 1 or getattr(args, '0th'):
|
if len(devices) == 1 or getattr(args, '0th'):
|
||||||
|
@ -19,13 +19,14 @@ class Model():
|
|||||||
Models = {}
|
Models = {}
|
||||||
|
|
||||||
# all known supported models
|
# all known supported models
|
||||||
for name in '_ZZ00 GB01 GB02 GB03 GT01 MX05 MX06 MX08 MX09 YT01'.split(' '):
|
for name in '_ZZ00 GB01 GB02 GB03 GT01 MX05 MX06 MX08 MX09 MX10 YT01'.split(' '):
|
||||||
Models[name] = Model()
|
Models[name] = Model()
|
||||||
|
|
||||||
# that can receive compressed data
|
# that can receive compressed data
|
||||||
for name in 'GB03'.split(' '):
|
for name in 'GB03'.split(' '):
|
||||||
Models[name].is_new_kind = True
|
Models[name].is_new_kind = True
|
||||||
|
|
||||||
# that have problem giving feed command
|
# feed message isn't handled corrently in the codebase, and these models have problems with it
|
||||||
for name in 'MX05 MX06 MX08 MX09'.split(' '):
|
# TODO fix that piece of code
|
||||||
|
for name in 'MX05 MX06 MX08 MX09 MX10'.split(' '):
|
||||||
Models[name].problem_feeding = True
|
Models[name].problem_feeding = True
|
||||||
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
bleak
|
Loading…
x
Reference in New Issue
Block a user