Commit cf73106f authored by Rick Gruber-Riemer's avatar Rick Gruber-Riemer

Clean-up of troubleshoot module

parent c484ab24
#!/usr/bin/env python
"""check tools.stats after running any of osm2city's modules and show troubleshooting
"""Checks tools.stats after running any of osm2city's modules and shows troubleshooting
hints if we detect problems.
"""
import logging
import textwrap
import parameters
import logging
from pdb import pm
import tools
class Troubleshoot():
class Troubleshoot:
def __init__(self):
self.msg = ""
self.n_problems = 0
......@@ -16,16 +18,16 @@ class Troubleshoot():
def skipped_no_elev(self):
self.n_problems += 1
msg = "%i. Some objects were skipped because we could not obtain their elevation.\n" % self.n_problems
msg += "You are using ELEV_MODE = %s.\n" % parameters.ELEV_MODE
if parameters.ELEV_MODE == "FgelevCaching":
msg += textwrap.dedent("""
You're using ELEV_MODE = FgelevCaching. Make sure
Make sure
- you have FG's scenery tiles for your area installed
- PATH_TO_SCENERY is correct\n
""")
else:
parameters.ELEV_MODE == "Manual"
elif parameters.ELEV_MODE == "Manual":
msg += textwrap.dedent("""
You're using ELEV_MODE = Manual. Consider using ELEV_MODE = FgelevCaching if
Consider using ELEV_MODE = FgelevCaching if
you run FG >= 3.2 and have >= 4GB RAM. If that is not feasible, make sure
- you have FG's scenery tiles for your area installed
- your bounding box BOUNDARY_NORTH, _EAST etc. is big enough to cover all your
......@@ -33,14 +35,18 @@ class Troubleshoot():
on the clipping options used when you obtained the OSM file, it may contain
data well outside your bounding box.\n
""")
else:
msg += "Unfortunately not all elevation data is available. consider using ELEV_MODE = FgelevCaching."
return msg
def skipped_no_texture(self):
self.n_problems += 1
msg = "%i. Some objects were skipped because we could not find a matching texture.\n\n" % self.n_problems
return msg
def troubleshoot(stats):
"""Analyzes statistics from tools.Stats objects and prints out logging information"""
msg = ""
t = Troubleshoot()
if stats.skipped_no_elev:
......@@ -52,13 +58,9 @@ def troubleshoot(stats):
logging.warn("We've detected %i problem(s):\n\n%s" % (t.n_problems, msg))
class Stats:
"""a fake stats object for testing"""
skipped_no_elev = 1
skipped_texture = 1
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
stats = Stats()
stats = tools.Stats()
stats.skipped_no_elev = 1
stats.skipped_texture = 1
troubleshoot(stats)
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment