J'essaie d'utiliser Adobe AIR NativeProcess dans une application Flex pour générer un fichier XML que je peux analyser pour obtenir diverses informations système sur un Mac (j'ai l'équivalent sous Windows et Je ne suis pas très familier avec le Mac). J'ai surtout besoin d'informations sur le CPU.AIR - NativeProcess avec Sytem Profiler sur Mac
Je ne parviens pas à appeler le profileur système et à passer les paramètres appropriés (ou tous les paramètres) pour que le processus NativeProcess s'exécute correctement.
Si je mets l'exécutable NativeProcess à:
/Applications/Utilitaires/Système Profiler.app/Contents/MacOS/System Profiler
il exécute, mais je vois le résultat à l'écran pop-up (il ne tient pas compte mes arguments pour l'enregistrer dans un fichier que je crois logique puisque c'est la version graphique).
Si je mets l'NativeProcess exécutable à:
utilisateur/sbin/system_profiler ou tout simplement system_profiler
rien et exécute je reçois un ArgumentError # 2004 sur la ligne où j'attribue l'exécutable.
Les paramètres sont quelque chose comme ceci:
systemDataMac.npArgList = [ "-xml", ">", systemDataFileName, "- detailLevel", "base"];
Comment puis-je obtenir ce fichier généré correctement (ou est-il un autre moyen d'obtenir les informations du processeur directement dans mon application Flex/AIR
Merci
Exemple de code:!
var nativeProcess:NativeProcess=new NativeProcess();
var startupInfo:NativeProcessStartupInfo=new NativeProcessStartupInfo();
var npArgs:Array = [];
var appDataDir:File = File.applicationStorageDirectory;
var nativeFilePath:String = appDataDir.nativePath.toString();
nativeFilePath+= File.separator + "systemInfoFile.xml";
nativeProcess.addEventListener(NativeProcessExitEvent.EXIT, onExit);
nativeProcess.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
nativeProcess.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, onErrorData);
nativeProcess.addEventListener(IOErrorEvent.STANDARD_INPUT_IO_ERROR, onInputIOError);
nativeProcess.addEventListener(IOErrorEvent.STANDARD_OUTPUT_IO_ERROR, onOutputIOError);
try
{
// tried each of these three
startupInfo.executable=new File("system_profiler"); // throws error
startupInfo.executable=new File("/user/sbin/system_profiler"); // throws error
startupInfo.executable=new File("/Applications/Utilities/System Profiler.app/Contents/MacOS/System Profiler"); // works but doesn't handle args because it is the GUI version I believe
npArgs = ["-xml",">", nativeFilePath,"-detailLevel","basic"];
var args:Vector.<String>=new Vector.<String>();
for each(var item:String in npArgs)
{
args.push(item);
}
startupInfo.arguments=args;
nativeProcess.start(startupInfo);
}
catch (error:IllegalOperationError)
{
trace("Illegal Operator Error - " + error.toString());
}
catch (error:ArgumentError)
{
trace("Arg Error - " + error.toString());
}
catch (error:Error)
{
trace("Error - " + error.toString());
}
afficher un code sur la façon dont vous essayez de l'exécuter. –
T son devrait être le code équivalent. – ImAStreamer