예제 #1
0
void CRDPStatus::ShowInfo(void)
{
	CDirControl	dir(Global::config.GetInfoDrivePath());	// (also changes drive)

	std::string	file = Global::config.GetInfoFile();

	size_t numwritten;
	FILE *infoStrm;
	char*	xmlHead = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
	char*	rdpHead = "<RDP>\n";
	char*	rdpTail = "</RDP>\n";
	char*	statusHead = "\t<STATUS>\n";
	char*	statusTail = "\t</STATUS>\n";
	char*	mssHead = "\t<MSS CONNECTED=\"";
	std::string	s;
	std::string prefix1("\t");		// prefix 1 tab
	std::string prefix2("\t\t");	// prefix 2 tabs

	if (fopen_s(&infoStrm, file.c_str(), "w+b") == 0) {
		numwritten = fwrite(xmlHead, 1, strlen(xmlHead), infoStrm);
		fwrite(rdpHead, 1, strlen(rdpHead), infoStrm);
		// MSS status
		s = mssHead;
		if (Global::status.IsMSSConnected()) {
			s += "YES\"/>\n";
			fwrite(s.c_str(), 1, s.length(), infoStrm);
		} else {
			s += "NO\"/>\n";
			fwrite(s.c_str(), 1, s.length(), infoStrm);
			}

		// Capture status
		s = ShowCapture(prefix1);
		fwrite(s.c_str(), 1, s.length(), infoStrm);

		// interface cards status
		fwrite(statusHead, 1, strlen(statusHead), infoStrm);
		for (int card = 0; card < Global::MAX_CARDS; card++) {
			s = ShowCard(card, prefix2);
			fwrite(s.c_str(), 1, s.length(), infoStrm);
		}
		fwrite(statusTail, 1, strlen(statusTail), infoStrm);
		fwrite(rdpTail, 1, strlen(rdpTail), infoStrm);
		fclose(infoStrm);
	} else {
		MsgLog::Error("CRDPStatus::ShowInfo Problem opening file %s\n", file.c_str());
	}
}
예제 #2
0
파일: main.cpp 프로젝트: hgsteggles/Torch
int main (int argc, char** argv) {
	MPIW& mpihandler = MPIW::Instance();

	bool silent = mpihandler.getRank() != 0;
	std::string paramFile = "config/torch-config.lua";
	std::string setupFile = "config/torch-setup.lua";

	// Parse parameters
	if (argc > 4) {
		showUsage();
		return 0;
	}
	if (argc > 1) {
		for (int iarg = 1; iarg < argc; ++iarg) {
			std::string arg = argv[iarg];
			std::string prefix1("--paramfile=");
			std::string prefix2("--setupfile=");
			std::string prefix3("-s");

			if (!arg.compare(0, prefix1.size(), prefix1))
				paramFile = arg.substr(prefix1.size()).c_str();
			else if (!arg.compare(0, prefix2.size(), prefix2))
				setupFile = arg.substr(prefix2.size()).c_str();
			else if (!arg.compare(0, prefix3.size(), prefix3))
				silent = true;
			else {
				showUsage();
				return 0;
			}
		}
	}

	std::unique_ptr<LogPolicyInterface> consoleLogPolicy 
		= std::unique_ptr<ConsoleLogPolicy>(new ConsoleLogPolicy());
	consoleLogPolicy->setLogLevel(silent ? SeverityType::ERROR : SeverityType::DEBUG);
	Logger::Instance().registerLogPolicy("console", std::move(consoleLogPolicy));

	TorchParameters tpars;

	try {
		mpihandler.serial([&] () {
			tpars.outputDirectory = parseOutputDirectory(paramFile);
		});

		if (mpihandler.getRank() == 0) {
			FileManagement::makeDirectoryPath(tpars.outputDirectory);
			FileManagement::deleteFileContents(tpars.outputDirectory);
			FileManagement::makeDirectoryPath(tpars.outputDirectory + "/log");
			FileManagement::deleteFileContents(tpars.outputDirectory + "/log");
			FileManagement::copyConfigFile(setupFile, tpars.outputDirectory);
			FileManagement::copyConfigFile(paramFile, tpars.outputDirectory);
		}

		mpihandler.barrier();

		std::unique_ptr<LogPolicyInterface> fileLogPolicy 
			= std::unique_ptr<FileLogPolicy>(
				  new FileLogPolicy(tpars.outputDirectory + "/log/torch.log" + std::to_string(mpihandler.getRank()))
			  );
		fileLogPolicy->setLogLevel(SeverityType::NOTICE);
		Logger::Instance().registerLogPolicy("file", std::move(fileLogPolicy));
	}
	catch (std::exception& e) {
		Logger::Instance().print<SeverityType::FATAL_ERROR>(e.what());
		mpihandler.abort();
	}

	try {
		mpihandler.serial([&] () {
			parseParameters( paramFile, tpars);
			tpars.setupFile = setupFile;
		});

		Torch torch;
		torch.initialise(tpars);
		torch.run();
	}
	catch (std::exception& e) {
		Logger::Instance().print<SeverityType::FATAL_ERROR>(e.what());
		std::cout << "See " << tpars.outputDirectory << "/log/torch.log* for more details." << std::endl;
		MPIW::Instance().abort();
	}

	return 0;
}
예제 #3
0
  void FuzzyStringComparator::reportFailure_(char const* const message) const
  {
    // We neither want this entire method be non-const nor make
    // is_status_success_ a mutable.  So lets hack around it.  (Documented in
    // class.)
    const_cast<bool&>(is_status_success_) = false;

    if (verbose_level_ >= 1)
    {
      PrefixInfo_ prefix1(input_line_1_, tab_width_, first_column_);
      PrefixInfo_ prefix2(input_line_2_, tab_width_, first_column_);

      std::string prefix;
      if (use_prefix_)
      {
        prefix = "   :|:  ";
      }

      *log_dest_ << std::boolalpha <<
        prefix << "FAILED: '" << message << "'\n" <<
        prefix << "\n" <<
        prefix << "  input:\tin1\tin2\n" <<
        prefix << "  line:\t" << line_num_1_ << '\t' << line_num_2_ << "\n" <<
        prefix << "  pos/col:\t" << input_line_1_.line_position_ << '/' << prefix1.line_column << '\t' << input_line_2_.line_position_ << '/' << prefix2.line_column << "\n" <<
        prefix << " --------------------------------\n" <<
        prefix << "  is_number:\t" << element_1_.is_number << '\t' << element_2_.is_number << "\n" <<
        prefix << "  numbers:\t" << element_1_.number << '\t' << element_2_.number << "\n" <<
        prefix << "  is_space:\t" << element_1_.is_space << '\t' << element_2_.is_space << "\n" <<
        prefix << "  is_letter:\t" << (!element_1_.is_number && !element_1_.is_space) << '\t' << (!element_2_.is_number && !element_2_.is_space) << "\n" <<
        prefix << "  letters:\t\"" << element_1_.letter << "\"\t\"" << element_2_.letter << "\"\n" <<
        prefix << "  char_codes:\t" << static_cast<UInt>(element_1_.letter) << "\t" << static_cast<UInt>(element_2_.letter) << "\n" <<
        prefix << " --------------------------------\n" <<
        prefix << "  relative_max:        " << ratio_max_ << "\n" <<
        prefix << "  relative_acceptable: " << ratio_max_allowed_ << "\n" <<
        prefix << " --------------------------------\n" <<
        prefix << "  absolute_max:        " << absdiff_max_ << "\n" <<
        prefix << "  absolute_acceptable: " << absdiff_max_allowed_ << std::endl;

      writeWhitelistCases_(prefix);

      *log_dest_
        << prefix << "\n"
        << prefix << "Offending lines:\t\t\t(tab_width = " << tab_width_ << ", first_column = " << first_column_ << ")\n"
        << prefix << "\n"
        << prefix << "in1:  " << QDir::toNativeSeparators(File::absolutePath(input_1_name_).toQString()).toStdString() << "   (line: " << line_num_1_ << ", position/column: " << input_line_1_.line_position_ << '/' << prefix1.line_column << ")\n"
        << prefix << prefix1.prefix << "!\n"
        << prefix << prefix1.prefix_whitespaces << OpenMS::String(input_line_1_.line_.str()).suffix(input_line_1_.line_.str().size() - prefix1.prefix.size()) << "\n"
        << prefix <<  "\n"
        << prefix << "in2:  " << QDir::toNativeSeparators(File::absolutePath(input_2_name_).toQString()).toStdString() << "   (line: " << line_num_2_ << ", position/column: " << input_line_2_.line_position_ << '/' << prefix2.line_column << ")\n"
        << prefix << prefix2.prefix << "!\n"
        << prefix << prefix2.prefix_whitespaces << OpenMS::String(input_line_2_.line_.str()).suffix(input_line_2_.line_.str().size() - prefix2.prefix.size()) << "\n"
        << prefix << "\n\n"
        << "Easy Access:" << "\n"
        << QDir::toNativeSeparators(File::absolutePath(input_1_name_).toQString()).toStdString() << ':' << line_num_1_ << ":" << prefix1.line_column << ":\n"
        << QDir::toNativeSeparators(File::absolutePath(input_2_name_).toQString()).toStdString() << ':' << line_num_2_ << ":" << prefix2.line_column << ":\n"
        << "\n"
        #ifdef WIN32
        << "TortoiseMerge"
        << " /base:\"" << QDir::toNativeSeparators(File::absolutePath(input_1_name_).toQString()).toStdString() << "\""
        << " /mine:\"" << QDir::toNativeSeparators(File::absolutePath(input_2_name_).toQString()).toStdString() << "\""
        #else
        << "diff"
        << " " << QDir::toNativeSeparators(File::absolutePath(input_1_name_).toQString()).toStdString()
        << " " << QDir::toNativeSeparators(File::absolutePath(input_2_name_).toQString()).toStdString()
        #endif
        << std::endl;
    }

    // If verbose level is low, report only the first error.
    if (verbose_level_ < 3)
    {
      throw FuzzyStringComparator::AbortComparison();
    }

    return;
  } // reportFailure_()