Ejemplo n.º 1
0
 def test(self):
     cfg = helpers.get_data_path('event_based_hazard/job.ini')
     job_id, oq = actions.job_from_file(cfg, 'test_user')
     with tempfile.NamedTemporaryFile() as temp:
         with self.assertRaises(ZeroDivisionError), mock.patch(
                 'openquake.engine.engine._do_run_calc', lambda *args: 1/0):
             engine.run_calc(job_id, oq, 'info', temp.name, exports=[])
         logged = open(temp.name).read()
         # make sure the real error has been logged
         self.assertIn('integer division or modulo by zero', logged)
Ejemplo n.º 2
0
def run_job(cfg, exports='xml,csv', hazard_calculation_id=None, **params):
    """
    Given the path to a job config file and a hazard_calculation_id
    or a output, run the job.

    :returns: a calculator object
    """
    job_id, oqparam = actions.job_from_file(
        cfg, 'openquake', 'error', [], hazard_calculation_id, **params)
    logfile = os.path.join(tempfile.gettempdir(), 'qatest.log')
    return engine.run_calc(job_id, oqparam, 'error', logfile, exports)
Ejemplo n.º 3
0
def run_job(cfg, exports='xml,csv', hazard_calculation_id=None, **params):
    """
    Given the path to a job config file and a hazard_calculation_id
    or a output, run the job.

    :returns: a calculator object
    """
    job_id, oqparam = actions.job_from_file(
        cfg, 'openquake', 'error', [], hazard_calculation_id, **params)
    logfile = os.path.join(tempfile.gettempdir(), 'qatest.log')
    return engine.run_calc(job_id, oqparam, 'error', logfile, exports)
Ejemplo n.º 4
0
 def test(self):
     cfg = helpers.get_data_path('event_based_hazard/job.ini')
     job_id, oq = actions.job_from_file(cfg, 'test_user')
     with tempfile.NamedTemporaryFile() as temp:
         with self.assertRaises(ZeroDivisionError), mock.patch(
                 'openquake.engine.engine._do_run_calc',
                 lambda *args: 1 / 0):
             engine.run_calc(job_id, oq, 'info', temp.name, exports=[])
         logged = open(temp.name).read()
         # make sure the real error has been logged
         self.assertIn('integer division or modulo by zero', logged)
Ejemplo n.º 5
0
def get_job(cfg, username, hazard_calculation_id=None):
    job_id, oq = actions.job_from_file(cfg, username, hazard_calculation_id)
    return models.OqJob.objects.get(pk=job_id)
Ejemplo n.º 6
0
def get_job(cfg, username, hazard_calculation_id=None):
    job_id, oq = actions.job_from_file(cfg, username, hazard_calculation_id)
    return models.OqJob.objects.get(pk=job_id)