def error(self, info): CrawlerDao.update_by_id(self.id, self.u_id, status=Crawler_Status.Error, info=info, finished=datetime.now()) logger.error(info)
def setUp(self): self.app = get_application().test_client() self.user_id = UserDao.create('t', 't', '*****@*****.**', '1') self.c_id = [ CrawlerDao.create(self.user_id, 1, '', '', ''), CrawlerDao.create(self.user_id, 2, '', '', '') ] for i in self.c_id: CrawlerDao.update_by_id(i, self.user_id, status=1, data_count=10, total=10, finished=datetime.now()) self.app.set_cookie('localhost', 'u_id', str(self.user_id)) with self.app.session_transaction() as session: session[str(self.user_id)] = 't'
def update_count(self, count): CrawlerDao.update_by_id(self.id, self.u_id, data_count=count)
def insert_extras(self, extras): CrawlerDao.update_by_id(self.id, self.u_id, extras=extras)
def done(self): CrawlerDao.update_by_id(self.id, self.u_id, status=Crawler_Status.DONE, finished=datetime.now())