Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfixes and support for current Adobe Substance Painter versions #20

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
8 changes: 3 additions & 5 deletions config/env/includes/frameworks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ frameworks:
# unrealqt - PySide build for Unreal (Windows-only)
tk-framework-unrealqt_v1.x.x:
location:
type: git_branch
path: https://github.com/shotgunsoftware/tk-framework-unrealqt.git
branch: master
version: 58c2f7b

type: git
path: https://github.com/ue4plugins/tk-framework-unrealqt.git
version: v1.2.3
32 changes: 6 additions & 26 deletions engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def refresh_engine(scene_name, prev_context):
# and construct the new context for this path:
tk = tank.tank_from_path(new_path)
ctx = tk.context_from_path(new_path, prev_context)
except tank.TankError, e:
except tank.TankError as e:
try:
# could not detect context from path, will use the project context
# for menus if it exists
Expand All @@ -154,7 +154,7 @@ def refresh_engine(scene_name, prev_context):
)
engine.show_warning(message)

except tank.TankError, e:
except tank.TankError as e:
(exc_type, exc_value, exc_traceback) = sys.exc_info()
message = ""
message += "Shotgun Substance Painter Engine cannot be started:.\n"
Expand Down Expand Up @@ -462,7 +462,7 @@ def pre_app_init(self):
raise tank.TankError(msg)

if painter_version > painter_min_supported_version:
# show a warning that this version of Substance Painter isn't yet fully tested
# log a warning that this version of Substance Painter isn't yet fully tested
# with Shotgun:
msg = (
"The Shotgun Pipeline Toolkit has not yet been fully "
Expand All @@ -472,26 +472,6 @@ def pre_app_init(self):
"\n\n" % (painter_version)
)

# determine if we should show the compatibility warning dialog:
show_warning_dlg = self.has_ui and SHOW_COMP_DLG not in os.environ

if show_warning_dlg:
# make sure we only show it once per session
os.environ[SHOW_COMP_DLG] = "1"

# check against the compatibility_dialog_min_version
# setting
min_version_str = self.get_setting("compatibility_dialog_min_version")

min_version = to_new_version_system(min_version_str)
if painter_version < min_version:
show_warning_dlg = False

if show_warning_dlg:
# Note, title is padded to try to ensure dialog isn't insanely
# narrow!
self.show_warning(msg)

# always log the warning to the script editor:
self.logger.warning(msg)

