Пример #1
0
def joinCall():
    roomFile = open("/home/pi/GrammyCam/roomId", "r")
    url = roomFile.readline()
    roomFile.close()
    #subprocess.Popen("echo 'as' | cec-client RPI -s -d 1", shell = True)
    cec.set_active_source()
    global callWindow
    callWindow = subprocess.Popen(["chromium-browser", "--kiosk", url])
    joinBtn["bg"] = red
    joinBtn["activebackground"] = red
    joinBtn["text"] = "Leave\nRoom"
    joinBtn["command"] = endCall
Пример #2
0
    def do_POST(self):
        print("received request.")
        ctype, pdict = cgi.parse_header(self.headers.get('content-type'))
        
        # refuse to receive non-json content
        if ctype != 'application/json':
            self.send_response(400)
            self.end_headers()
            return
        
        # read the message and convert it into a python dictionary
        length = int(self.headers.get('content-length'))
        message = json.loads(self.rfile.read(length))

        if message.get("command") == "on":
          try:
            tv = cec.Device(cec.CECDEVICE_TV)
            tv.power_on()
            cec.set_active_source()
          except e:
            print(e)
        
        self._set_headers()
        self.wfile.write(json.dumps({"statusMsg": "Success"}).encode("utf8"))
        os.system("/sbin/reboot")
    else:
        print("Restart non necessaire")
        os.remove(UPDATE_FILE)


update()
control_mode = get_control_mode()
if control_mode == "lg-serial":
    import serial
elif control_mode == "cec":
    import cec
    # On initialise le CEC
    cec.init()
    tv = cec.Device(0)
    cec.set_active_source(1)

while 1:  # Boucle qui pool toutes les 1 min, on utilise pas cron car la connexion au CEC est longue et pas faites pour rester que quelques secondes. Elle est faite pour rester connectee.
    print
    "Start Pooling"
    # Construction du JSON de donnees monitoring
    jsonData = {}
    jsonData["temperature"] = round(getCPUtemperature(), 1)
    #jsonData["heure"] = round(time.time(), 0)
    load = os.getloadavg()
    jsonData["load"] = str(load[0]) + " " + str(load[1]) + " " + str(load[2])
    jsonData["tv_screen_on"] = False
    jsonData["ip"] = commands.getoutput(
        'hostname -I | awk \'{print $1}\'').strip()
    jsonData["hostname"] = commands.getoutput('hostname').strip()
    jsonData["fs_ro"] = commands.getoutput(
 def activate_source(self):
     cec.set_active_source()
Пример #5
0
 def power_on(self):
     cec.set_active_source()
     if self.event_id is not None:
         GLib.source_remove(self.event_id)
         self.event_id = None