Added list_programs
list_programs is a route that can be used to list all runnable programs on the controller. How convenient.
This commit is contained in:
parent
260fd121f9
commit
2ca28cba4f
1 changed files with 24 additions and 4 deletions
|
@ -16,6 +16,7 @@ IS_WALLABY = Utils.is_wallaby()
|
||||||
PATH = "/home/root/Documents/KISS/bin/" if IS_WALLABY else (sys.argv[1] if len(sys.argv) > 1 else None)
|
PATH = "/home/root/Documents/KISS/bin/" if IS_WALLABY else (sys.argv[1] if len(sys.argv) > 1 else None)
|
||||||
|
|
||||||
LIB_WALLABY = "/usr/lib/libwallaby.so"
|
LIB_WALLABY = "/usr/lib/libwallaby.so"
|
||||||
|
WALLABY_PROGRAMS = "/root/Documents/KISS/bin/"
|
||||||
|
|
||||||
if not PATH:
|
if not PATH:
|
||||||
Logging.error("No path specified. (Necessary on simulated Wallaby controllers.)")
|
Logging.error("No path specified. (Necessary on simulated Wallaby controllers.)")
|
||||||
|
@ -133,6 +134,25 @@ class SensorReadout:
|
||||||
class Identify(Pipe):
|
class Identify(Pipe):
|
||||||
def run(self, data, peer, handler):
|
def run(self, data, peer, handler):
|
||||||
Utils.play_sound(config.identify_sound)
|
Utils.play_sound(config.identify_sound)
|
||||||
|
if handler.debug:
|
||||||
|
Logging.success("I was identified!")
|
||||||
|
|
||||||
|
|
||||||
|
class ListPrograms(Pipe):
|
||||||
|
def run(self, data, peer, handler):
|
||||||
|
programs = []
|
||||||
|
if IS_WALLABY:
|
||||||
|
if os.path.isdir(WALLABY_PROGRAMS):
|
||||||
|
for program in os.listdir(WALLABY_PROGRAMS):
|
||||||
|
if "botball_user_program" in WALLABY_PROGRAMS + program:
|
||||||
|
programs.append(programm)
|
||||||
|
else:
|
||||||
|
Logging.error("Harrogate folder structure does not exist. "
|
||||||
|
"You broke something, mate.")
|
||||||
|
else:
|
||||||
|
for program in os.listdir("/bin"):
|
||||||
|
programs.append(program)
|
||||||
|
handler.pipe(programs, handler.reverse_routes[self], peer)
|
||||||
|
|
||||||
|
|
||||||
class Sensor(Pipe):
|
class Sensor(Pipe):
|
||||||
|
@ -235,7 +255,7 @@ class Hostname(Pipe):
|
||||||
def run(self, data, peer, handler):
|
def run(self, data, peer, handler):
|
||||||
if type(data) is dict:
|
if type(data) is dict:
|
||||||
if "set" in data:
|
if "set" in data:
|
||||||
set_hostname(str(data["set"]))
|
Utils.set_hostname(str(data["set"]))
|
||||||
|
|
||||||
|
|
||||||
class Processes(Pipe):
|
class Processes(Pipe):
|
||||||
|
@ -273,7 +293,7 @@ try:
|
||||||
# setup has to be called before the connection is established
|
# setup has to be called before the connection is established
|
||||||
ws.setup({"subscribe" : Subscribe(), "hostname" : Hostname(),
|
ws.setup({"subscribe" : Subscribe(), "hostname" : Hostname(),
|
||||||
"processes" : Processes(), "sensor" : Sensor(),
|
"processes" : Processes(), "sensor" : Sensor(),
|
||||||
"identify" : Identify()},
|
"identify" : Identify(), "list_programs" : ListPrograms()},
|
||||||
debug=config.debug)
|
debug=config.debug)
|
||||||
ws.connect()
|
ws.connect()
|
||||||
ws.run_forever()
|
ws.run_forever()
|
||||||
|
|
Reference in a new issue