Skip to content

Commit

Permalink
Merge pull request #115 from jokumo/more-debug-messages
Browse files Browse the repository at this point in the history
Error handling for RenderDoc module import
  • Loading branch information
eliemichel authored Dec 5, 2020
2 parents 513d7a9 + c9501ce commit abaa0d3
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 9 deletions.
43 changes: 35 additions & 8 deletions blender/MapsModelsImporter/google_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,30 @@
from .preferences import getPreferences

SCRIPT_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "google_maps_rd.py")

MSG_CONSOLE_DEBUG_OUTPUT = """\nPlease report to MapsModelsImporter developers providing the full console log with debug information.
First turn on debug output by activating the "Debug Info"-checkbox under Edit > Preferences > Add-ons > MapsModelsImporter
On Windows systems console log is accessible in Windows > Toggle System Console (right click to copy).
On Linux systems you have to run Blender from the console to get the debug output"""
MSG_INCORRECT_RDC = """Invalid RDC capture file. Please make sure that:
1. You are importing from Google Maps or Google Earth web
2. You were MOVING in the 3D view while taking the capture (you can use the Capture after delay button in RenderDoc).
Please report to MapsModelsImporter developers providing the .rdc file as well as the full console log.
Console log is accessible in Windows > Toggle System Console (right click to copy)."""
1. You are using the recommended RenderDoc Version for this AddOn
- RenderDoc Version 1.5 - 1.9 for MapsModelsImporter <= 0.3.2
- RenderDoc Version >= 1.10 for MapsModelsImporter >= 0.3.3
2. You are importing from Google Maps or Google Earth web
3. You were MOVING in the 3D view while taking the capture (you can use the "Capture after delay"-button in RenderDoc).
Before opening a new Issue on GitHub please download a working sample file to check if this works on your Computer.
Please be patient. If there's no error message it might still be loading.
It can take a minute or two to load it and Blender will get unresponsive during this time.
Find sample files here: https://github.com/eliemichel/MapsModelsImporter-samples
If it works with a sample file you most probably shouldn't open a new issue on GitHub but figure out how to use RenderDoc.
Find instructions about using RenderDoc by searching YouTube for "Capturing Google Maps with RenderDoc"
If the sample file doesn't work:""" + MSG_CONSOLE_DEBUG_OUTPUT
MSG_RDMODULE_NOT_FOUND = "Error: Can't find the RenderDoc Module." + MSG_CONSOLE_DEBUG_OUTPUT
MSG_RDMODULE_IMPORT_ERROR = "Error: Failed to load the RenderDoc Module." + MSG_CONSOLE_DEBUG_OUTPUT
MSG_UNKNOWN_ERROR = "Error: An unknown Error occurred!" + MSG_CONSOLE_DEBUG_OUTPUT

class MapsModelsImportError(Exception):
pass
Expand All @@ -54,14 +73,22 @@ def captureToFiles(context, filepath, prefix, max_blocks):
if pref.debug_info:
print("google_maps_rd returned:")
print(out.decode())
success = True
except subprocess.CalledProcessError as err:
if pref.debug_info:
print("\n==========================================================================================")
print("google_maps_rd failed and returned:")
print(err.output.decode())
success = False
if not success:
raise MapsModelsImportError(MSG_INCORRECT_RDC)
if err.returncode == 20: #error codes 20 and 21 are defined in google_maps_rd.py
ERROR_MESSAGE = MSG_RDMODULE_NOT_FOUND
elif err.returncode == 21:
ERROR_MESSAGE = MSG_RDMODULE_IMPORT_ERROR
elif err.returncode == 1:
ERROR_MESSAGE = MSG_INCORRECT_RDC
if pref.debug_info:
print(MSG_INCORRECT_RDC)
else:
ERROR_MESSAGE = MSG_UNKNOWN_ERROR + "\nReturncode: " + err.returncode
raise MapsModelsImportError(ERROR_MESSAGE)

# -----------------------------------------------------------------------------

Expand Down
26 changes: 25 additions & 1 deletion blender/MapsModelsImporter/google_maps_rd.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,34 @@
# This file is part of MapsModelsImporter, a set of addons to import 3D models
# from Maps services

MSG_RD_IMPORT_FAILED = """Error: Failed to load the RenderDoc Module. It however seems to exist.
This might be due to one of the following reasons:
- Your Blender version uses another version of python than used to build the RenderDoc Module
- An additional file required by the RenderDoc Module is missing (i.E. renderdoc.dll)
- Something completely different
Remember, you must use exactly the same version of python to load the RenderDoc Module as was used to build it.
Find more information about building the RenderDoc Module here: https://github.com/baldurk/renderdoc/blob/v1.x/docs/CONTRIBUTING/Compiling.md\n"""

import sys
import pickle
import struct
import renderdoc as rd

try:
import renderdoc as rd
except ModuleNotFoundError as err:
print("Error: Can't find the RenderDoc Module.")
print("sys.path contains the following paths:\n")
print(*sys.path, sep = "\n")
sys.exit(20)
except ImportError as err:
print(MSG_RD_IMPORT_FAILED)
print("sys.platform: ", sys.platform)
print("Python version: ",sys.version)
print("err.name: ",err.name)
print("err.path: ",err.path)
print("Error Message: ", err,"\n")
sys.exit(21)

from meshdata import MeshData, makeMeshData
from rdutils import CaptureWrapper
Expand Down

0 comments on commit abaa0d3

Please sign in to comment.