Expand Down Expand Up @@ -612,7 +592,7 @@ def _run_app_instance_commands(self):
# Build a dictionary mapping app instance names to dictionaries of
# commands they registered with the engine.
app_instance_commands = {}
for (cmd_name, value) in self.commands.iteritems():
for (cmd_name, value) in self.commands.items():
app_instance = value["properties"].get("app")
if app_instance:
# Add entry 'command name: command function' to the command
Expand Down Expand Up @@ -644,7 +624,7 @@ def _run_app_instance_commands(self):
else:
if not setting_cmd_name:
# Run all commands of the given app instance.
for (cmd_name, command_function) in cmd_dict.iteritems():
for (cmd_name, command_function) in cmd_dict.items():
msg = (
"%s startup running app '%s' command '%s'.",
self.name,
Expand Down Expand Up @@ -756,7 +736,7 @@ def close_windows(self):
# the original dialog list.
self.logger.debug("Closing dialog %s.", dialog_window_title)
dialog.close()
except Exception, exception:
except Exception as exception:
traceback.print_exc()
self.logger.error(
"Cannot close dialog %s: %s", dialog_window_title, exception
Expand Down
22 changes: 14 additions & 8 deletions hooks/tk-multi-publish2/basic/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def settings(self):
},
"Publish Textures as Folder": {
"type": "bool",
"default": True,
"default": False,
"description": "Publish Substance Painter textures as a folder."
"If true (default) textures will be all exported"
" together as a folder publish."
Expand Down Expand Up @@ -102,11 +102,17 @@ def process_current_session(self, settings, parent_item):
item = self.collect_current_substancepainter_session(settings, parent_item)

if item:
publish_as_folder_setting = settings.get("Publish Textures as Folder")
if publish_as_folder_setting and publish_as_folder_setting.value:
resource_items = self.collect_textures_as_folder(settings, item)
else:
resource_items = self.collect_textures(settings, item)

# TO FIX
# THIS DOES NOT SEEM TO WORK!
# publish_as_folder_setting = settings.get("Publish Textures as Folder")
# if publish_as_folder_setting and publish_as_folder_setting.value:
# resource_items = self.collect_textures_as_folder(settings, item)
# else:
# resource_items = self.collect_textures(settings, item)

# HARDCODE to publish textures as individual published files
resource_items = self.collect_textures(settings, item)

def get_export_path(self, settings):
publisher = self.parent
Expand Down Expand Up @@ -204,8 +210,8 @@ def collect_textures(self, settings, parent_item):

icon_path = os.path.join(self.disk_location, os.pardir, "icons", "texture.png")

for texture_set_name, texture_set in map_export_info.iteritems():
for texture_id, texture_file in texture_set.iteritems():
for texture_set_name, texture_set in map_export_info.items():
for texture_id, texture_file in texture_set.items():
if os.path.exists(texture_file):
_, filenamefile = os.path.split(texture_file)
texture_name, _ = os.path.splitext(filenamefile)
Expand Down
2 changes: 1 addition & 1 deletion hooks/tk-multi-publish2/basic/publish_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def _session_path():
# get the path to the current file
path = engine.app.get_current_project_path()

if isinstance(path, unicode):
if not isinstance(path, str):
path = path.encode("utf-8")

return path
Expand Down
4 changes: 2 additions & 2 deletions hooks/tk-multi-publish2/basic/publish_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def _find_publishes(self, ctx, publish_name, publish_type):
sg_publishes = self.parent.shotgun.find(
publish_entity_type, filters, query_fields
)
except Exception, e:
except Exception as e:
self.logger.error(
"Failed to find publishes of type '%s', called '%s', for context %s: %s"
% (publish_name, publish_type, ctx, e)
Expand All @@ -383,7 +383,7 @@ def _export_path():
# get the path to the current file
path = engine.app.get_project_export_path()

if isinstance(path, unicode):
if not isinstance(path, str):
path = path.encode("utf-8")

return path
4 changes: 2 additions & 2 deletions hooks/tk-multi-publish2/basic/publish_textures.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def _find_publishes(self, ctx, publish_name, publish_type):
sg_publishes = self.parent.shotgun.find(
publish_entity_type, filters, query_fields
)
except Exception, e:
except Exception as e:
self.logger.error(
"Failed to find publishes of type '%s', called '%s', for context %s: %s"
% (publish_name, publish_type, ctx, e)
Expand All @@ -395,7 +395,7 @@ def _export_path():
# get the path to the current file
path = engine.app.get_project_export_path()

if isinstance(path, unicode):
if not isinstance(path, str):
path = path.encode("utf-8")

return path
2 changes: 1 addition & 1 deletion hooks/tk-multi-publish2/basic/start_version_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def _session_path():
# get the path to the current file
path = engine.app.get_current_project_path()

if isinstance(path, unicode):
if not isinstance(path, str):
path = path.encode("utf-8")

return path
Expand Down
2 changes: 1 addition & 1 deletion python/tk_substancepainter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import application
from . import application
from .menu_generation import MenuGenerator
12 changes: 8 additions & 4 deletions python/tk_substancepainter/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ def on_text_message_received(self, message):
message_id = jsonData.get("id")

# requesting data
if jsonData.has_key("method"):
if "method" in jsonData:
# self.log_debug("client: request detected: %s" % (message))
method = jsonData.get("method")
params = jsonData.get("params")
self.engine.process_request(method, **params)

if jsonData.has_key("result"):
if "result" in jsonData:
# self.log_debug("client: result detected: %s" % (message))
if message_id in self.callbacks:
# self.log_debug(
Expand Down Expand Up @@ -270,7 +270,7 @@ def get_map_export_information(self):
result = self.send_and_receive("GET_MAP_EXPORT_INFORMATION")
return result

def export_document_maps(self, destination):
def export_document_maps(self, preset, destination, format, mapInfo):
# This is a trick to wait until the async process of
# exporting textures finishes.
self.__export_results = None
Expand All @@ -283,7 +283,11 @@ def run_once_finished_exporting_maps(**kwargs):
)

self.log_debug("Starting map export...")
result = self.send_and_receive("EXPORT_DOCUMENT_MAPS", destination=destination)
self.send_and_receive("EXPORT_DOCUMENT_MAPS",
preset=preset,
destination=destination,
format=format,
mapInfo=mapInfo)

while self.__export_results is None:
self.log_debug("Waiting for maps to be exported ...")
Expand Down
2 changes: 1 addition & 1 deletion python/tk_substancepainter/menu_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def get_documentation_url_str(self):
app = self.properties["app"]
doc_url = app.documentation_url
# deal with nuke's inability to handle unicode. #fail
if doc_url.__class__ == unicode:
if not isinstance(doc_url, str):
doc_url = unicodedata.normalize("NFKD", doc_url).encode(
"ascii", "ignore"
)
Expand Down
5 changes: 1 addition & 4 deletions resources/plugins/shotgun_bridge/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,8 @@ PainterPlugin

function exportDocumentMaps(data)
{
var export_preset = alg.mapexport.getProjectExportPreset();
var export_options = alg.mapexport.getProjectExportOptions();
var export_path = data.destination;
server.sendCommand("EXPORT_STARTED", {});
var result = alg.mapexport.exportDocumentMaps(export_preset, export_path, export_options.fileFormat)
var result = alg.mapexport.exportDocumentMaps(data.preset, data.destination, data.format, data.mapInfo)
server.sendCommand("EXPORT_FINISHED", {map_infos:result});
return true;
}
Expand Down
8 changes: 4 additions & 4 deletions startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class SubstancePainterLauncher(SoftwareLauncher):

EXECUTABLE_TEMPLATES = {
"darwin": ["/Applications/Allegorithmic/Substance Painter.app"],
"win32": ["C:/Program Files/Allegorithmic/Substance Painter/Substance Painter.exe"],
"win32": ["C:/Program Files/Adobe/Adobe Substance 3D Painter/Adobe Substance 3D Painter.exe"],
"linux2": [
"/usr/Allegorithmic/Substance Painter",
"/usr/Allegorithmic/Substance_Painter/Substance Painter",
Expand Down Expand Up @@ -275,7 +275,7 @@ def prepare_launch(self, exec_path, args, file_to_open=None):
# Only the startup script, the location of python and potentially the file to open
# are needed.
args = ""
args = ["%s=%s" % (k, v) for k, v in required_env.iteritems()]
args = ["%s=%s" % (k, v) for k, v in required_env.items()]
args = '"&%s"' % "&".join(args)
logger.info("running %s" % args)

Expand All @@ -297,11 +297,11 @@ def prepare_launch(self, exec_path, args, file_to_open=None):
None, CSIDL_PERSONAL, None, SHGFP_TYPE_CURRENT, path_buffer
)

user_scripts_path = path_buffer.value + r"\Allegorithmic\Substance Painter\plugins"
user_scripts_path = path_buffer.value + r"\Adobe\Adobe Substance 3D Painter\plugins"

else:
user_scripts_path = os.path.expanduser(
r"~/Documents/Allegorithmic/Substance Painter/plugins"
r"~/Documents/Adobe/Adobe Substance 3D Painter/plugins"
)

ensure_scripts_up_to_date(resources_plugins_path, user_scripts_path)
Expand Down
6 changes: 3 additions & 3 deletions startup/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def start_toolkit_classic():
try:
# Deserialize the environment context
context = sgtk.context.deserialize(env_context)
except Exception, e:
except Exception as e:
msg = (
"Shotgun: Could not create context! Shotgun Pipeline Toolkit"
" will be disabled. Details: %s" % e
Expand All @@ -83,7 +83,7 @@ def start_toolkit_classic():
engine = sgtk.platform.start_engine(env_engine, context.sgtk, context)
logger.debug("Current engine '%s'" % sgtk.platform.current_engine())

except Exception, e:
except Exception as e:
msg = "Shotgun: Could not start engine. Details: %s" % e
etype, value, tb = sys.exc_info()
msg += "".join(traceback.format_exception(etype, value, tb))
Expand All @@ -100,7 +100,7 @@ def start_toolkit():
# Verify sgtk can be loaded.
try:
import sgtk
except Exception, e:
except Exception as e:
msg = "Shotgun: Could not import sgtk! Disabling for now: %s" % e
print(msg)
return
Expand Down