예제 #1
0
void ZDvidBufferReader::read(
    const QString &url, const QByteArray &payload, bool outputingUrl)
{
  if (outputingUrl) {
    qDebug() << url;
  }

  m_buffer.clear();

#if defined(_ENABLE_LIBDVIDCPP_)
//  qDebug() << "Using libdvidcpp";

  ZDvidTarget target;
  target.setFromUrl(url.toStdString());

  if (target.isValid()) {
    try {
      libdvid::DVIDNodeService service(
            target.getAddressWithPort(), target.getUuid());
      std::string endPoint = ZDvidUrl::GetEndPoint(url.toStdString());
      libdvid::BinaryDataPtr libdvidPayload =
          libdvid::BinaryData::create_binary_data(payload.data(), payload.length());
      libdvid::BinaryDataPtr data = service.custom_request(
            endPoint, libdvidPayload, libdvid::POST, m_tryingCompress);

      m_buffer.append(data->get_data().c_str(), data->length());
      m_status = READ_OK;
    } catch (std::exception &e) {
      std::cout << e.what() << std::endl;
      m_status = READ_FAILED;
    }
  }
#endif
}
예제 #2
0
void ZDvidBufferReader::read(const QString &url, bool outputingUrl)
{
  if (outputingUrl) {
    qDebug() << url;
  }

  m_buffer.clear();

#if defined(_ENABLE_LIBDVIDCPP_)
//  qDebug() << "Using libdvidcpp";

  ZDvidTarget target;
  target.setFromUrl(url.toStdString());

  if (target.isValid()) {
    try {
      libdvid::DVIDNodeService service(
            target.getAddressWithPort(), target.getUuid());
      std::string endPoint = ZDvidUrl::GetEndPoint(url.toStdString());
      libdvid::BinaryDataPtr data = service.custom_request(
            endPoint, libdvid::BinaryDataPtr(), libdvid::GET, m_tryingCompress);

      m_buffer.append(data->get_data().c_str(), data->length());
      m_status = READ_OK;
    } catch (std::exception &e) {
      std::cout << e.what() << std::endl;
      m_status = READ_FAILED;
    }
  } else {
    startReading();

    m_networkReply = m_networkManager->get(QNetworkRequest(url));
    connect(m_networkReply, SIGNAL(finished()), this, SLOT(finishReading()));
    connect(m_networkReply, SIGNAL(readyRead()), this, SLOT(readBuffer()));
    connect(m_networkReply, SIGNAL(error(QNetworkReply::NetworkError)),
            this, SLOT(handleError(QNetworkReply::NetworkError)));

    waitForReading();
  }

#else
  startReading();

  m_networkReply = m_networkManager->get(QNetworkRequest(url));
  connect(m_networkReply, SIGNAL(finished()), this, SLOT(finishReading()));
  connect(m_networkReply, SIGNAL(readyRead()), this, SLOT(readBuffer()));
  connect(m_networkReply, SIGNAL(error(QNetworkReply::NetworkError)),
          this, SLOT(handleError(QNetworkReply::NetworkError)));

  waitForReading();
#endif
}
예제 #3
0
void ZFlyEmSupervisor::setDvidTarget(const ZDvidTarget &target)
{
  m_dvidTarget = target;
  if (!target.getSupervisor().empty()) {
    setSever(m_dvidTarget.getSupervisor());
  }
}
예제 #4
0
void ZDvidTile::setDvidTarget(const ZDvidTarget &target)
{
  m_dvidTarget = target;
  if (!m_tilingInfo.isValid()) {
    ZDvidReader reader;
    if (reader.open(target)) {
      m_tilingInfo = reader.readTileInfo(target.getMultiscale2dName());
    }
  }
}
예제 #5
0
void ZDvidDialog::setServer(int index)
{
  ZDvidTarget dvidTarget = m_dvidRepo[index];

  ui->addressLineEdit->setText(dvidTarget.getAddress().c_str());
  ui->portSpinBox->setValue(dvidTarget.getPort());
  ui->uuidLineEdit->setText(dvidTarget.getUuid().c_str());
  ui->infoLabel->setText(dvidTarget.getComment().c_str());
  ui->bodyLineEdit->setText(dvidTarget.getBodyLabelName().c_str());
  ui->grayScalelineEdit->setText(dvidTarget.getGrayScaleName().c_str());
  ui->labelBlockLineEdit->setText(dvidTarget.getLabelBlockName().c_str());
  ui->tileLineEdit->setText(dvidTarget.getMultiscale2dName().c_str());

  ui->addressLineEdit->setReadOnly(index > 0);
  ui->portSpinBox->setReadOnly(index > 0);
  ui->uuidLineEdit->setReadOnly(index > 0);
//  ui->bodyLineEdit->setReadOnly(index > 0);
}
int ZSplitTaskUploadCommand::run(
    const std::vector<std::string> &input, const std::string &/*output*/,
    const ZJsonObject &config)
{
  ZJsonObject dvidJson(config.value("dvid"));
  if (dvidJson.isEmpty()) {
    std::cerr << "No dvid server specified. Abort." << std::endl;
    return 1;
  }

  if (input.empty()) {
    std::cerr << "No input file specified. Abort." << std::endl;
    return 1;
  }

  ZDvidTarget target;
  target.loadJsonObject(dvidJson);
  if (!target.isValid()) {
    std::cerr << "No valide dvid server specified. Abort." << std::endl;
    return 1;
  }

  if (target.getBodyLabelName().empty()) {
    std::cerr << "No sparsevol data specified. Abort." << std::endl;
    return 1;
  }

  ZJsonObject docJson;
  docJson.load(input.front());

  ZJsonArray rootObj(docJson.value("meshReview"));
  if (rootObj.isEmpty()) {
    std::cerr << "Unrecognized input format. Abort." << std::endl;
    return 1;
  }

  ZDvidWriter *writer = ZGlobal::GetInstance().getDvidWriterFromUrl(
        GET_FLYEM_CONFIG.getTaskServer());
  if (writer == NULL) {
    std::cerr << "Unable to Initialize the task server: "
              << GET_FLYEM_CONFIG.getTaskServer() << std::endl;
    std::cerr << "Abort" << std::endl;
    return 1;
  } else {
    std::cout << "Task server: " << writer->getDvidTarget().getSourceString()
              << std::endl;
  }

  ZDvidUrl dvidUrl(target);

  std::cout << std::endl;
  std::cout << "Uploading tasks: " << std::endl << std::endl;
  int count = 0;
  for (size_t i = 0; i < rootObj.size(); ++i) {
    ZJsonObject obj(rootObj.value(i));
    ZJsonArray markerJson(obj.value("pointMarkers"));
#ifdef _DEBUG_2
      std::cout << "Here";
#endif
    if (!markerJson.isEmpty()) {
      uint64_t bodyId =
          ZString(obj.value("file").toString()).firstUint64();

      if (bodyId > 0) {
        ZJsonObject taskJson;
        ZFlyEmMisc::SetSplitTaskSignalUrl(taskJson, bodyId, target);
        for (size_t i = 0; i < markerJson.size(); ++i) {
          ZJsonObject markerObj(markerJson.value(i));
          ZStroke2d stroke =
              ZFlyEmMisc::SyGlassSeedToStroke(markerObj);
          ZFlyEmMisc::AddSplitTaskSeed(taskJson, stroke);
        }

        std::string location = writer->writeServiceTask("split", taskJson);
        ZJsonObject entryJson;
        entryJson.setEntry(neutube::json::REF_KEY, location);
        QString taskKey = dvidUrl.getSplitTaskKey(bodyId).c_str();
        writer->writeSplitTask(taskKey, taskJson);
        std::cout << "*    Task for " << bodyId << " is saved @ "
                  << taskKey.toStdString() << "->" << location << std::endl;
        ++count;
      }
    }
  }
  std::cout << std::endl;
  std::cout << count << " tasks uploaded." << std::endl;

  return 0;
}