From 08e66aa8d555246b732de1d58751c2e593bd8d80 Mon Sep 17 00:00:00 2001 From: drallensmith <drallensmith@users.noreply.github.com> Date: Wed, 5 Jul 2017 15:11:23 -0500 Subject: [PATCH] setup.py clarifications (will put in README.md next); reliability fix in HFO; python_agents_3v3.sh for version compatibility testing --- bin/HFO | 18 ++++++++++++------ example/python_agents_3v3.sh | 5 +++-- setup.py | 10 +++++++++- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/bin/HFO b/bin/HFO index 14e5590..96e8a46 100755 --- a/bin/HFO +++ b/bin/HFO @@ -1,16 +1,18 @@ #!/usr/bin/env python # encoding: utf-8 +from __future__ import print_function import subprocess, os, time, numpy, sys # Global list of all/essential running processes processes, necProcesses = [], [] -# Command to run the rcssserver. Edit as needed. + +# Command to run the rcssserver. Edit as needed; the below assumes running in the same directory as HFO SERVER_BIN = 'rcssserver' -# Command to run the monitor. Edit as needed. +# Command to run the monitor. Edit as needed; ditto to the above re directories. MONITOR_BIN = 'soccerwindow2' -def launch(cmd, name = 'Unknown', necessary = True, supressOutput = True): +def launch(cmd, name = 'Unknown', necessary = True, suppressOutput = True): """Launch a process. Appends to list of processes and (optionally) necProcesses if @@ -19,10 +21,14 @@ def launch(cmd, name = 'Unknown', necessary = True, supressOutput = True): Returns: The launched process. """ kwargs = {} - if supressOutput: + if suppressOutput: kwargs = {'stdout': open('/dev/null', 'w'), 'stderr': open('/dev/null', 'w')} - p = subprocess.Popen(cmd.split(' '), shell = False, **kwargs) + try: + p = subprocess.Popen(cmd.split(' '), shell = False, **kwargs) + except (IOError, OSError): + print("ERROR: Unsuccessful launch of process {!r}".format(cmd), file=sys.stderr) + raise processes.append(p) if necessary: necProcesses.append([p,name]) @@ -66,7 +72,7 @@ def main(args): try: # Launch the Server server = launch(serverCommand + serverOptions, name='server', - supressOutput=not args.verbose) + suppressOutput=not args.verbose) time.sleep(0.2) assert server.poll() is None,\ '[start.py] Failed to launch Server with command: \"%s\"' \ diff --git a/example/python_agents_3v3.sh b/example/python_agents_3v3.sh index 436a4d2..7d4215d 100755 --- a/example/python_agents_3v3.sh +++ b/example/python_agents_3v3.sh @@ -2,9 +2,10 @@ ./bin/HFO --offense-agents=2 --defense-npcs=3 --offense-npcs=1 --trials 20 --headless & sleep 5 -/usr/bin/python2.7 ./example/high_level_custom_agent.py --numTeammates=2 --numOpponents=3 --port 6000 &> agent1.txt & +# -x is needed to skip first line - otherwise whatever default python version is will run +python2.7 -x ./example/high_level_custom_agent.py --numTeammates=2 --numOpponents=3 --port 6000 &> agent1.txt & sleep 5 -/usr/bin/python3 ./example/high_level_custom_agent.py --numTeammates=2 --numOpponents=3 --port 6000 &> agent2.txt & +python3 -x ./example/high_level_custom_agent.py --numTeammates=2 --numOpponents=3 --port 6000 &> agent2.txt & # The magic line # $$ holds the PID for this script diff --git a/setup.py b/setup.py index 5d25f8d..290a7a7 100644 --- a/setup.py +++ b/setup.py @@ -26,8 +26,16 @@ setup(name = 'hfo', 'Development Status :: 4 - Beta', 'Intended Audience :: Science/Research', 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', + 'Operating System :: OS Independent', # except for shell scripts + 'Programming Language :: C++', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.2', # not tested + 'Programming Language :: Python :: 3.3', # not tested + 'Programming Language :: Python :: 3.4', # not tested + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', # not tested ], + requires=['numpy'], # packages=find_packages(), packages=['hfo'], package_dir={'hfo': 'hfo'}, -- 2.24.1