def print_album(node, indent): album = Album.get_album(connection, node.album_uri) stdout.write(", " + str(album.image_count) + " images") images = album.get_images(connection) for image in images: do_indent(indent + 1) print image.filename + " - " + image.caption
def print_album(node, indent): album = Album(Album.get_album(connection, node.album)) stdout.write(", " + str(album.image_count) + " images") images = album.get_images(connection) for image in images: do_indent(indent+1) print image.filename + " - " + image.caption
#print new_node.uri + " - " + new_node.name new_node = None for thisnode in node.get_children(connection): if thisnode.url_name == "Testalbum": new_node = thisnode if new_node is None: # creating the child folder privately so people can run this test script 'safely'. new_node = node.create_child_album(connection, 'testalbum', 'Testalbum', 'Private', 'A long description for the album') print new_node.uri + " - " + new_node.name + new_node.album_uri album = Album.get_album(connection, new_node.album_uri) try: pprint( connection.upload_image('adhawkins_github_avatar.jpg', album.uri)) except exceptions.ConnectionError as e: print "ConnectionError: " + str(e) print "Deleting node after failed upload" new_node.delete_node(connection) #delete_node=Node(node.create_child_folder(connection, 'deletetest','Deletetest','Public')) #print "Name: " + delete_node.name + ", url: " + delete_node.url_name #pprint(delete_node.delete_node(connection)) #rename_node=Node(node.create_child_folder(connection, 'renametest','Renametest','Public'))
#new_node=Node(node.create_child_folder(connection, 'aaaatestnode2','aaaaatestnode2','Public')) #print new_node.uri + " - " + new_node.name new_node = None for thisnode in node.get_children(connection): if thisnode.url_name == "Testalbum": new_node=thisnode if new_node is None: # creating the child folder privately so people can run this test script 'safely'. new_node=node.create_child_album(connection, 'testalbum','Testalbum','Private', 'A long description for the album') print new_node.uri + " - " + new_node.name + new_node.album album=Album.get_album(connection, new_node.album) try: pprint(connection.upload_image('adhawkins_github_avatar.jpg', album.uri)) except exceptions.ConnectionError as e: print "ConnectionError: " + str(e) print "Deleting node after failed upload" new_node.delete_node(connection) #delete_node=Node(node.create_child_folder(connection, 'deletetest','Deletetest','Public')) #print "Name: " + delete_node.name + ", url: " + delete_node.url_name #pprint(delete_node.delete_node(connection)) #rename_node=Node(node.create_child_folder(connection, 'renametest','Renametest','Public'))
def sync_node(connection, local, remote): global root_node global root_dir print "Syncing node " + local.json["url_name"] + " with " + remote.url_name remote_children = remote.get_children(connection) if local.directory != root_dir: node_patch = {} if local.json["description"] != remote.description: node_patch["Description"] = local.json["description"] if local.json["url_name"] != remote.url_name: node_patch["UrlName"] = local.json["url_name"] if local.json["node_sort_method"] != remote.sort_method: node_patch["SortMethod"] = local.json["node_sort_method"] if local.json["node_sort_direction"] != remote.sort_direction: node_patch["SortDirection"] = local.json["node_sort_direction"] if node_patch: remote.change_node(connection, node_patch) for child in local.children: if child.items: node = find_remote_child_node(remote_children, child.json["uri"], child.json["url_name"]) if not node: print "Creating album " + child.json["url_name"] node = remote.create_child_album(connection, child.json["name"], child.json["url_name"], 'Public', child.json["description"]) child.json["uri"] = node.uri album = Album.get_album(connection, node.album_uri) sync_album(connection, child, album) else: node = find_remote_child_node(remote_children, child.json["uri"], child.json["url_name"]) if not node: print "Creating node " + child.json["url_name"] node = remote.create_child_folder(connection, child.json["name"], child.json["url_name"], 'Public') child.json["uri"] = node.uri sync_node(connection, child, node) print "Checking to delete remote children in " + local.directory for child in remote_children: if not find_local_child_node(local.children, child.uri, child.url_name): if child.uri == root_node.uri: import sys print "*** About to delete root node" sys.exit(1) child.delete_node(connection) local.save_json()