Esempio n. 1
0
def processHotplugData(self, v):
	print "hotplug:", v
	action = v.get("ACTION")
	device = v.get("DEVPATH")
	physdevpath = v.get("PHYSDEVPATH")
	media_state = v.get("X_E2_MEDIA_STATUS")

	dev = device.split('/')[-1]

	if action is not None and action == "add":
		error, blacklisted, removable, is_cdrom, partitions, medium_found = harddiskmanager.addHotplugPartition(dev, physdevpath)
		if bdpoll and removable or is_cdrom:
			bdpoll.addDevice(dev, is_cdrom, medium_found)
	elif action is not None and action == "remove":
		if bdpoll:
			bdpoll.removeDevice(dev)
		harddiskmanager.removeHotplugPartition(dev)
	elif media_state is not None:
		if media_state == '1':
			harddiskmanager.removeHotplugPartition(dev)
			harddiskmanager.addHotplugPartition(dev, physdevpath)
		elif media_state == '0':
			harddiskmanager.removeHotplugPartition(dev)

	for callback in hotplugNotifier:
		try:
			callback(dev, action or media_state)
		except AttributeError:
			hotplugNotifier.remove(callback)
def processHotplugData(self, v):
    print "hotplug:", v
    action = v.get("ACTION")
    device = v.get("DEVPATH")
    physdevpath = v.get("PHYSDEVPATH")
    if physdevpath == "-":
        physdevpath = None
    media_state = v.get("X_E2_MEDIA_STATUS")

    dev = device.split('/')[-1]

    if action == "add":
        error, blacklisted, removable, is_cdrom, partitions, medium_found = harddiskmanager.addHotplugPartition(
            dev, physdevpath)
    elif action == "remove":
        harddiskmanager.removeHotplugPartition(dev)
    elif media_state is not None:
        if media_state == '1':
            harddiskmanager.removeHotplugPartition(dev)
            harddiskmanager.addHotplugPartition(dev, physdevpath)
        elif media_state == '0':
            harddiskmanager.removeHotplugPartition(dev)

    for callback in hotplugNotifier:
        try:
            callback(dev, action or media_state)
        except AttributeError:
            hotplugNotifier.remove(callback)
Esempio n. 3
0
	def connectionLost(self, reason):
		data = self.received.split('\0')[:-1]

		v = {}

		for x in data:
			i = x.find('=')
			var, val = x[:i], x[i+1:]
			v[var] = val

		print "hotplug:", v

		action = v.get("ACTION")
		device = v.get("DEVPATH")
		physdevpath = v.get("PHYSDEVPATH")
		media_state = v.get("X_E2_MEDIA_STATUS")

		dev = device.split('/')[-1]

		if action is not None and action == "add":
			harddiskmanager.addHotplugPartition(dev, physdevpath)
		elif action is not None and action == "remove":
			harddiskmanager.removeHotplugPartition(dev)
		elif media_state is not None:
			if media_state == '1':
				harddiskmanager.removeHotplugPartition(dev)
				harddiskmanager.addHotplugPartition(dev, physdevpath)
			elif media_state == '0':
				harddiskmanager.removeHotplugPartition(dev)
		
		for callback in hotplugNotifier:
			try:
				callback(dev, action or media_state)
			except AttributeError:
				hotplugNotifier.remove(callback)
Esempio n. 4
0
				def gotThreadMsg(self, msg):
					msg = self.messages.pop()
					if msg[0] == BDPoll.MSG_MEDIUM_REMOVED:
						print "MSG_MEDIUM_REMOVED"
						harddiskmanager.removeHotplugPartition(msg[1])
					elif msg[0] == BDPoll.MSG_MEDIUM_INSERTED:
						print "MSG_MEDIUM_INSERTED"
						harddiskmanager.addHotplugPartition(msg[1])
					elif msg[0] == BDPoll.MSG_POLL_FINISHED:
						self.checkTimer.start(BDPoll.CHECK_INTERVAL, True)
Esempio n. 5
0
				def gotThreadMsg(self, msg):
					msg = self.messages.pop()
					if msg[0] == BDPoll.MSG_MEDIUM_REMOVED:
						print "MSG_MEDIUM_REMOVED"
						harddiskmanager.removeHotplugPartition(msg[1])
					elif msg[0] == BDPoll.MSG_MEDIUM_INSERTED:
						print "MSG_MEDIUM_INSERTED"
						harddiskmanager.addHotplugPartition(msg[1])
					elif msg[0] == BDPoll.MSG_POLL_FINISHED:
						self.checkTimer.start(BDPoll.CHECK_INTERVAL, True)
