コード例 #1
0
ファイル: controller.py プロジェクト: temi4/ScrapyKeeper
 def post(self, project_id):
     post_data = request.form
     if post_data:
         job_instance = JobInstance()
         job_instance.spider_name = post_data['spider_name']
         job_instance.project_id = project_id
         job_instance.spider_arguments = post_data.get('spider_arguments')
         job_instance.desc = post_data.get('desc')
         job_instance.tags = post_data.get('tags')
         job_instance.run_type = post_data['run_type']
         job_instance.priority = post_data.get('priority', 0)
         if job_instance.run_type == "periodic":
             job_instance.cron_minutes = post_data.get(
                 'cron_minutes') or '0'
             job_instance.cron_hour = post_data.get('cron_hour') or '*'
             job_instance.cron_day_of_month = post_data.get(
                 'cron_day_of_month') or '*'
             job_instance.cron_day_of_week = post_data.get(
                 'cron_day_of_week') or '*'
             job_instance.cron_month = post_data.get('cron_month') or '*'
             job_instance.cron_month = post_data.get('cron_month') or '*'
             job_instance.cron_month = post_data.get('cron_month') or '*'
             job_instance.start_tasks = post_data.get('start_tasks', 1)
             job_instance.max_start_tasks = post_data.get(
                 'max_start_tasks', 1)
         db.session.add(job_instance)
         db.session.commit()
         return True
コード例 #2
0
ファイル: controller.py プロジェクト: bsekiewicz/ScrapyKeeper
 def put(self, project_id, spider_id):
     spider_instance = SpiderInstance.query.filter_by(project_id=project_id,
                                                      id=spider_id).first()
     if not spider_instance: abort(404)
     job_instance = JobInstance()
     job_instance.spider_name = spider_instance.spider_name
     job_instance.project_id = project_id
     job_instance.spider_arguments = request.form.get('spider_arguments')
     job_instance.desc = request.form.get('desc')
     job_instance.tags = request.form.get('tags')
     job_instance.run_type = JobRunType.ONETIME
     job_instance.priority = request.form.get('priority', 0)
     job_instance.enabled = -1
     db.session.add(job_instance)
     db.session.commit()
     agent.start_spider(job_instance)
     return True
コード例 #3
0
ファイル: controller.py プロジェクト: divtiply/ScrapyKeeper
 def post(self, project_id):
     post_data = request.form
     if post_data:
         job_instance = JobInstance()
         job_instance.spider_name = post_data['spider_name']
         job_instance.project_id = project_id
         job_instance.spider_arguments = post_data.get('spider_arguments')
         job_instance.desc = post_data.get('desc')
         job_instance.tags = post_data.get('tags')
         job_instance.run_type = post_data['run_type']
         job_instance.priority = post_data.get('priority', 0)
         if job_instance.run_type == "periodic":
             job_instance.cron_minutes = post_data.get('cron_minutes') or '0'
             job_instance.cron_hour = post_data.get('cron_hour') or '*'
             job_instance.cron_day_of_month = post_data.get('cron_day_of_month') or '*'
             job_instance.cron_day_of_week = post_data.get('cron_day_of_week') or '*'
             job_instance.cron_month = post_data.get('cron_month') or '*'
         db.session.add(job_instance)
         try:
             db.session.commit()
         except Exception as e:
             db.session.rollback()
             raise e
         return True