at, ats = connection.get_access_token(verifier) print "Token: " + at print "Secret: " + ats token = at secret = ats connection.authorise_connection(token, secret) try: user = User.get_authorized_user(connection) print "User: "******" (" + user.name + ")" node = Node.get_node(connection,user.node) #print_node(node, 0) #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')
at, ats = connection.get_access_token(verifier) print "Token: " + at print "Secret: " + ats token = at secret = ats connection.authorise_connection(token, secret) try: user = User.get_authorized_user(connection) print "User: "******" (" + user.name + ")" node = Node.get_node(connection, user.node) #print_node(node, 0) #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',
def main(): global root_node global root_dir parser = ArgumentParser() parser.add_argument("site", help="the site to upload to") parser.add_argument("path", help="the path containing local photos") parser.add_argument("-r", "--reauth", help="force reauthorisation", action="store_true") parser.add_argument("-k", "--api-key", help="smugmug API key") parser.add_argument("-s", "--api-secret", help="smugmug API secret") args = parser.parse_args() root_dir = args.path config = Config() site_config = {} if ("api-key" not in config.json and not args.api_key) or \ ("api-secret" not in config.json and not args.api_secret): print "API key and secret must be in either config or on command line" parser.print_help() exit(-1) if args.site in config.json: site_config = config.json[args.site] save_config = False if args.api_key: config.json["api-key"] = args.api_key save_config = True if args.api_secret: config.json["api-secret"] = args.api_secret save_config = True if "exclusions" not in site_config: save_config = True site_config["exclusions"] = [] connection = Connection(config.json["api-key"], config.json["api-secret"], user_agent="pysmugmugsync/" + get_distribution('pysmugmugsync').version) if args.reauth or "token" not in site_config or "secret" not in site_config: auth_url = connection.get_auth_url(access="Full", permissions="Modify") print "Visit the following URL and retrieve a verification code:%s%s" % ( linesep, auth_url) stdout.write('Enter the six-digit code: ') stdout.flush() verifier = stdin.readline().strip() at, ats = connection.get_access_token(verifier) site_config["token"] = at site_config["secret"] = ats save_config = True if save_config: config.json[args.site] = site_config config.write() connection.authorise_connection(site_config["token"], site_config["secret"]) user = User.get_authorized_user(connection) print "User: "******" (" + user.name + ")" root_node = Node.get_node(connection, user.node) root = SmugMugLocalAlbum(exclusions=site_config["exclusions"], directory=args.path) sync_node(connection, root, root_node)