Пример #1
0
def discover_devices():
	# Create an Array of 5 devices
	devices = (hdhomerun_discover_device * 5)()

	# Search for devices and put them in the array
	num_devices = libhdhomerun.hdhomerun_discover_find_devices_custom( 
			ctypes.c_long(0), # Filter IP Address (0 ==> no filter) 
			ctypes.c_long(0x00000001), # Filter Device Type (None)
			ctypes.c_long(0xFFFFFFFF), # Filter Device ID (None)
			devices , # Search result Array
			ctypes.c_int(5)) # Max Num of results Allowed
		
	if num_devices <= 0:
		print "No devices Found"
		return None

	print "Number of Devices:",num_devices

	# Prepare the Message
	output = []
	for i in range(num_devices):
		d = {}
		d["ip"] = hex(devices[i].ip_addr) # TODO Convert to IP string
		d["id"] = hex(devices[i].device_id)
		output.append(d)

	# Set devices to command center
	req = {
		"source":"device_manager",
		"message":"OK",
		"devices":output
		}
	libcc.send_recv(output)

	return output
Пример #2
0
def loop_forever():
    while (1):
        # Create an Empty Database object
        db = {
            "source": "scanner",
            "movies": [],
            "tv": [],
            "music": [],
            "pictures": []
        }

        # Scan the Movie Folder
        scan_movies(db["movies"])

        # Scan the TV Folder
        scan_tv(db["tv"])

        # Scan the Music Folder
        scan_music(db["music"])

        # Scan the Picutre Folder
        scan_pictures(db["pictures"])

        # Send database to the command cetner
        ret = libcc.send_recv(db)
        if ret["message"] == "OK":
            # if succesful, Wait 10 minutes before the next scan
            time.sleep(60 * 10)
        else:
            # If it doesnt work out, sleep for 10 seconds
            time.sleep(10)

    return -1
Пример #3
0
def loop_forever():
	while(1):
		# Create an Empty Database object
		db = {
			"source":"scanner",
			"movies":[],
			"tv":[],
			"music":[],
			"pictures":[]
			}

		# Scan the Movie Folder
		scan_movies(db["movies"])

		# Scan the TV Folder
		scan_tv(db["tv"])

		# Scan the Music Folder
		scan_music(db["music"])

		# Scan the Picutre Folder
		scan_pictures(db["pictures"])

		# Send database to the command cetner
		ret = libcc.send_recv(db)
		if ret["message"] == "OK":
			# if succesful, Wait 10 minutes before the next scan
			time.sleep(60*10)
		else:
			# If it doesnt work out, sleep for 10 seconds
			time.sleep(10)
		

	return -1
Пример #4
0
def loop_forever():
    while (1):
        # Create a message to send to the Command Center
        msg = {}
        msg["source"] = "discoverer"
        msg["devices"] = dial.discover.discover_devices()

        # Send message to devices
        resp = libcc.send_recv(msg)

        if resp["message"] == "OK":
            # If everything went well, sleep for an hour
            time.sleep(60 * 60)
        else:
            # If there was an error, try again in 10
            time.sleep(10)
Пример #5
0
def loop_forever():
	while(1):
		# Create a message to send to the Command Center
		msg = {}
		msg["source"] = "discoverer"
		msg["devices"]= dial.discover.discover_devices()

		# Send message to devices
		resp = libcc.send_recv(msg)

		if resp["message"] == "OK":
			# If everything went well, sleep for an hour
			time.sleep(60*60)
		else:
			# If there was an error, try again in 10
			time.sleep(10)
Пример #6
0
def cc_communicate(req):
	# Add the source to the request object
	req["source"] = "cli"
	
	resp = libcc.send_recv(req)
	return resp
Пример #7
0
def cc_communicate(req):
    # Add the source to the request object
    req["source"] = "cli"

    resp = libcc.send_recv(req)
    return resp