aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-11-04 07:06:44 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-11-04 07:06:44 +0000
commit01c3a6940286ef2ad1e7a3cd9912e2c0ad057603 (patch)
tree4de222af70d652d33a3a7c5d14ea47212acdd39c
parent48bdff1a499e40190adef7c32ee6469540a50b6e (diff)
downloadpaludis-01c3a6940286ef2ad1e7a3cd9912e2c0ad057603.tar.gz
paludis-01c3a6940286ef2ad1e7a3cd9912e2c0ad057603.tar.xz
Include status updates whilst carrying out QA checks
-rw-r--r--paludis/qa.hh5
-rw-r--r--paludis/repositories/e/qa/extractors_TEST.cc4
-rw-r--r--paludis/repositories/e/qa/qa_controller.cc33
-rw-r--r--paludis/repositories/e/qa/qa_controller.hh1
-rw-r--r--paludis/repositories/e/qa/spec_keys_TEST.cc4
-rw-r--r--paludis/repositories/e/qa/visibility_TEST.cc4
-rw-r--r--python/qa.cc15
-rwxr-xr-xpython/qa_TEST.py3
-rwxr-xr-xpython/repository_TEST.py3
-rw-r--r--ruby/paludis_ruby.cc5
-rw-r--r--ruby/paludis_ruby.hh1
-rw-r--r--src/clients/qualudis/qualudis.cc5
12 files changed, 82 insertions, 1 deletions
diff --git a/paludis/qa.hh b/paludis/qa.hh
index 47f2937..2194939 100644
--- a/paludis/qa.hh
+++ b/paludis/qa.hh
@@ -57,6 +57,11 @@ namespace paludis
* Report a QA message.
*/
virtual void message(const QAMessage &) = 0;
+
+ /**
+ * Update status.
+ */
+ virtual void status(const std::string &) = 0;
};
}
diff --git a/paludis/repositories/e/qa/extractors_TEST.cc b/paludis/repositories/e/qa/extractors_TEST.cc
index 205b9e1..bd1622b 100644
--- a/paludis/repositories/e/qa/extractors_TEST.cc
+++ b/paludis/repositories/e/qa/extractors_TEST.cc
@@ -48,6 +48,10 @@ namespace
++count;
last_message = m.message;
}
+
+ void status(const std::string &)
+ {
+ }
};
}
diff --git a/paludis/repositories/e/qa/qa_controller.cc b/paludis/repositories/e/qa/qa_controller.cc
index 3c51d52..52de195 100644
--- a/paludis/repositories/e/qa/qa_controller.cc
+++ b/paludis/repositories/e/qa/qa_controller.cc
@@ -32,6 +32,7 @@
#include <paludis/util/action_queue.hh>
#include <paludis/qa.hh>
+#include <unistd.h>
#include <algorithm>
#include <list>
#include <set>
@@ -79,7 +80,7 @@ namespace
if (0 != stringify(i->first).compare(0, root.length(), root))
break;
- message_queue.enqueue(tr1::bind(&QAReporter::message, &base, i->second));
+ message_queue.enqueue(tr1::bind(&QAReporter::message, &base, QAMessage(i->second)));
message_buf.erase(i++);
}
}
@@ -89,6 +90,11 @@ namespace
Lock lock(mutex);
message_buf.insert(std::make_pair(msg.entry, msg));
}
+
+ void status(const std::string & s)
+ {
+ message_queue.enqueue(tr1::bind(&QAReporter::status, &base, std::string(s)));
+ }
};
}
@@ -187,6 +193,24 @@ QAController::_worker()
}
void
+QAController::_status_worker()
+{
+ while (true)
+ {
+ {
+ Lock l(_imp->pools_mutex);
+ _imp->reporter.status("Pending: " + stringify(_imp->cats_pool.size()) + " full categories, "
+ + stringify(_imp->pkgs_pool.size()) + " packages in '" + stringify(_imp->repo->name()) + "'");
+
+ if (_imp->cats_pool.empty() && _imp->pkgs_pool.empty())
+ break;
+ }
+
+ ::sleep(1);
+ }
+}
+
+void
QAController::_check_category(const CategoryNamePart c, const tr1::shared_ptr<const QualifiedPackageNameSet> qpns)
{
FSEntry c_dir(_imp->repo->layout()->category_directory(c));
@@ -223,7 +247,13 @@ QAController::_check_category(const CategoryNamePart c, const tr1::shared_ptr<co
}
if (work_item)
+ {
+#ifndef PALUDIS_ENABLE_THREADS
+ _imp->reporter.status("Pending: " + stringify(_imp->cats_pool.size()) + " full categories, "
+ + stringify(_imp->pkgs_pool.size()) + " packages in '" + stringify(_imp->repo->name()) + "'");
+#endif
work_item();
+ }
else
done = true;
}
@@ -303,6 +333,7 @@ QAController::run()
ThreadPool workers;
for (int x(0) ; x < 5 ; ++x)
workers.create_thread(tr1::bind(&QAController::_worker, this));
+ workers.create_thread(tr1::bind(&QAController::_status_worker, this));
#else
_worker();
#endif
diff --git a/paludis/repositories/e/qa/qa_controller.hh b/paludis/repositories/e/qa/qa_controller.hh
index ef0bee4..08500af 100644
--- a/paludis/repositories/e/qa/qa_controller.hh
+++ b/paludis/repositories/e/qa/qa_controller.hh
@@ -45,6 +45,7 @@ namespace paludis
void _check_id(const tr1::shared_ptr<const PackageID> &);
void _worker();
+ void _status_worker();
bool _under_base_dir(const FSEntry &) const;
bool _above_base_dir(const FSEntry &) const;
diff --git a/paludis/repositories/e/qa/spec_keys_TEST.cc b/paludis/repositories/e/qa/spec_keys_TEST.cc
index 82a14b4..371cdce 100644
--- a/paludis/repositories/e/qa/spec_keys_TEST.cc
+++ b/paludis/repositories/e/qa/spec_keys_TEST.cc
@@ -46,6 +46,10 @@ namespace
{
++count;
}
+
+ void status(const std::string &)
+ {
+ }
};
}
diff --git a/paludis/repositories/e/qa/visibility_TEST.cc b/paludis/repositories/e/qa/visibility_TEST.cc
index ac8824f..e2d8f7f 100644
--- a/paludis/repositories/e/qa/visibility_TEST.cc
+++ b/paludis/repositories/e/qa/visibility_TEST.cc
@@ -54,6 +54,10 @@ namespace
messages.append(", ");
messages.append(m.message);
}
+
+ void status(const std::string &)
+ {
+ }
};
}
diff --git a/python/qa.cc b/python/qa.cc
index 5db3b20..50303e7 100644
--- a/python/qa.cc
+++ b/python/qa.cc
@@ -41,6 +41,16 @@ struct QAReporterWrapper :
else
throw PythonMethodNotImplemented("QAReporter", "message");
}
+
+ void status(const std::string & msg)
+ {
+ Lock l(get_mutex());
+
+ if (bp::override f = get_override("status"))
+ f(msg);
+ else
+ throw PythonMethodNotImplemented("QAReporter", "status");
+ }
};
void expose_qa()
@@ -90,5 +100,10 @@ void expose_qa()
"message(QAMessage)\n"
"NEED_DOC"
)
+ .def("status", bp::pure_virtual(&QAReporter::status),
+ "status(str)\n"
+ "NEED_DOC"
+ )
;
}
+
diff --git a/python/qa_TEST.py b/python/qa_TEST.py
index a0facd6..07a86f3 100755
--- a/python/qa_TEST.py
+++ b/python/qa_TEST.py
@@ -57,6 +57,9 @@ class TestCase_03_QAReporter(unittest.TestCase):
def message(self, msg):
return 1
+ def status(self, str):
+ return 1
+
def test_01_create(self):
QAReporter()
diff --git a/python/repository_TEST.py b/python/repository_TEST.py
index aad3ab5..e6144a6 100755
--- a/python/repository_TEST.py
+++ b/python/repository_TEST.py
@@ -207,6 +207,9 @@ class TestCase_02_RepositoryInterfaces(unittest.TestCase):
def message(self, msg):
self.messages += 1
+ def status(self, msg):
+ return
+
qi = repo.qa_interface
self.assert_(isinstance(qi, RepositoryQAInterface))
diff --git a/ruby/paludis_ruby.cc b/ruby/paludis_ruby.cc
index c127387..33ce091 100644
--- a/ruby/paludis_ruby.cc
+++ b/ruby/paludis_ruby.cc
@@ -329,5 +329,10 @@ paludis::ruby::RubyQAReporter::message(const QAMessage & msg)
exception_to_ruby_exception(e);
}
}
+
+void
+paludis::ruby::RubyQAReporter::status(const std::string &)
+{
+}
#endif
diff --git a/ruby/paludis_ruby.hh b/ruby/paludis_ruby.hh
index f4d9c74..6a0be8b 100644
--- a/ruby/paludis_ruby.hh
+++ b/ruby/paludis_ruby.hh
@@ -57,6 +57,7 @@ namespace paludis
public:
RubyQAReporter(VALUE*);
void message(const QAMessage &);
+ void status(const std::string &);
};
#endif
diff --git a/src/clients/qualudis/qualudis.cc b/src/clients/qualudis/qualudis.cc
index c93e52a..860b6cf 100644
--- a/src/clients/qualudis/qualudis.cc
+++ b/src/clients/qualudis/qualudis.cc
@@ -225,6 +225,11 @@ namespace
}
}
}
+
+ void status(const std::string & s)
+ {
+ std::cerr << xterm_title(s);
+ }
};
}