forked from broncotc/python-paperang
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathlittleprinter.py
More file actions
executable file
·31 lines (27 loc) · 921 Bytes
/
littleprinter.py
File metadata and controls
executable file
·31 lines (27 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
import time
import hardware
import image_data
import tempfile
import os
from watchgod import watch
import config
from pathlib import Path
class Paperang_Printer:
def __init__(self):
if hasattr(config, "macaddress"):
self.printer_hardware = hardware.Paperang(config.macaddress)
else:
self.printer_hardware = hardware.Paperang()
def print_sirius_image(self, path):
if self.printer_hardware.connected:
self.printer_hardware.sendImageToBt(image_data.sirius(path))
if __name__ == '__main__':
mmj=Paperang_Printer()
# `sirius-client` will write to this folder
tmpdir = os.path.join(tempfile.gettempdir(), 'sirius-client')
Path(tmpdir).mkdir(parents=True, exist_ok=True)
for changes in watch(tmpdir):
file = changes.pop()[1]
print("Printing " + file)
mmj.print_sirius_image(file)