Esempio n. 6
0
def processHotplugData(self, v):
    print "[Hotplug.plugin.py]:", v
    action = v.get("ACTION")
    device = v.get("DEVPATH")
    physdevpath = v.get("PHYSDEVPATH")
    if physdevpath == "-":
        physdevpath = None
    media_state = v.get("X_E2_MEDIA_STATUS")
    global audiocd

    dev = device.split('/')[-1]

    if action == "add":
        error, blacklisted, removable, is_cdrom, partitions, medium_found = harddiskmanager.addHotplugPartition(
            dev, physdevpath)
    elif action == "remove":
        harddiskmanager.removeHotplugPartition(dev)
    elif action == "audiocdadd":
        audiocd = True
        media_state = "audiocd"
        error, blacklisted, removable, is_cdrom, partitions, medium_found = harddiskmanager.addHotplugAudiocd(
            dev, physdevpath)
        print "[Hotplug.plugin.py] AUDIO CD ADD"
    elif action == "audiocdremove":
        audiocd = False
        file = []
        # Removing the invalid playlist.e2pls If its still the audio cd's list
        # Default setting is to save last playlist on closing Mediaplayer.
        # If audio cd is removed after Mediaplayer was closed,
        # the playlist remains in if no other media was played.
        if os.path.isfile('/etc/enigma2/playlist.e2pls'):
            with open('/etc/enigma2/playlist.e2pls', 'r') as f:
                file = f.readline().strip()
        if file:
            if '.cda' in file:
                try:
                    os.remove('/etc/enigma2/playlist.e2pls')
                except OSError:
                    pass
        harddiskmanager.removeHotplugPartition(dev)
        print "[Hotplug.plugin.py] REMOVING AUDIOCD"
    elif media_state is not None:
        if media_state == '1':
            harddiskmanager.removeHotplugPartition(dev)
            harddiskmanager.addHotplugPartition(dev, physdevpath)
        elif media_state == '0':
            harddiskmanager.removeHotplugPartition(dev)

    for callback in hotplugNotifier:
        try:
            callback(dev, action or media_state)
        except AttributeError:
            hotplugNotifier.remove(callback)
Esempio n. 7
0
def processHotplugData(self, eventData):
    print("[Hotplug] DEBUG:", eventData)
    action = eventData.get("ACTION")
    device = eventData.get("DEVPATH")
    physDevPath = eventData.get("PHYSDEVPATH")
    mediaState = eventData.get("X_E2_MEDIA_STATUS")
    global audioCd

    dev = device.split("/")[-1]
    print(
        "[Hotplug] DEBUG: device = %s action = %s mediaState = %s physDevPath = %s dev = %s"
        % (device, action, mediaState, physDevPath, dev))
    if action == "add":
        error, blacklisted, removable, is_cdrom, partitions, medium_found = harddiskmanager.addHotplugPartition(
            dev, physDevPath)
    elif action == "remove":
        harddiskmanager.removeHotplugPartition(dev)
    elif action == "audiocdadd":
        audioCd = True
        mediaState = "audiocd"
        error, blacklisted, removable, is_cdrom, partitions, medium_found = harddiskmanager.addHotplugPartition(
            dev, physDevPath)
        print("[Hotplug] Adding Audio CD.")
    elif action == "audiocdremove":
        audioCd = False
        # Removing the invalid playlist.e2pls if its still the audio cd's list.
        # Default setting is to save last playlist on closing Mediaplayer. If
        # audio cd is removed after Mediaplayer was closed, the playlist
        # remains in if no other media was played.
        try:
            with open("/etc/enigma2/playlist.e2pls", "r") as fd:
                file = f.readline().strip()
        except (IOError, OSError):
            file = None
        if file and ".cda" in file:
            try:
                os.remove("/etc/enigma2/playlist.e2pls")
            except (IOError, OSError):
                pass
        harddiskmanager.removeHotplugPartition(dev)
        print("[Hotplug] Removing Audio CD.")
    elif mediaState is not None:
        if mediaState == "1":
            harddiskmanager.removeHotplugPartition(dev)
            harddiskmanager.addHotplugPartition(dev, physDevPath)
        elif mediaState == "0":
            harddiskmanager.removeHotplugPartition(dev)
    for callback in hotplugNotifier:
        try:
            callback(dev, action or mediaState)
        except AttributeError:
            hotplugNotifier.remove(callback)
Esempio n. 8
0
def processHotplugData(self, v):
	print "[Hotplug.plugin.py]:", v
	action = v.get("ACTION")
	device = v.get("DEVPATH")
	physdevpath = v.get("PHYSDEVPATH")
	if physdevpath == "-":
		physdevpath = None
	media_state = v.get("X_E2_MEDIA_STATUS")
	global audiocd

	dev = device.split('/')[-1]

	if action == "add":
		error, blacklisted, removable, is_cdrom, partitions, medium_found = harddiskmanager.addHotplugPartition(dev, physdevpath)
	elif action == "remove":
		harddiskmanager.removeHotplugPartition(dev)
	elif action == "audiocdadd":
		audiocd = True
		media_state = "audiocd"
		error, blacklisted, removable, is_cdrom, partitions, medium_found = harddiskmanager.addHotplugAudiocd(dev, physdevpath)
		print "[Hotplug.plugin.py] AUDIO CD ADD"
	elif action == "audiocdremove":
		audiocd = False
		file = []
		# Removing the invalid playlist.e2pls If its still the audio cd's list
		# Default setting is to save last playlist on closing Mediaplayer.
		# If audio cd is removed after Mediaplayer was closed,
        # the playlist remains in if no other media was played.
		if os.path.isfile('/etc/enigma2/playlist.e2pls'):
			with open('/etc/enigma2/playlist.e2pls', 'r') as f:
				file = f.readline().strip()
		if file:
			if '.cda' in file:
				try:
					os.remove('/etc/enigma2/playlist.e2pls')
				except OSError:
					pass
		harddiskmanager.removeHotplugPartition(dev)
		print "[Hotplug.plugin.py] REMOVING AUDIOCD"
	elif media_state is not None:
		if media_state == '1':
			harddiskmanager.removeHotplugPartition(dev)
			harddiskmanager.addHotplugPartition(dev, physdevpath)
		elif media_state == '0':
			harddiskmanager.removeHotplugPartition(dev)

	for callback in hotplugNotifier:
		try:
			callback(dev, action or media_state)
		except AttributeError:
			hotplugNotifier.remove(callback)