summaryrefslogtreecommitdiff
path: root/proj.py
blob: 3b611607f7cc5fbd59ddc671c26404a2a5bfeb0e (plain)
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
#!/usr/bin/env python3

from pysdcp import Projector
from time import sleep
import sys

PROJ_IP_ADDRESS="10.45.0.100"

args_len = len(sys.argv)

first_part = ""
is_second_part = False

if args_len == 1:
    exit()

pj = Projector(PROJ_IP_ADDRESS)

for i in range(1, args_len):
    if is_second_part == False:
        if sys.argv[i] == "power":
            is_second_part = True
        elif sys.argv[i] == "mute":
            is_second_part = True
        elif sys.argv[i] == "sleep":
            is_second_part = True
        else:
            print("Command not understood.")
            exit()
        first_part = sys.argv[i]
    else:
        is_second_part = False
        if first_part == "sleep":
            try:
                s = float(sys.argv[i])
            except ValueError:
                print(f"Value {sys.argv[i]} doesn't look like a number!")
                continue
            sleep(s)
        elif first_part == "power":
            if sys.argv[i] == "on":
                pj.set_power(True)
            elif sys.argv[i] == "off":
                pj.set_power(False)
            else:
                print("Command not understood.")
        elif first_part == "mute":
            if sys.argv[i] == "on":
                pj.set_power(True)
            elif sys.argv[i] == "off":
                pj.set_power(False)
            else:
                print("Command not understood.")