diff options
author | ZachIR <zachir@librem.one> | 2023-01-10 13:05:59 -0600 |
---|---|---|
committer | ZachIR <zachir@librem.one> | 2023-01-10 13:05:59 -0600 |
commit | 0a67e22480a3be86c38ca6a63e9dd64e65d01c13 (patch) | |
tree | 0257b8ceccca30d968715e80fc924205843357d6 | |
parent | 328738278b556d013b110769531e3a45347c52ec (diff) |
update proj.py script
-rwxr-xr-x | proj.py | 49 |
1 files changed, 31 insertions, 18 deletions
@@ -8,7 +8,8 @@ PROJ_IP_ADDRESS="10.45.0.100" args_len = len(sys.argv) -get_sleep = False +first_part = "" +is_second_part = False if args_len == 1: exit() @@ -16,25 +17,37 @@ if args_len == 1: pj = Projector(PROJ_IP_ADDRESS) for i in range(1, args_len): - if get_sleep == False: - if sys.argv[i] == "power_on": - pj.set_power(True) - elif sys.argv[i] == "power_off": - pj.set_power(False) - elif sys.argv[i] == "mute_on": - pj.set_mute(True) - elif sys.argv[i] == "mute_off": - pj.set_mute(False) + 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": - get_sleep = True + is_second_part = True else: print("Command not understood.") exit() + first_part = sys.argv[i] else: - get_sleep = False - try: - s = float(sys.argv[i]) - except ValueError: - print(f"Value {sys.argv[i]} doesn't look like a number!") - continue - sleep(s) + 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.") |