Skip to content

Commit

Permalink
invoke run.py using exec, instead of importing
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed May 14, 2018
1 parent 198b21a commit a0be39c
Show file tree
Hide file tree
Showing 16 changed files with 20 additions and 34 deletions.
3 changes: 1 addition & 2 deletions examples/Schelling/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from server import server

if __name__ == "__main__":
server.launch()
server.launch()
3 changes: 1 addition & 2 deletions examples/bank_reserves/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from bank_reserves.server import server

if __name__ == "__main__":
server.launch()
server.launch()
5 changes: 2 additions & 3 deletions examples/boid-flockers/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from flockers.server import server
from boidflockers.server import server

if __name__ == "__main__":
server.launch()
server.launch()
3 changes: 1 addition & 2 deletions examples/boltzmann_wealth_model/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from wealth_model.server import server

if __name__ == "__main__":
server.launch()
server.launch()
3 changes: 1 addition & 2 deletions examples/boltzmann_wealth_model_network/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from wealth_model.server import server

if __name__ == "__main__":
server.launch()
server.launch()
3 changes: 1 addition & 2 deletions examples/color_patches/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from color_patches.server import server

if __name__ == "__main__":
server.launch()
server.launch()
3 changes: 1 addition & 2 deletions examples/conways_game_of_life/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from game_of_life.server import server

if __name__ == "__main__":
server.launch()
server.launch()
3 changes: 1 addition & 2 deletions examples/epstein_civil_violence/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from civil_violence.server import server

if __name__ == "__main__":
server.launch()
server.launch()
3 changes: 1 addition & 2 deletions examples/forest_fire/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from forest_fire.server import server

if __name__ == "__main__":
server.launch()
server.launch()
3 changes: 1 addition & 2 deletions examples/hex_snowflake/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from hex_snowflake.server import server

if __name__ == "__main__":
server.launch()
server.launch()
3 changes: 1 addition & 2 deletions examples/pd_grid/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from pd_grid.server import server

if __name__ == "__main__":
server.launch()
server.launch()
3 changes: 1 addition & 2 deletions examples/shape_example/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from shape_model.server import launch_shape_model

if __name__ == "__main__":
launch_shape_model()
launch_shape_model()
3 changes: 1 addition & 2 deletions examples/sugarscape_cg/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from sugarscape.server import server

if __name__ == "__main__":
server.launch()
server.launch()
3 changes: 1 addition & 2 deletions examples/virus_on_network/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from virus_on_network.server import server

if __name__ == "__main__":
server.launch()
server.launch()
3 changes: 1 addition & 2 deletions examples/wolf_sheep/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from wolf_sheep.server import server

if __name__ == "__main__":
server.launch()
server.launch()
7 changes: 4 additions & 3 deletions mesa/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import sys
import os
import importlib
import click

PROJECT_PATH = click.Path(exists=True, file_okay=False, dir_okay=True, resolve_path=True)
Expand All @@ -21,5 +20,7 @@ def run(project):
'''
sys.path.insert(0, project)
os.chdir(project)
run = importlib.import_module('run')
run.server.launch()

with open("run.py") as f:
code = compile(f.read(), "run.py", 'exec')
exec(code, {}, {})

0 comments on commit a0be39c

Please sign in to comment.