-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinitial_setup.py
63 lines (49 loc) · 1.75 KB
/
initial_setup.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from printer.models import Settings
import subprocess as sp
raspi_commands = [
'sudo apt install -y cups',
'sudo apt install -y default-jre libreoffice-core libreoffice-common libreoffice-java-common',
'sudo apt install -y --no-install-recommends libreoffice-writer libreoffice-gtk3',
'sudo usermod -aG lpadmin pi'
]
migrations_commands = [
'python manage.py makemigrations printer --skip-checks',
'python manage.py migrate --skip-checks'
]
print("\n================== printer-gui ==================")
print("Author: Ryan Haas (github.com/haasr/printer-gui)")
print("=================================================\n")
using_raspi = input("\nUsing Raspberry Pi w/ Pi OS ? (y/n) >")
if using_raspi.lower() == 'y':
print("\n------------------------------------")
print("Installing Aptitude dependencies...")
for cmd in raspi_commands:
print(f">> \033[93m {cmd}\033[00m")
resp = sp.call(cmd, shell=True)
if resp == 0:
print(f"\033[92m[ ✓ OK ]\033[00m")
else:
print(f"\033[91m[ X Failed! ]\033 ]00m")
print("\n------------------------------------")
print("Migrating the database...")
for cmd in migrations_commands:
print(f">> \033[93m {cmd}\033[00m")
resp = sp.call(cmd, shell=True)
if resp == 0:
print(f"\033[92m[ ✓ OK ]\033[00m")
else:
print(f"\033[91m[ X Failed! ]\033 ]00m")
print("\n------------------------------------")
app_title='GUI Print Server'
opt = input("App title >")
if opt != '': app_title = opt
x = Settings(
id=1,
app_title=app_title,
default_color='RGB',
default_orientation='3',
printer_profile='None found'
)
x.save()
print(f"\033[92m[ DONE ]\033[00m")
print("Type \033[93mexit()\033[00m to exit the shell")