Beispiel #1
0
    def test_export_expands_user(self):
        # If the user specifies a path using '~' (to indicate the current
        # user's home directory), make sure the path is expanded properly.
        # See `os.path.expanduser`.
        self._create_job_profiles(self.user_name)
        self._set_up_complete_jobs()
        self._set_up_outputs()

        self.uhs_output.output_type = 'unknown'
        self.uhs_output.save()

        expanded_dir = '%s/uhs_results/some_subdir/' % os.getenv('HOME')

        with helpers.patch('openquake.export.core._export_fn_not_implemented'
                           ) as expt_patch:
            export.export(self.uhs_output.id, '~/uhs_results/some_subdir/')

            self.assertEqual(1, expt_patch.call_count)
            self.assertEqual(((self.uhs_output, expanded_dir), {}),
                             expt_patch.call_args)
    def test_export_expands_user(self):
        # If the user specifies a path using '~' (to indicate the current
        # user's home directory), make sure the path is expanded properly.
        # See `os.path.expanduser`.
        self._create_job_profiles(self.user_name)
        self._set_up_complete_jobs()
        self._set_up_outputs()

        self.uhs_output.output_type = 'unknown'
        self.uhs_output.save()

        expanded_dir = '%s/uhs_results/some_subdir/' % os.getenv('HOME')

        with helpers.patch(
            'openquake.export.core._export_fn_not_implemented') as expt_patch:
            export.export(self.uhs_output.id, '~/uhs_results/some_subdir/')

            self.assertEqual(1, expt_patch.call_count)
            self.assertEqual(((self.uhs_output, expanded_dir), {}),
                             expt_patch.call_args)
Beispiel #3
0
def do_export(output_id, target_dir):
    """Simple UI wrapper around
    :function:`openquake.export.core.export`. It prints the results in a nice
    way."""
    from django.core.exceptions import ObjectDoesNotExist
    try:
        files = export.export(output_id, target_dir)
        if len(files) > 0:
            print 'Files Exported:'
            for f in files:
                print f
    except NotImplementedError, err:
        print err.message
        print 'This feature is probably not implemented yet'
Beispiel #4
0
def do_export(output_id, target_dir):
    """Simple UI wrapper around
    :function:`openquake.export.core.export`. It prints the results in a nice
    way."""
    from django.core.exceptions import ObjectDoesNotExist

    try:
        files = export.export(output_id, target_dir)
        if len(files) > 0:
            print "Files Exported:"
            for f in files:
                print f
    except NotImplementedError, err:
        print err.message
        print "This feature is probably not implemented yet"