forked from protonphoton/LJ
[fix] Many fixes to the clitools runner lib
This commit is contained in:
parent
1e43a5fc43
commit
2f54d37856
@ -10,6 +10,16 @@ import json
|
||||
from pathlib import Path
|
||||
import redis
|
||||
|
||||
|
||||
environ = {
|
||||
# "REDIS_IP" : "127.0.0.1",
|
||||
"REDIS_IP" : "192.168.2.44",
|
||||
"REDIS_PORT" : "6379",
|
||||
"REDIS_KEY" : "/pl/0/0",
|
||||
"REDIS_SCENE" : "0",
|
||||
"REDIS_LASER" : "0"
|
||||
}
|
||||
|
||||
class bcolors:
|
||||
HL = '\033[31m'
|
||||
OKBLUE = '\033[94m'
|
||||
@ -37,12 +47,12 @@ def intkey():
|
||||
except ValueError:
|
||||
print("Error.")
|
||||
|
||||
current_id=0
|
||||
current_cmd=""
|
||||
process = None
|
||||
current_filename = ""
|
||||
currentPlayList = []
|
||||
playlistsDir = Path("./playlists")
|
||||
current_id = 0
|
||||
current_cmd = ""
|
||||
process = None
|
||||
current_filename = ""
|
||||
currentPlayList = []
|
||||
playlistsDir = Path("./playlists")
|
||||
if not playlistsDir.is_dir() : playlistsDir.mkdir()
|
||||
|
||||
def ask(q):
|
||||
@ -105,10 +115,12 @@ def action_changeCommand( inc ):
|
||||
return True
|
||||
|
||||
def action_match( k ):
|
||||
global current_id, currentPlayList
|
||||
if int(k) > (len(currentPlayList) - 1):
|
||||
print( bcolors.HL + "This key does not exist" + bcolors.ENDC )
|
||||
return False
|
||||
else :
|
||||
_ok("Changed action id to {}.".format(k))
|
||||
current_id = int(k)
|
||||
|
||||
def action_runCommand():
|
||||
@ -155,7 +167,7 @@ def action_deleteCommand():
|
||||
action_listAll()
|
||||
key = int(input())
|
||||
# Exit early
|
||||
if "x" == k:
|
||||
if "x" == key:
|
||||
return(False)
|
||||
del currentPlayList[key]
|
||||
return True
|
||||
@ -163,7 +175,7 @@ def action_deleteCommand():
|
||||
|
||||
|
||||
def action_listAll():
|
||||
global currentPlayList, current_cmd
|
||||
global currentPlayList, current_cmd, current_id
|
||||
print("\n--------------------------------------")
|
||||
for i,seq in enumerate(currentPlayList):
|
||||
pre=""
|
||||
@ -232,7 +244,7 @@ def action_loadPlaylist():
|
||||
print( bcolors.HL + "This key '{}' is not valid".format(k) + bcolors.ENDC )
|
||||
return False
|
||||
|
||||
# Load file
|
||||
# @todo replace with _loadPlaylist
|
||||
playlistFile = Path("./playlists/"+file_list[k].name)
|
||||
currentPlayList = json.loads(playlistFile.read_text())
|
||||
current_playlist_name = file_list[k].name
|
||||
@ -242,7 +254,18 @@ def action_loadPlaylist():
|
||||
|
||||
|
||||
|
||||
def _loadPlaylist( filename ):
|
||||
|
||||
global currentPlayList, current_playlist_name, current_id
|
||||
try:
|
||||
playlistFile = Path(filename)
|
||||
currentPlayList = json.loads(playlistFile.read_text())
|
||||
current_playlist_name = filename
|
||||
current_id = 0
|
||||
_ok("Playlist loaded: {}\n".format(current_playlist_name))
|
||||
return True
|
||||
except Exception as e:
|
||||
_err("_loadPlaylist error when loading '{}':{}".format(filename,e))
|
||||
|
||||
|
||||
|
||||
@ -353,13 +376,4 @@ def action_quit():
|
||||
quit = inkey()
|
||||
if quit != "n":
|
||||
_kill(process)
|
||||
sys.exit(1)
|
||||
|
||||
environ = {
|
||||
# "REDIS_IP" : "127.0.0.1",
|
||||
"REDIS_IP" : "192.168.2.44",
|
||||
"REDIS_PORT" : "6379",
|
||||
"REDIS_KEY" : "/pl/0/0",
|
||||
"REDIS_SCENE" : "0",
|
||||
"REDIS_LASER" : "0"
|
||||
}
|
||||
sys.exit(1)
|
Loading…
Reference in New Issue
Block a user