Ejemplo n.º 1
0
    def create_job(self, analysis_name, input_data):
        """ Create a job for the supplied analysis and input hash
        The input_data dict is converted to a Perl string before storing
        """

        input_data['timestamp'] = time.time()
        analysis = self.get_analysis_by_name(analysis_name)
        if analysis == None:
            raise ValueError("Analysis %s not found" % analysis_name)
        s = Session()
        try:
            job = Job(input_id=dict_to_perl_string(input_data),
                      status='READY',
                      analysis_id=analysis.analysis_id)
            s.add(job)
            s.commit()
            # force load of object
            job.analysis
            job.result
            return job
        except:
            s.rollback()
            raise
        finally:
            s.close()
Ejemplo n.º 2
0
 def test_parse_simple_str(self):
     o = {'a': 'b'}
     s = dict_to_perl_string(o)
     self.assertEquals(s, """{"a" => "b"}""")
     o2 = perl_string_to_python(s)
     t = type(o2).__name__
     self.assertEquals(t, "dict")
     self.assertEquals(o2['a'], 'b')
Ejemplo n.º 3
0
 def test_parse_string_dollar(self):
     o = {'a': "$b"}
     s = dict_to_perl_string(o)
     self.assertEquals(s, """{"a" => "\\$b"}""")
     o2 = perl_string_to_python(s)
     t = type(o2).__name__
     self.assertEquals(t, "dict")
     self.assertEquals(o2['a'], '$b')
Ejemplo n.º 4
0
 def test_parse_string_quotes(self):
     o = {'a': "\"b\""}
     s = dict_to_perl_string(o)
     self.assertEquals(s, """{"a" => "\\"b\\""}""")
     o2 = perl_string_to_python(s)
     t = type(o2).__name__
     self.assertEquals(t, "dict")
     self.assertEquals(o2['a'], '"b"')
Ejemplo n.º 5
0
 def test_parse_simple_list(self):
     o = {'a': ["a", "b", "c"]}
     s = dict_to_perl_string(o)
     self.assertEquals(s, """{"a" => ["a", "b", "c"]}""")
     o2 = perl_string_to_python(s)
     t = type(o2).__name__
     self.assertEquals(t, "dict")
     self.assertEquals(type(o2['a']).__name__, "list")
Ejemplo n.º 6
0
 def test_parse_complex(self):
     o = {'a': ["a", "b", "c"], 'b': 'd', 'c': 99}
     s = dict_to_perl_string(o)
     self.assertEquals(
         s, """{"a" => ["a", "b", "c"], "b" => "d", "c" => 99}""")
     o2 = perl_string_to_python(s)
     t = type(o2).__name__
     self.assertEquals(t, "dict")
     self.assertEquals(type(o2['a']).__name__, "list")
     self.assertEquals(o2['b'], 'd')
     self.assertEquals(o2['c'], 99)
Ejemplo n.º 7
0
 def test_parse_none(self):
     o = {'a': None}
     s = dict_to_perl_string(o)
     self.assertEquals(s, """{}""")