I created a script that uses Python subprocess.Popen(...). When I click a button, I want to destroy this subprocess (I use subprocess.kill()). It works fine when I use Python.
However, when I "compile" my script with PyInstaller, this doesn't work. Indeed, in the Task Manager (Windows), there are two processes (one from a temporary directory [created by PyInstaller I guess]). And so when I click the button, a process stops, but not one created by PyInstaller.
How can I do to kill the 2 processes at once ?
Tkanks
PS : Sorry for my bad english...
Have you tried to compile the 2 Python files? You have to use the path of the second compiled file when you use subprocess.Popen(...)
Related
I would like to run an exported Parameters Variation experiment on my Linux machine. Although there is a way for setting a Simulation experiment to start automatically running the batch file (or .sh file for Linux) once the file is opened, I cannot find a similar option for Parameters Variation in which I am running 40 different replications of the same model. In Windows, you need to open the file and manually click the Run button for this.
Considering Linux OS, which is a headless environment, how can I make the model start automatically once I run the command ./mySimulationModel_linux.sh?
Currently when I run this command, the model does nothing. Any help will be appreciated.
The best option would be to add some code to your "Initial Experiment setup:" section to get it to run without any user input
just add run();
Of course, you can add any of other code as well there.
To do this in-editor you open the automation tab, connect to the session and choose which tests to run.
How do you do it from the command line?
(NB. not compiling UnrealEngine/Engine/Build/BatchFiles/* comprehensively covers both building the application and compiling it. Specifically, given that you have code that is 100% happy to compile, how do you kick the test suite off)
--
Here's some more info, from recent testing on 4.10:
Running tests from the editor:
UE4Editor Project.uproject -ExecCmds="Automation RunTests MyTest"
Notice the absence of the -Game flag; this launches the Editor and runs the tests successfully in the editor console.
Running the game engine and using the 'popup log window':
UE4Editor Project.uproject -Game -ExecCmds="Automation RunTests MyTest" -log
This runs the game in 'play' mode, pops up an editor window; however, the logs stop at:
LogAssetRegistry: FAssetRegistry took 0.0004 seconds to start up
...and the game never closes or executes the tests.
Running the game engine and logging to a file:
UE4Editor Project.uproject -Game -ExecCmds="Automation RunTests MyTest" -log=Log.txt
This runs the game in 'play' mode, and then stops and never exists.
It does not appear to run any tests or log to any files.
The folder Saved/Logs does not exist after quitting the running game.
Running in the editor, test types, etc...
see: https://answers.unrealengine.com/questions/358821/hot-reload-does-not-re-compile-automation-tests.html,
Hot reload is not supported for tests; so this isn't an option.
There's also been some suggestion in various places that the test type (eg. ATF_Game, ATF_Editor) has some affect on if runs are or can be run; perhaps this is an issue to, but I've tried all kind of combinations with no success.
--
I've tried all kinds of combinations of things trying to get this working, with no success so it's time for a bounty.
I'll accept an answer which reliably:
Executes a specific test from the command line
Logs the output from that test to a file
Right, no one has any idea here or on the issue tracker.
After some serious digging through the UE4 source code, here's the actual deal, which I leave here for the next suffering soul who can't figure this out:
To run tests from the command line, and log the output and exit after the test run use:
UE4Editor.exe path/to/project/TestProject.uproject
-ExecCmds="Automation RunTests SourceTests"
-unattended
-nopause
-testexit="Automation Test Queue Empty"
-log=output.txt
-game
On OSX use UE4Editor.app/Contents/MacOS/UE4Editor.
Notice that the logs will, regardless of what you supply, ultimately be placed in:
WindowsNoEditor/TestProject/Saved/Logs/output.txt
or
~/Library/Logs/TestProject/output.txt
Notice that for mac this is outside of your project directory, in, for example, /Users/doug/Library/Logs/TestProject. (Who thought that was a good idea?)
(see https://wiki.unrealengine.com/Locating_Project_Logs#Game_Logs)
You can list automation tests using:
-ExecCmds="Automation List"
...and then parse the response to find tests to run; automation commands may be chained, for example:
-ExecCmds="Automation List, Automation RunAll"
Do you mean the in-editor command line or the Windows command line?
In the editor you can use the Automation command with parameters, e.g. Automation RunAll
In the Windows command line you can specify unreal command parameters with -ExecCmds. To run all tests in your project: UE4Editor.exe YOURPROJECT -Game -ExecCmds="Automation RunAll"
For anyone still wondering, there is a bug in the editor that make it so the test list is flushed before they are run when they are started from the command-line (be it at startup or after).
This means that the editor actually compiles a list of tests to run, which is then flushed by another part of the program. The editor then thinks that it has finished running all the test and, since there is no errors, shows that they all succeeded.
I can post how to do a fix to this if anyone is interested, but it introduce another minor bug.
I know it's possible to re-compile or re-run tests on file changes. I want know to if it's possible to perform something similar for the run command. ~ run does not work. (That makes sense since the run never finishes).
Is there a way to create a task that watches for file changes, quit the running server and relaunch it ?
If not what other tool, would you suggest to get the same behaviour ?
You will have to bring in an external project like sbt-revolver
https://github.com/spray/sbt-revolver
I want to read data from GtkListStore and build an excel by phpExcel. First, I build a php file according to the GtkListStore, then I use php and phpexcel lib to compile and build execl file.
In my gtk code (compile in MinGW environment), I use execvp(cmd[0], (const char **)cmd); to call the external command -- php. In fact, cmd[0] is php.exe and cmd[1], cmd[2] ... are the parameters for php. After calling the php command, my gtk main window is closed and it quits my gtk program.
How can I prevent the php command from quitting main program? Should I use something else instead of execvp? Thank you.
execvp() and friends replace the current process with another process, so it's no surprise that your program quits. Use g_spawn_sync() or a related function - that will run your php program, then return control to your original program.
Let me answer my own question. Followed is the summary to what I have googled and tried within the past few days. It has nothing new but maybe is useful to a newbie like me.
First, thank ptomato. To avoid my problem in GTK, it must use g_spawn_sync or related functions. If your command is absolute path, you don't have to use the flag G_SPAWN_SEARCH_PATH, otherwise, make sure to use the flag.
Following are something related in MinGW environment.
-> gspawn-win32-helper.exe
In MinGW, to use g_spawn_sync, it must have gspawn-win32-helper.exe installed. When I installed GTK environment, I only extracted the useful lib or exe file I think it is useful then I missed gspawn-win32-helper.exe and it resulted in the problem -- Failed to execute helper program (No such file or directory) mentioned in the above comments. After extracting gspawn-win32-helper.exe from ftp://ftp.gtk.org/pub/glib/2.10/win32/glib-2.10.0.zip and installing it, g_spawn_sync worked.
-> For canonical Windows paths, both double backslashes and single forward slash work, e.g., c:/foo/bar and c:\foo\bar work.
I have everything installed and I am able to create and run tests in NetBeans fine by right clicking the test in the project menu and selecting "Run". The problem is that the browser windows opened for the test close immediately after the test is ran - meaning that the only reporting I have is what NetBeans provides and that's not enough. I don't think I want to use the command line, plus I haven't had much success with it in the past anyways.
Is it possible to just point the browser at the test.php file? When i try to do that I get this error:
Fatal error: Class 'PHPUnit_Framework_TestCase' not found in C:\xampp\php\PEAR\PHPUnit\Extensions\SeleniumTestCase.php on line 275
Shouldn't i be able to execute these test from a different machine? ie PC1 is my dedicated selenium test box and I want to tell it to run test.php from PC2 remotely.
Where should my test files go?
How do I customize the reporting/out put from the test script?
You could add a sleep(60) at the end of your test :) This would prevent PHPUnit from closing the Selenium session.
Alternatively, store your selenium tests as html files compatible with the Selenium IDE Firefox extension and let the test simply run in your browser.
I found out how to run my test files remotely - i just created a script that would execute phpunit from the command line:
<?php
exec('c:\xampp\php\phpunit.bat c:\xampp\htdocs\selenium\testcases\newSeleneseTest.php', $output);
echo "<pre>". var_export($output,TRUE)."</pre>";
exec('c:\xampp\php\phpunit.bat c:\xampp\htdocs\selenium\testcases\newSeleneseTest.php', $output);
echo "<pre>". var_export($output,TRUE)."</pre>";
?>
then I can just hit the URL of that script to have it run - works great, but I still think there should be a better/easier way...