Esempio n. 1
0
bool pgAppMinimumVersion(const wxString &cmd, const int majorVer, const int minorVer)
{
	wxArrayString output;
	bool isEnterpriseDB = false;

#ifdef __WXMSW__
	if (wxExecute(cmd + wxT(" --version"), output, 0) != 0)
#else
	if (ExecProcess(cmd + wxT(" --version"), output) != 0)
#endif
	{
		wxLogError(_("Failed to execute: %s --version"), cmd.c_str());
		return false;
	}

	// Is this an EDB utility?
	if (output[0].Contains(wxT("EnterpriseDB")))
		isEnterpriseDB = true;

	wxString version = output[0].AfterLast(' ');
	long actualMajor = 0, actualMinor = 0;

	wxString tmp = wxT("");
	int x = 0;
	while(version[x] == '0' || version[x] == '1' || version[x] == '2' || version[x] == '3' || version[x] == '4' ||
	        version[x] == '5' || version[x] == '6' || version[x] == '7' || version[x] == '8' || version[x] == '9')
	{
		tmp += version[x];
		x++;
	}
	tmp.ToLong(&actualMajor);
	x++;

	tmp = wxT("");
	while(version[x] == '0' || version[x] == '1' || version[x] == '2' || version[x] == '3' || version[x] == '4' ||
	        version[x] == '5' || version[x] == '6' || version[x] == '7' || version[x] == '8' || version[x] == '9')
	{
		tmp += version[x];
		x++;
	}

	tmp.ToLong(&actualMinor);

	// EnterpriseDB's 8.3R1 utilties are based on PG8.2, so correct the version number here.
	// This will need more work when 8.3R2 is released :-(
	if (isEnterpriseDB && actualMajor == 8 && actualMinor == 3)
		actualMinor = 2;

	if (actualMajor > majorVer)
		return true;

	if (actualMajor == majorVer && actualMinor >= minorVer)
		return true;

	return false;
}
Esempio n. 2
0
bool isGpApp(const wxString &app)
{
	if (!wxFile::Exists(app))
		return false;

	wxArrayString output;

#ifdef __WXMSW__
	if (wxExecute(app + wxT(" --version"), output, 0) != 0)
#else
	if (ExecProcess(app + wxT(" --version"), output) != 0)
#endif
	{
		wxLogError(_("Failed to execute: %s --version"), app.c_str());
		return false;
	}

	if (output[0].Contains(wxT("8.2")))  // Ugly... No way to tell Greenplum app from PostgreSQL 8.2 app
		return true;

	return false;
}
Esempio n. 3
0
bool isEdbApp(const wxString &app)
{
	if (!wxFile::Exists(app))
		return false;

	wxArrayString output;

#ifdef __WXMSW__
	if (wxExecute(app + wxT(" --version"), output, 0) != 0)
#else
	if (ExecProcess(app + wxT(" --version"), output) != 0)
#endif
	{
		wxLogError(_("Failed to execute: %s --version"), app.c_str());
		return false;
	}

	if (output[0].Contains(wxT("EnterpriseDB")))
		return true;

	return false;
}
Esempio n. 4
0
void BuildDrawingRulesImpl(QString const & mapcssFile, QString const & outputDir)
{
  QString const outputTemplate = JoinPathQt({outputDir, "drules_proto_design"});
  QString const outputFile = outputTemplate + ".bin";

  // Caller ensures that output directory is clear
  if (QFile(outputFile).exists())
    throw std::runtime_error("Output directory is not clear");

  // Prepare command line
  QStringList params;
  params << "python" <<
            GetScriptPath() <<
            "-s" << mapcssFile <<
            "-o" << outputTemplate <<
            "-x" << "True";
  QString const cmd = params.join(' ');

  // Add path to the protobuf EGG in the PROTOBUF_EGG_PATH environment variable
  QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  env.insert("PROTOBUF_EGG_PATH", GetProtobufEggPath());

  // Run the script
  auto const res = ExecProcess(cmd, &env);

  // Script returs nothing and zero exit code if it is executed succesfully,
  if (res.first != 0 || !res.second.isEmpty())
  {
    QString msg = QString("System error ") + to_string(res.first).c_str();
    if (!res.second.isEmpty())
      msg = msg + "\n" + res.second;
    throw std::runtime_error(to_string(msg));
  }

  // Ensure generated files has non-zero size
  if (QFile(outputFile).size() == 0)
    throw std::runtime_error("Drawing rules file has zero size");
}
Esempio n. 5
0
void CMainFrame::Exec_pngquant(Parameter p)
{
	TCHAR options[32] = {0};
	if (p.nofs) {
		_tcscat(options, _T(" -nofs"));
	}
	if (p.iebug) {
		_tcscat(options, _T(" -iebug"));
	}
	TCHAR cmdLine[64];
	_stprintf(cmdLine, _T("pngquant.exe %s -speed %d %d"), options, p.speed, p.color);
	uint8_t* outp = &g_outImage[0];
	std::vector<uint8_t> outData;
	if (ExecProcess(cmdLine, g_inData, outData)) {
		if (outData.size()) {
			MemoryFile mf(&outData[0], outData.size());
			if (ReadImageInfo_png(mf, g_info)) {
				if (ReadImage_png(mf, g_info, outp, g_info.width*4, 0)) {
					int hoge = 1;
				}
			}
		}
	}
}
Esempio n. 6
0
// Entry point
int main(int argc, char *argv[])
{
	HKEY hKey;
	bool ok = false;
	char error[MAX_SIZE];
	wchar_t *current_args;
	bool flag = false;
	bool break_now = false;

	error[0] = 0;

	setlocale(LC_ALL, "");

	current_args = GetCommandLineW();

	// Remove the program name portion from the command line string
	while (true)
	{
		switch (*current_args)
		{
		case L'\"':
			if (flag == false)
			{
				flag = true;
			}
			else
			{
				flag = false;
			}
			break;

		case L' ':
		case L'\t':
		case 0:
			if (flag == false)
			{
				break_now = true;
			}
			break;
		}
		if (break_now)
		{
			break;
		}
		current_args++;
	}

	while (true)
	{
		if (*current_args == L' ' || *current_args == L'\t')
		{
			current_args++;
		}
		else
		{
			break;
		}
	}

	strcpy(error, "VPN Command Line Tools is not Installed.\nPlease reinstall programs.");

	// Get the path of the vpncmd.exe from the registry
	if (RegOpenKey(HKEY_LOCAL_MACHINE, VPNCMD_BOOTSTRAP_REG_KEYNAME, &hKey) == 0)
	{
		DWORD type = REG_SZ;
		DWORD size = 4096;
		char buf[4096];

		if (RegQueryValueEx(hKey, VPNCMD_BOOTSTRAP_REG_VALUENAME_PATH, NULL, &type, (LPBYTE)buf, &size) == 0)
		{
			wchar_t args[MAX_SIZE];

			swprintf(args, sizeof(args), L"\"%S\" %s", buf, current_args);
			if (ExecProcess(buf, args) == false)
			{
				//sprintf(error, "Failed to execute \"%S\".", buf);
			}
			else
			{
				ok = true;
			}
		}

		RegCloseKey(hKey);
	}

	if (ok == false)
	{
		printf("%s\n", error);
	}

	return ret_code;
}