Beispiel #1
0
def setPhrase(args):
  global phrase
  p = args
  print("%s setting phrase to %s"%(name,p['phrase']))
  phraseMutex.acquire()
  phrase=p
  phraseMutex.release()
  return host.jsonStatus("ok")
Beispiel #2
0
def clearCache(args):
  path = getImageCache()
  for f in os.listdir(path):
    try:
      r = path+"/%s"%f
      print("rm: %s"%r)
      shutil.rmtree(path)
    except OSError as e:
      rval = "Error: %s - %s." % (e.filename, e.strerror)
  return host.jsonStatus("ok")
Beispiel #3
0
def setImageDir(args):
  rval = "ok"
  id = args[0]
  global imageDir
  path = getCacheDir(id)
  idLock.acquire()
  imageDir = path
  idLock.release()
  print("SetImageDir to %s: %s"%(imageDir,rval))
  return host.jsonStatus(rval)
Beispiel #4
0
def rmCacheDir(args):
  rval = "ok"
  id = args[0]
  path = getCacheDir(id)
  try:
    shutil.rmtree(path)
  except OSError as e:
    rval = "Error: %s - %s." % (e.filename, e.strerror)
  print("rmCacheDir: path %s %s"%(path,rval))
  return host.jsonStatus(rval)
Beispiel #5
0
def addImage(args):
  global currentId
  id = args['id']
  imgData = args['imgData']
  if currentId is None or currentId != id:
    currentId = id
  print("addImage currentId: %d"%currentId)
  path = getCacheDir(currentId)
  for d in imgData:
    file = path + "/%s"%d['name']
    print("---name: %s"%file)
    with open(file, 'wb') as f:
      f.write(base64.b64decode(d['img']))

  return host.jsonStatus("ok");
Beispiel #6
0
def handleCmd(cmd):
  if debug: print("handling cmd:"+str(cmd['cmd']));
  if cmd['cmd'] not in cmds.keys():
    return host.jsonStatus("%s: not implemented"%cmd['cmd']);
  status = cmds[cmd['cmd']](cmd['args'])
  return status
Beispiel #7
0
def doReboot(cmd):
  return host.jsonStatus("reboot");
Beispiel #8
0
def doPoweroff(cmd):
  return host.jsonStatus("poweroff");
Beispiel #9
0
def doUpgrade(cmd):
  upgrade.upgrade()
  print("returned from upgrade")
  return host.jsonStatus("reboot")
Beispiel #10
0
def setSearchType(t):
    global searchType
    searchType = t[0]
    archive.init = False
    return host.jsonStatus("ok")