Example #1
0
 def handle(self, *args, **options):
     user = DimUser.objects.get_or_create(username="******")[0]
     sim_group = SimulationGroup(submitted_by=user)
     sim_group.save()
     print "Simulation group %s has been created successfully" % sim_group.id
     with open(os.path.join("ts_om","management", "commands", "default.xml")) as fp:
         xml = fp.read()
     simulation1 = add_simulation(sim_group, xml)
     print "Simulation %s has been created successfully" % simulation1.id
     simulation2 = add_simulation(sim_group, xml)
     print "Simulation %s has been created successfully" % simulation2.id
     dispatcher.submit(sim_group)
     print "Simulation group has been submitted successfully. Waiting for the results."
     seconds = 0
     print sim_status.SCRIPT_DONE
     while simulation1.status != sim_status.SCRIPT_DONE and \
           simulation1.status != sim_status.SCRIPT_ERROR and \
           simulation1.status != sim_status.OUTPUT_ERROR:
         time.sleep(1)
         seconds += 1
         if divmod(seconds, 60):
             print "Waiting %s seconds, status %s/%s" % (seconds, simulation1.status, simulation2.status)
         # reload model from the database
         simulation1 = Simulation.objects.get(id = simulation1.id)
         simulation2 = Simulation.objects.get(id = simulation2.id)
     print "Simulation result: %s/%s" % (simulation1.status, simulation2.status)
Example #2
0
 def test_with_3_simulations(self):
     """
     Test the addition_simulation function by adding 3 simulations to a group.
     """
     xml_contents = ["<?xml version='1.0'>", "", EMPTY_SCENARIO]  # Just XML header  # Empty file,
     expected_count = 0
     for xml in xml_contents:
         simulation = add_simulation(self.sim_group, xml, version="30")
         self.check_simulation(simulation, xml)
         expected_count += 1
         self.assertEqual(self.sim_group.simulations.count(), expected_count)
Example #3
0
 def test_with_empty_xml(self):
     """
     Test the addition_simulation function when the XML contents is an empty string.
     """
     simulation = add_simulation(self.sim_group, "", version="30")
     self.check_simulation(simulation, "")