def _getUserSubCategories(conn, smugmug, lock, ids): for categoryid in ids: result = smugmug.subcategories_get(CategoryID=categoryid) subcategories = result["SubCategories"] for subcategory in subcategories: lock.acquire() db.addUserSubCategory(conn,subcategory["id"],subcategory["NiceName"],subcategory["Name"], categoryid) lock.release()
def createMissingSubCategories(configobj, smugmug, lock): """ Will create any missing SubCategories on SmugMug that have been found locally, but not on SmugMug. """ myLogger.debug('createMissingSubCategories - parent process: %s process id: %s', os.getppid(), os.getpid()) conn = db.getConn(configobj) sync = datetime.now() subcategories = db.missingSmugMugSubCategories(conn) for subcategory in subcategories: result = smugmug.subcategories_create(Name=subcategory[0], CategoryID=subcategory[2]) id = result["SubCategory"]["id"] myLogger.debug("SubCategory created: '%s' and id '%s'", subcategory[0], id) lock.acquire() db.addUserSubCategory(conn,id,"",subcategory[0], subcategory[2]) db.insertSubCategoryLog(conn, id, subcategory[0],subcategory[1], sync) lock.release()