def reset(): try: db = connect_to_mongo() collection = 'tops' tops = db[collection] for d in tops.find()[:]: top_id = d['_id'] tops.update({"_id": top_id}, {"$set": {"colors": "_not_available_"}}) finally: disconnect_from_mongo(db)
def reset(): try: db = connect_to_mongo() collection = 'tops' tops = db[collection] for d in tops.find()[:]: top_id = d['_id'] tops.update({"_id": top_id}, {"$set": { "colors": "_not_available_" }}) finally: disconnect_from_mongo(db)
def close_spider(self, spider): disconnect_from_mongo(self.db)
try: item_color = ItemColor(str(top_id), img_url) item_color.detect_colors() # update field for id with color tops.update({"_id": top_id}, {"$set": {"colors": item_color.rgb_colors}}) except Exception, e: print '[ERROR] %s' % (e) continue print "Count of items with no colors: %s" % tops.find({"colors": "_not_available_"}).count() print "Processing complete" finally: disconnect_from_mongo(db) def reset(): try: db = connect_to_mongo() collection = 'tops' tops = db[collection] for d in tops.find()[:]: top_id = d['_id'] tops.update({"_id": top_id}, {"$set": {"colors": "_not_available_"}}) finally: disconnect_from_mongo(db)
print "%s - img_url = %s" % (e, img_url) logging.warning("%s - img_url = %s" % (e, img_url)) if (item_color.palette is not None): print "%s: %s" % (img_url, str(item_color.palette)) logging.warning("%s: %s" % (img_url, str(item_color.palette))) continue print "Count of items with no colors: %s" % tops.find({ "colors": "_not_available_" }).count() print "Processing complete" finally: disconnect_from_mongo(db) def reset(): try: db = connect_to_mongo() collection = 'tops' tops = db[collection] for d in tops.find()[:]: top_id = d['_id'] tops.update({"_id": top_id}, {"$set": { "colors": "_not_available_" }})