new: Push to one or many collections

pull/7/head
Hannah Ward 2017-03-31 10:24:32 +01:00
parent 033c37a446
commit b38073a880
No known key found for this signature in database
GPG Key ID: 6F3BAD60DE190290
1 changed files with 8 additions and 1 deletions

View File

@ -50,6 +50,10 @@ localClient = create_client(host = localConfig["host"],
localClient.username = localConfig["auth"]["username"] localClient.username = localConfig["auth"]["username"]
localClient.password = localConfig["auth"]["password"] localClient.password = localConfig["auth"]["password"]
localInbox = "{}://{}:{}{}".format("https" if localConfig["use_https"] else "http",
localConfig["host"], localConfig["port"],
localConfig["inbox_path"])
# Check that we're all good and authenticated # Check that we're all good and authenticated
try: try:
list(localClient.discover_services()) list(localClient.discover_services())
@ -75,6 +79,9 @@ for server in config:
for collection in server["collections"]: for collection in server["collections"]:
for content_block in cli.poll(collection): for content_block in cli.poll(collection):
log.debug("Pushing block %s", content_block) log.debug("Pushing block %s", content_block)
localClient.push(content_block.content.decode("utf-8"), content_binding=content_block.binding) localClient.push(content_block.content.decode("utf-8"),
collection_names=localConfig["collections"],
content_binding=content_block.binding,
uri=localInbox)
log.info("Finished!") log.info("Finished!")