Commits

yml ...@gmail.com  committed 107c939

Fix some quirks while writing the tutorial

  • Participants
  • Parent commits 90914db

Comments (0)

Files changed (2)

File src/worker/__init__.py

         file_path = os.path.join(self.kitchen_path, file)
         self.output, self.error = self._execute_task_from_fabfile(file_path, self.task)  # We should collect this output
         if self.error:
+            self.success = False
+        else:
             self.success = True
-        else:
-            self.success = False
             
     def post_result(self):
         values = {
-            "name":'test',
-            "task": 'my_task',
+            "name": self.name,
+            "task": self.task,
             'revision': '',
             'executed':'on',
             'environment':'',
             sys.stdout = output
             sys.stderr = error
             # execute the task
-            task()
-            sys.stdout = sys.__stdout__
-            sys.stderr = sys.__stderr__
+            try:
+                task()
+            except SystemExit, e:
+                logging.error("%s %s" %(e.__class__(), str(e)))
+            finally:
+                sys.stdout = sys.__stdout__
+                sys.stderr = sys.__stderr__
             return (output.getvalue(), error.getvalue())
         else:
             raise WorkerError("No task %s in fabfile %s" %
-                                            (task, fabfile_path))
-    
+                                            (task, fabfile_path))    

File src/worker/tests/__init__.py

         
     def test_execute_task_from_fabfile(self):
         output, error = Worker._execute_task_from_fabfile(self.fabfile_path, self.task)
-        self.assertEqual(output, 'hello world\n')
+        self.assertEqual(output, 'hello world\n[localhost] run: ls -l\n')
         self.assertEqual(error, "")
         
     def test_execute_wrong_task_from_fabfile(self):