Пример #1
0
def _consume_action_queue(request, device, x_items):
	was_updated = False
	while device.actions_queue:
		action = device.actions_queue.pop()
		# logging.debug("checking action %s", action)
		if list(qxml.filter(x_items, 'item', action = action[0], type = action[1])):
			# logging.debug("action %s already found in %s, skipping", action, x_items)
			continue
		if action == 'SET_SCFG':
			_add_item(x_items, 'SET', 'SCFG', key = 'KSP.set.scfg', priority = 100, body = _servers_config(request, device))
			was_updated = True
		elif action == 'UPLOAD_SNAP':
			_add_item(x_items, 'UPLOAD', 'SNAP', key = 'KSP.upload.snap', priority = 1000, url = config.server_url(request) + 'FionaCDEServiceEngine/UploadSnapshot')
			was_updated = True
		# elif action == 'GET_NAMS':
		# 	_add_item(x_items, 'GET', 'NAMS', key = 'NameChange' if device.is_kindle() else 'AliasChange')
		# 	was_updated = True
		elif action == 'UPLOAD_SCFG':
			_add_item(x_items, 'UPLOAD', 'SCFG', key = 'KSP.upload.scfg', priority = 50, url = config.server_url(request) + 'ksp/scfg')
			was_updated = True
		elif type(action) == tuple and action[0] == 'ADD_COLLECTION':
			pass
		else:
			logging.warn("unknown action %s", action)
	return was_updated
Пример #2
0
def _process_xml(doc, device, reason):
	x_response = qxml.get_child(doc, 'response')
	x_items = qxml.get_child(x_response, 'items')
	if not x_items:
		return False

	was_updated = False

	# rewrite urls
	for x_item in qxml.list_children(x_items, 'item'):
		was_updated |= _filter_item(x_items, x_item)

	if features.download_updated_books:
		for book in calibre.books().values():
			if book.needs_update_on(device) and book.cde_content_type in ('EBOK', ): # PDOC updates are not supported ATM
				logging.warn("book %s updated in library, telling device %s to download it again", book, device)
				# <item action="GET" is_incremental="false" key="asin" priority="600" sequence="0" type="EBOK">title</item>
				_add_item(x_items, 'GET', book.cde_content_type, key = book.asin, text = book.title, forced = True) # book.title)
				was_updated = True

	while device.actions_queue:
		action = device.actions_queue.pop()
		# logging.debug("checking action %s", action)
		if list(qxml.filter(x_items, 'item', action = action[0], type = action[1])):
			# logging.debug("action %s already found in %s, skipping", action, x_items)
			continue
		if action == ('SET', 'SCFG'):
			_add_item(x_items, 'SET', 'SCFG', text = _servers_config(device), key = 'KSP.set.scfg', priority = 100)
			was_updated = True
		elif action == ('UPLOAD', 'SNAP'):
			_add_item(x_items, 'UPLOAD', 'SNAP', key = 'KSP.upload.snap', priority = 1000, url = config.server_url + 'FionaCDEServiceEngine/UploadSnapshot')
			was_updated = True
		# elif action == ('GET', 'NAMS'):
		# 	_add_item(x_items, 'GET', 'NAMS', key = 'NameChange' if device.is_kindle() else 'AliasChange')
		# 	was_updated = True
		elif action == ('UPLOAD', 'SCFG'):
			_add_item(x_items, 'UPLOAD', 'SCFG', key = 'KSP.upload.scfg', priority = 50, url = config.server_url + 'ksp/scfg')
			was_updated = True
		else:
			logging.warn("unknown action %s", action)

	if was_updated:
		x_total_count = qxml.get_child(x_response, 'total_count')
		qxml.set_text(x_total_count, len(x_items.childNodes))

	return was_updated
Пример #3
0
def _consume_action_queue(request, device, x_items):
    was_updated = False
    while device.actions_queue:
        action = device.actions_queue.pop()
        # logging.debug("checking action %s", action)
        if list(qxml.filter(x_items, 'item', action=action[0],
                            type=action[1])):
            # logging.debug("action %s already found in %s, skipping", action, x_items)
            continue
        if action == 'SET_SCFG':
            _add_item(x_items,
                      'SET',
                      'SCFG',
                      key='KSP.set.scfg',
                      priority=100,
                      body=_servers_config(request, device))
            was_updated = True
        elif action == 'UPLOAD_SNAP':
            _add_item(x_items,
                      'UPLOAD',
                      'SNAP',
                      key='KSP.upload.snap',
                      priority=1000,
                      url=config.server_url(request) +
                      'FionaCDEServiceEngine/UploadSnapshot')
            was_updated = True
        # elif action == 'GET_NAMS':
        # 	_add_item(x_items, 'GET', 'NAMS', key = 'NameChange' if device.is_kindle() else 'AliasChange')
        # 	was_updated = True
        elif action == 'UPLOAD_SCFG':
            _add_item(x_items,
                      'UPLOAD',
                      'SCFG',
                      key='KSP.upload.scfg',
                      priority=50,
                      url=config.server_url(request) + 'ksp/scfg')
            was_updated = True
        elif type(action) == tuple and action[0] == 'ADD_COLLECTION':
            pass
        else:
            logging.warn("unknown action %s", action)
    return was_updated