mirror of
				https://github.com/simon987/od-database.git
				synced 2025-11-04 06:56:52 +00:00 
			
		
		
		
	hotfix attempt 2
This commit is contained in:
		
							parent
							
								
									8ced4859f3
								
							
						
					
					
						commit
						0ff6ea1682
					
				
							
								
								
									
										4
									
								
								api.py
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								api.py
									
									
									
									
									
								
							@ -34,9 +34,7 @@ def setup_api(app):
 | 
				
			|||||||
                    website_id = oddb.db.get_oldest_website_id()
 | 
					                    website_id = oddb.db.get_oldest_website_id()
 | 
				
			||||||
                    website = oddb.db.get_website_by_id(website_id)
 | 
					                    website = oddb.db.get_website_by_id(website_id)
 | 
				
			||||||
                    task = Task(website_id, website.url)
 | 
					                    task = Task(website_id, website.url)
 | 
				
			||||||
                    oddb.db.put_task(task)
 | 
					                    oddb.db.put_task(task, name)
 | 
				
			||||||
 | 
					 | 
				
			||||||
                    task = oddb.db.pop_task(name, accept_ftp)
 | 
					 | 
				
			||||||
                except:
 | 
					                except:
 | 
				
			||||||
                    oddb.logger.error("Couldn't create new task")
 | 
					                    oddb.logger.error("Couldn't create new task")
 | 
				
			||||||
                    abort(404)
 | 
					                    abort(404)
 | 
				
			||||||
 | 
				
			|||||||
@ -373,15 +373,15 @@ class Database:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            conn.commit()
 | 
					            conn.commit()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def put_task(self, task: Task) -> None:
 | 
					    def put_task(self, task: Task, assigned_crawler=None) -> None:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        with sqlite3.connect(self.db_path) as conn:
 | 
					        with sqlite3.connect(self.db_path) as conn:
 | 
				
			||||||
            cursor = conn.cursor()
 | 
					            cursor = conn.cursor()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            cursor.execute("INSERT INTO Queue (website_id, url, priority, callback_type, callback_args) "
 | 
					            cursor.execute("INSERT INTO Queue (website_id, url, priority, callback_type, callback_args, assigned_crawler) "
 | 
				
			||||||
                           "VALUES (?,?,?,?,?)",
 | 
					                           "VALUES (?,?,?,?,?,?)",
 | 
				
			||||||
                           (task.website_id, task.url, task.priority,
 | 
					                           (task.website_id, task.url, task.priority,
 | 
				
			||||||
                            task.callback_type, json.dumps(task.callback_args)))
 | 
					                            task.callback_type, json.dumps(task.callback_args), assigned_crawler))
 | 
				
			||||||
            conn.commit()
 | 
					            conn.commit()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_tasks(self) -> list:
 | 
					    def get_tasks(self) -> list:
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user