Exemple #1
0
    def get_isight_stix(self, start_time=None, end_time=None):
        #登録情報を取得
        isight_adapter = isightAdapter.get()
        community = isight_adapter.community
        uploader = isight_adapter.uploader
        via = Vias.get_via_adapter_isight(uploader)
        try:
            #範囲内のリストを取得する
            l = self._get_isight_stix_report_list(start_time, end_time)
        except Exception as e:
            traceback.print_exc()
            raise e

        #last_requested更新
        isight_adapter.modify_last_requested()

        #リストの各要素をSTIXで取得してregistする
        count = 0
        for report_id in l:
            try:
                content = self._get_isight_stix_report(report_id)
                #ファイル登録
                #self._regist_isight_stix(content,community,via)
                _regist_stix(content, community, via)
                count += 1
            except Exception as e:
                #エラーが発生した場合はログを表示して処理は実行する
                traceback.print_exc()
        return count
Exemple #2
0
 def remove_job(self, job_id):
     #isightAdapterのjobsからjob削除
     isight_adapter = isightAdapter.get()
     isight_adapter.remove_job(job_id)
     #スケジューラからjob削除
     schedule_job = ScheduleJobs.objects.get(id=job_id)
     self._schedule.remove_job(schedule_job)
     #mongoのschedule_jobsからschedule_job削除
     schedule_job.remove()
Exemple #3
0
def get_isight_dict(replace_dict):
    replace_dict['isight'] = isightAdapter.get()
    # communityが削除されている場合はNoneを格納する
    try:
        if replace_dict['isight'].community is None:
            replace_dict['isight'].community = None
    except DoesNotExist:
        replace_dict['isight'].community = None
    return replace_dict
Exemple #4
0
 def resume_job(self, job_id):
     schedule_job = ScheduleJobs.objects.get(id=job_id)
     if schedule_job in isightAdapter.get().jobs:
         if schedule_job.status == ScheduleJobs.STATUS_STOP:
             pass
         else:
             print 'already working.'
             return
     else:
         raise Exception('invalid job_id')
     self._schedule.resume_job(schedule_job)
Exemple #5
0
 def pause_job(self, job_id):
     schedule_job = ScheduleJobs.objects.get(id=job_id)
     if schedule_job in isightAdapter.get().jobs:
         if schedule_job.status == ScheduleJobs.STATUS_IN_OPERATION:
             pass
         else:
             print 'not yet start.'
             return
     else:
         raise Exception('invalid job_id')
         return
     self._schedule.pause_job(schedule_job)
Exemple #6
0
 def add_job(self, schedule_job):
     #スケジューラに job 追加
     self._schedule.add_job(schedule_job, self._get_isight_stix_job)
     #job start
     self._schedule.start_job(schedule_job)
     #mongo の設定に格納する
     isight = isightAdapter.get()
     if schedule_job.job_type == ScheduleJobs.JOB_INTERVAL:
         #Interval指定の場合は_interval_jobを更新する
         isight.interval_schedule_job = schedule_job
         self._interval_job = schedule_job
     else:
         isight.jobs.append(schedule_job)
Exemple #7
0
def isight_common_render(request, info_msg=None, error_msg=None):
    try:
        replace_dict = get_common_replace_dict(request)
        # mongoからisight情報を取得
        ia = isightAdapter.get()
        replace_dict['isight'] = ia
        if info_msg is not None:
            replace_dict['interval_info_msg'] = info_msg
        if error_msg is not None:
            replace_dict['interval_error_msg'] = error_msg
        # レンダリング
        return render(request, 'isight_detail.html', replace_dict)
    except Exception:
        # エラーページ
        return error_page(request)