def try_enqueue(url): url = os.path.join(url, "") url = od_util.get_top_directory(url) if not od_util.is_valid_url(url): return "<strong>Error:</strong> Invalid url. Make sure to include the appropriate scheme.", "warning" website = db.get_website_by_url(url) if website: return "Website already exists", "danger" website = db.website_exists(url) if website: return "A parent directory of this url has already been posted", "danger" if db.is_blacklisted(url): return "<strong>Error:</strong> " \ "Sorry, this website has been blacklisted. If you think " \ "this is an error, please <a href='/contribute'>contact me</a>.", "danger" if not od_util.is_od(url): return "<strong>Error:</strong>" \ "The anti-spam algorithm determined that the submitted url is not " \ "an open directory or the server is not responding. If you think " \ "this is an error, please <a href='/contribute'>contact me</a>.", "danger" website_id = db.insert_website(Website(url, str(request.remote_addr + "_" + request.headers.get("X-Forwarded-For", "")), request.user_agent)) task = Task(website_id, url, priority=1) taskManager.queue_task(task) return "The website has been added to the queue", "success"
def try_enqueue(url): url = os.path.join(url, "") url = od_util.get_top_directory(url) if not od_util.is_valid_url(url): return "<strong>Error:</strong> Invalid url. Make sure to include the appropriate scheme." website = db.get_website_by_url(url) if website: return "Website already exists" website = db.website_exists(url) if website: return "A parent directory of this url has already been posted" if db.is_blacklisted(url): return "<strong>Error:</strong> " \ "Sorry, this website has been blacklisted. If you think " \ "this is an error, please <a href='/contribute'>contact me</a>." if not od_util.is_od(url): return "<strong>Error:</strong>" \ "The anti-spam algorithm determined that the submitted url is not " \ "an open directory or the server is not responding. If you think " \ "this is an error, please <a href='/contribute'>contact me</a>." website_id = db.insert_website(Website(url, "localhost", "mass_import.py")) task = Task(website_id, url, priority=2) taskManager.queue_task(task) return "The website has been added to the queue"