Пример #1
0
/*static*/
int
_MSFT_nxServiceResource_Self::create (
    _MSFT_nxServiceResource_Self** const ppInstance)
{
    int rval = EXIT_SUCCESS;
    PyObjPtr pModule;
    PyObjPtr pSetFn;
    PyObjPtr pTestFn;
    PyObjPtr pGetFn;
    if (ppInstance &&
        !*ppInstance)
    {
        if (EXIT_SUCCESS == (rval = initPython ("do'h", GetScriptPath().c_str())))
        {
            pModule = loadModule ("nxService");
            if (pModule)
            {
                pSetFn = loadFunctionFromModule (pModule, "Set_Marshall");
                pTestFn = loadFunctionFromModule (pModule, "Test_Marshall");
                pGetFn = loadFunctionFromModule (pModule, "Get_Marshall");
                if (pSetFn && pTestFn && pGetFn)
                {
                    *ppInstance = new _MSFT_nxServiceResource_Self (
                        pModule, pSetFn, pTestFn, pGetFn);
                }
                else
                {
                    rval = EXIT_FAILURE;
                }
            }
            else
            {
                rval = EXIT_FAILURE;
            }
        }
        else
        {
            rval = EXIT_FAILURE;
        }
    }
    else
    {
        rval = EXIT_FAILURE;
    }
    return rval;
}
Пример #2
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");
}
Пример #3
0
TInt CSecMgrStore::GetScriptFile(TDes& aFile, TExecutableID aExecID)
	{
	TInt ret(GetScriptPath (aFile));

	if ( (KErrNone==ret) || (KErrAlreadyExists==ret))
		{
		if ( KAnonymousScript!=aExecID)
			{
			HBufC *fSuffix = HBufC::NewLC(KMaxName);
			TPtr fSuffixPtr(fSuffix->Des());
			fSuffixPtr.Num (aExecID);

			aFile.Append (fSuffixPtr);
			aFile.Append (KDatExtn);
			CleanupStack::PopAndDestroy (fSuffix);
			}
		}

	if ( KErrAlreadyExists==ret)
		ret=KErrNone;

	return ret;
	}
Пример #4
0
const char * qEnvHttp::GetName()
{
    return GetScriptPath();
}