Beispiel #1
0
/**
 * Constraucts a Libertine application wrapper object.
 * @param[in] argc  The count of the number of command-line arguments.
 * @param[in] argv  A vector of command-line arguments.
 *
 * Sets up the Libertine application from the command-line arguments,
 * environment variables, and configurations files and displays the GUI.
 */
Libertine::
Libertine(int argc, char* argv[])
: QGuiApplication(argc, argv)
, main_qml_source_file_(find_main_qml_source_file())
{
  setApplicationName(LIBERTINE_APPLICATION_NAME);
  setApplicationVersion(LIBERTINE_VERSION);
  config_.reset(new LibertineConfig(*this));
  qmlRegisterType<ContainerConfig>("Libertine", 1, 0, "ContainerConfig");
  qmlRegisterType<ContainerManagerWorker>("Libertine", 1, 0, "ContainerManagerWorker");
  qmlRegisterType<PasswordHelper>("Libertine", 1, 0, "PasswordHelper");

  initialize_python();

  if (main_qml_source_file_.isEmpty())
  {
    qWarning() << "Can not locate " << s_main_QML_source_file;
  }

  containers_ = new ContainerConfigList(config_.data(), this);
  container_apps_ = new ContainerAppsList(containers_, this);
  password_helper_ = new PasswordHelper();

  initialize_view();
  view_.show();
}
Beispiel #2
0
int assimilate_handler(WORKUNIT& wu, std::vector<RESULT>& results, RESULT& canonical_result)
{
  PyObject *retval;

  initialize_python();
#if 0// OLD
  retval = py_user_code_on_workunit(results, &canonical_result, "assimilators");
  if(retval == NULL)
    {
      fprintf(stderr,"[%s:%d] There was a python error when assimilating %s.\nExiting.\n",__FILE__,__LINE__,canonical_result.name);
      finalize_python();
      exit(1);
    }
  Py_DECREF(retval);

  if(PyErr_Occurred())
    {
      printf("Assimilation failed\n");
      PyErr_Print();
      finalize_python();
      return 1;
    }
#else // New
    std::string command;
  
  if(PyRun_SimpleString("import boinctools;results = []"))
    {
      fprintf(stderr,"Could not import boinctools python module.\n");
      if(PyErr_Occurred())
	PyErr_Print();
      finalize_python();
      exit(1);
    }
  
  // Create Result Class
  command = "canonical = " + result_init_string(canonical_result);
  if(PyRun_SimpleString(command.c_str()))
    {
      fprintf(stderr,"Could not create result object.\n");
      fprintf(stderr,"Python command: %s",command.c_str());
      if(PyErr_Occurred())
	PyErr_Print();
      finalize_python();
      exit(1);
    }

  for(std::vector<RESULT>::const_iterator result = results.begin();result != results.end();result++)
    {
      command = "results.append(" + result_init_string(*result) + ")";
      if(PyRun_SimpleString(command.c_str()))
	{
	  fprintf(stderr,"Could not add result object to assimilation result list.\n");
	  fprintf(stderr,"Python command: %s",command.c_str());
	  if(PyErr_Occurred())
	    PyErr_Print();
	  finalize_python();
	  exit(1);
	}
    }
  
  command = "boinctools.assimilator(results,canonical)";
  if(PyRun_SimpleString(command.c_str()))
    {
      fprintf(stderr,"Could not assimilate result objects.\n");
      fprintf(stderr,"Python command: %s",command.c_str());
      if(PyErr_Occurred())
	PyErr_Print();
      finalize_python();
      exit(1);
    }
  
#endif
  return 0;


}