diff --git a/developer/bake_config.py b/developer/bake_config.py index 590cfb7524..abe7a8a77b 100644 --- a/developer/bake_config.py +++ b/developer/bake_config.py @@ -31,6 +31,7 @@ from tank.descriptor import create_descriptor, is_descriptor_version_missing from tank.descriptor.errors import TankDescriptorError from tank.bootstrap import constants as bootstrap_constants +from shotgun_api3 import ShotgunError import functools from utils import ( @@ -293,7 +294,7 @@ def main(): # make sure we are properly connected try: sg_connection.find_one("HumanUser", []) - except Exception as e: + except ShotgunError as e: logger.error("Could not communicate with ShotGrid: %s" % e) return 3 diff --git a/hooks/get_current_login.py b/hooks/get_current_login.py index 78870b5aec..9169c71ecd 100644 --- a/hooks/get_current_login.py +++ b/hooks/get_current_login.py @@ -54,5 +54,6 @@ def execute(self, **kwargs): pwd_entry = pwd.getpwuid(os.geteuid()) return pwd_entry[0] - except: + except Exception: + self.logger.debug("GetCurrentLogin hook failed.", exc_info=True) return None diff --git a/python/tank/api.py b/python/tank/api.py index a2cdc01782..429eacbca5 100644 --- a/python/tank/api.py +++ b/python/tank/api.py @@ -282,7 +282,8 @@ def documentation_url(self): data = str(data.get("documentation_url")) if data == "": data = None - except Exception: + except Exception as e: + log.debug("Cant get documentation url: %s" %e) data = None return data diff --git a/python/tank/authentication/interactive_authentication.py b/python/tank/authentication/interactive_authentication.py index 3e1df9f8b4..3207fd9233 100644 --- a/python/tank/authentication/interactive_authentication.py +++ b/python/tank/authentication/interactive_authentication.py @@ -68,7 +68,8 @@ def _get_current_os_user(): pwd_entry = pwd.getpwuid(os.geteuid()) return pwd_entry[0] - except: + except Exception as e: + logger.debug("Cant get current user: %s" %e) return None diff --git a/python/tank/authentication/session_cache.py b/python/tank/authentication/session_cache.py index 7b6683667c..fe936b3043 100644 --- a/python/tank/authentication/session_cache.py +++ b/python/tank/authentication/session_cache.py @@ -599,6 +599,6 @@ def generate_session_token(hostname, login, password, http_proxy, auth_token=Non # If the error message is empty, like httplib.HTTPException, convert # the class name to a string if len(str(e)) == 0: - raise Exception("Unknown error: %s" % type(e).__name__) + raise type(e)("Unknown error: %s" % type(e).__name__) else: raise diff --git a/python/tank/commands/cache_yaml.py b/python/tank/commands/cache_yaml.py index b299f4c093..c653b7b0ab 100644 --- a/python/tank/commands/cache_yaml.py +++ b/python/tank/commands/cache_yaml.py @@ -86,7 +86,7 @@ def _run(self, log): try: fh = open(pickle_path, "wb") - except Exception as e: + except OSError as e: raise TankError("Unable to open '%s' for writing: %s" % (pickle_path, e)) try: diff --git a/python/tank/commands/clone_configuration.py b/python/tank/commands/clone_configuration.py index 12742daa1f..b576f1a047 100644 --- a/python/tank/commands/clone_configuration.py +++ b/python/tank/commands/clone_configuration.py @@ -280,7 +280,7 @@ def _do_clone( fh.write("# End of file.\n") fh.close() - except Exception as e: + except OSError as e: raise TankError("Could not create file system structure: %s" % e) # lastly, update the pipeline_configuration.yml file diff --git a/python/tank/commands/console_utils.py b/python/tank/commands/console_utils.py index 4aee97d8d0..9b18753c7d 100644 --- a/python/tank/commands/console_utils.py +++ b/python/tank/commands/console_utils.py @@ -228,7 +228,7 @@ def _get_configuration_recursive( param_name, answer, ) - except Exception as e: + except TankError as e: log.error("Validation failed: %s" % e) else: input_valid = True diff --git a/python/tank/commands/dump_config.py b/python/tank/commands/dump_config.py index f6eeaa86e3..02e11fc153 100644 --- a/python/tank/commands/dump_config.py +++ b/python/tank/commands/dump_config.py @@ -213,7 +213,7 @@ def _run(self, log, params): log.info( "Environment written to: %s" % (os.path.abspath(params["file"])) ) - except Exception as e: + except TankError as e: import traceback traceback.print_exc() @@ -244,7 +244,7 @@ def _get_file_handle(self, params): ) try: fh = open(path, "w") - except Exception as e: + except OSError as e: raise TankError( "Unable to open file: %s\n" " Error reported: %s" % (path, e) ) diff --git a/python/tank/commands/install.py b/python/tank/commands/install.py index ed5066b59c..d1be9c1036 100644 --- a/python/tank/commands/install.py +++ b/python/tank/commands/install.py @@ -226,7 +226,7 @@ def _run(self, log, env_name, engine_instance_name, app_name, preserve_yaml): env_name, writable=True ) env.set_yaml_preserve_mode(preserve_yaml) - except Exception as e: + except TankError as e: raise TankError( "Environment '%s' could not be loaded! Error reported: %s" % (env_name, e) @@ -528,7 +528,7 @@ def _run(self, log, env_name, engine_name, preserve_yaml): env_name, writable=True ) env.set_yaml_preserve_mode(preserve_yaml) - except Exception as e: + except TankError as e: raise TankError( "Environment '%s' could not be loaded! Error reported: %s" % (env_name, e) diff --git a/python/tank/commands/misc.py b/python/tank/commands/misc.py index 1174225965..4208d44df5 100644 --- a/python/tank/commands/misc.py +++ b/python/tank/commands/misc.py @@ -70,8 +70,8 @@ def _run(self, log): log.debug("Deleting cache file %s..." % full_path) try: os.remove(full_path) - except: - log.warning("Could not delete cache file '%s'!" % full_path) + except OSError as e: + log.warning("Could not delete cache file '%s'! // %s" % (full_path, e)) log.info("The SG menu cache has been cleared.") @@ -137,7 +137,7 @@ def run_interactive(self, log, args): readline.parse_and_bind("bind ^I rl_complete") else: readline.parse_and_bind("tab: complete") - except: - pass + except Exception as e: + msg.append(e) code.interact(banner="\n".join(msg), local=tk_locals) diff --git a/python/tank/commands/move_pc.py b/python/tank/commands/move_pc.py index c63b7274f1..60121b64f7 100644 --- a/python/tank/commands/move_pc.py +++ b/python/tank/commands/move_pc.py @@ -48,7 +48,7 @@ def _cleanup_old_location(self, log, path): log.debug("Removing %s..." % full_path) try: os.remove(full_path) - except Exception as e: + except OSError as e: log.warning( "Could not delete file %s. Error Reported: %s" % (full_path, e) @@ -68,7 +68,7 @@ def _cleanup_old_location(self, log, path): log.debug("Deleting folder %s..." % full_path) try: os.rmdir(full_path) - except Exception as e: + except OSError as e: log.warning( "Could not remove folder %s. Error Reported: %s" % (full_path, e) @@ -272,7 +272,7 @@ def run_interactive(self, log, args): fh.write("# End of file.\n") fh.close() - except Exception as e: + except OSError as e: raise TankError( "Could not copy configuration! This may be because of system " "permissions or system setup. This configuration will " diff --git a/python/tank/commands/push_pc.py b/python/tank/commands/push_pc.py index 49b2654e78..4275e3d14c 100644 --- a/python/tank/commands/push_pc.py +++ b/python/tank/commands/push_pc.py @@ -137,8 +137,8 @@ def run_interactive(self, log, args): raise TankError("Aborted by user.") try: target_pc_id = int(answer) - except: - raise TankError("Please enter a number!") + except ValueError as e: + raise TankError("Please enter a number! // %s" % e) self._run( log, @@ -230,7 +230,7 @@ def _run(self, log, target_id, use_symlink=False): for env_name in self.tk.pipeline_configuration.get_environments(): try: env = self.tk.pipeline_configuration.get_environment(env_name) - except Exception as e: + except TankError as e: raise TankError( "Failed to load environment %s," " run 'tank validate' for more details, got error: %s" diff --git a/python/tank/commands/setup_project.py b/python/tank/commands/setup_project.py index 0b19eda9f2..340de29b85 100644 --- a/python/tank/commands/setup_project.py +++ b/python/tank/commands/setup_project.py @@ -548,8 +548,8 @@ def _select_project(self, log, sg, show_initialized_projects): raise TankError("Aborted by user.") try: project_id = int(answer) - except: - raise TankError("Please enter a number!") + except ValueError as e: + raise TankError("Please enter a number! // %s" % e) if project_id not in [x["id"] for x in projs]: raise TankError("Id %d was not found in the list of projects!" % project_id) diff --git a/python/tank/commands/switch.py b/python/tank/commands/switch.py index dcfe5ce3bd..60fd2ea76d 100644 --- a/python/tank/commands/switch.py +++ b/python/tank/commands/switch.py @@ -143,7 +143,7 @@ def run_interactive(self, log, args): env_name, writable=True ) env.set_yaml_preserve_mode(preserve_yaml) - except Exception as e: + except TankError as e: raise TankError( "Environment '%s' could not be loaded! Error reported: %s" % (env_name, e) diff --git a/python/tank/descriptor/io_descriptor/appstore.py b/python/tank/descriptor/io_descriptor/appstore.py index 59fcad9d2a..c2949c436c 100644 --- a/python/tank/descriptor/io_descriptor/appstore.py +++ b/python/tank/descriptor/io_descriptor/appstore.py @@ -399,7 +399,7 @@ def get_changelog(self): summary = sg_version_data.get("description") url = sg_version_data.get("sg_detailed_release_notes").get("url") except Exception: - pass + log.exception("Cant get changelog.") return (summary, url) def _download_local(self, destination_path): diff --git a/python/tank/descriptor/io_descriptor/base.py b/python/tank/descriptor/io_descriptor/base.py index f53e9d4237..f4fb962539 100644 --- a/python/tank/descriptor/io_descriptor/base.py +++ b/python/tank/descriptor/io_descriptor/base.py @@ -260,7 +260,8 @@ def _find_latest_tag_by_pattern(self, version_numbers, pattern): for version_num in version_numbers: try: version_split = list(map(int, version_num[1:].split("."))) - except Exception: + except Exception as e: + log.debug(e) # this git tag is not on the expected form vX.Y.Z where X Y and Z are ints. skip. continue diff --git a/python/tank/descriptor/io_descriptor/downloadable.py b/python/tank/descriptor/io_descriptor/downloadable.py index 4580c0788c..1ec0a8ec1d 100644 --- a/python/tank/descriptor/io_descriptor/downloadable.py +++ b/python/tank/descriptor/io_descriptor/downloadable.py @@ -91,7 +91,7 @@ def open_write_location(self): target_parent = os.path.dirname(target) try: filesystem.ensure_folder_exists(target_parent) - except Exception as e: + except OSError as e: if not os.path.exists(target_parent): log.error("Failed to create directory %s: %s" % (target_parent, e)) raise TankDescriptorIOError( @@ -104,7 +104,7 @@ def open_write_location(self): # download completed without issue. Now create settings folder metadata_folder = self._get_metadata_folder(temporary_path) filesystem.ensure_folder_exists(metadata_folder) - except Exception as e: + except OSError as e: # something went wrong during the download, remove the temporary files. log.error( "Failed to download into path %s: %s. Attempting to remove it." @@ -141,7 +141,7 @@ def open_write_location(self): % target ) - except Exception as e: + except OSError as e: # if the target path already exists, this means someone else is either # moving things right now or have moved it already, so we are ok. @@ -188,7 +188,7 @@ def open_write_location(self): filesystem.safe_delete_folder(temporary_path) move_succeeded = True - except Exception as e: + except OSError as e: # something during the copy went wrong. Attempt to roll back the target # so we aren't left with any corrupt bundle cache items. if os.path.exists(target): diff --git a/python/tank/descriptor/io_descriptor/git.py b/python/tank/descriptor/io_descriptor/git.py index 8b60f6d17f..91ac082e28 100644 --- a/python/tank/descriptor/io_descriptor/git.py +++ b/python/tank/descriptor/io_descriptor/git.py @@ -34,7 +34,8 @@ def _can_hide_terminal(): subprocess.STARTF_USESHOWWINDOW subprocess.SW_HIDE return True - except Exception: + except AttributeError as e: + log.debug("Terminal cant be hidden: %s" % e) return False @@ -131,7 +132,7 @@ def _clone_then_execute_git_commands( log.debug("Checking that git exists and can be executed...") try: output = _check_output(["git", "--version"]) - except: + except SubprocessCalledProcessError: log.exception("Unexpected error:") raise TankGitError( "Cannot execute the 'git' command. Please make sure that git is " @@ -291,7 +292,7 @@ def has_remote_access(self): # clone repo into temp folder self._tmp_clone_then_execute_git_commands([], depth=1) log.debug("...connection established") - except Exception as e: + except (OSError, SubprocessCalledProcessError) as e: log.debug("...could not establish connection: %s" % e) can_connect = False return can_connect diff --git a/python/tank/descriptor/io_descriptor/git_branch.py b/python/tank/descriptor/io_descriptor/git_branch.py index a11db88f8b..943a8ea11f 100644 --- a/python/tank/descriptor/io_descriptor/git_branch.py +++ b/python/tank/descriptor/io_descriptor/git_branch.py @@ -10,11 +10,12 @@ import os import copy -from .git import IODescriptorGit, _check_output +from .git import IODescriptorGit, _check_output, TankGitError from ..errors import TankDescriptorError from ... import LogManager from tank_vendor import six +from ...util.process import SubprocessCalledProcessError log = LogManager.get_logger(__name__) @@ -119,7 +120,7 @@ def _is_latest_commit(self, version, branch): log.debug("Checking if the version is pointing to the latest commit...") try: output = _check_output(["git", "ls-remote", self._path, branch]) - except: + except SubprocessCalledProcessError: log.exception("Unexpected error:") raise TankGitError( "Cannot execute the 'git' command. Please make sure that git is " @@ -168,7 +169,7 @@ def _download_local(self, destination_path): ref=self._branch, is_latest_commit=is_latest_commit, ) - except Exception as e: + except (TankGitError, OSError, SubprocessCalledProcessError) as e: raise TankDescriptorError( "Could not download %s, branch %s, " "commit %s: %s" % (self._path, self._branch, self._version, e) @@ -215,7 +216,7 @@ def get_latest_version(self, constraint_pattern=None): ] git_hash = self._tmp_clone_then_execute_git_commands(commands) - except Exception as e: + except (TankGitError, OSError, SubprocessCalledProcessError) as e: raise TankDescriptorError( "Could not get latest commit for %s, " "branch %s: %s" % (self._path, self._branch, e) diff --git a/python/tank/descriptor/io_descriptor/git_tag.py b/python/tank/descriptor/io_descriptor/git_tag.py index c6a9f6ff19..996928bd25 100644 --- a/python/tank/descriptor/io_descriptor/git_tag.py +++ b/python/tank/descriptor/io_descriptor/git_tag.py @@ -11,11 +11,12 @@ import copy import re -from .git import IODescriptorGit +from .git import IODescriptorGit, TankGitError from ..errors import TankDescriptorError from ... import LogManager from tank_vendor import six +from ...util.process import SubprocessCalledProcessError log = LogManager.get_logger(__name__) @@ -145,7 +146,7 @@ def _download_local(self, destination_path): self._clone_then_execute_git_commands( destination_path, [], depth=1, ref=self._version ) - except Exception as e: + except (TankGitError, OSError, SubprocessCalledProcessError) as e: raise TankDescriptorError( "Could not download %s, " "tag %s: %s" % (self._path, self._version, e) ) @@ -222,7 +223,7 @@ def _fetch_tags(self): if m: git_tags.append(m.group(1)) - except Exception as e: + except (TankGitError, OSError, SubprocessCalledProcessError) as e: raise TankDescriptorError( "Could not get list of tags for %s: %s" % (self._path, e) ) diff --git a/python/tank/folder/folder_types/listfield.py b/python/tank/folder/folder_types/listfield.py index 5d3d9c3456..c7caaf111d 100644 --- a/python/tank/folder/folder_types/listfield.py +++ b/python/tank/folder/folder_types/listfield.py @@ -172,10 +172,10 @@ def _create_folders_impl(self, io_receiver, parent_path, sg_data): chunks = self._field_name.split(".") entity_type = chunks[1] field_name = chunks[2] - except: + except IndexError as e: msg = ( - "Folder creation error: Cannot resolve the field expression %s." - % self._field_name + "Folder creation error: Cannot resolve the field expression %s: %s" + % (self._field_name, e) ) raise TankError(msg) diff --git a/python/tank/hook.py b/python/tank/hook.py index 12b2502e75..01d6f5f66e 100644 --- a/python/tank/hook.py +++ b/python/tank/hook.py @@ -447,10 +447,10 @@ def some_method(self): try: engine = self.__parent.engine - except: + except Exception as e: raise TankError( "Cannot load framework %s for %r - it does not have a " - "valid engine property!" % (framework_instance_name, self.__parent) + "valid engine property! // %s" % (framework_instance_name, self.__parent, e) ) return framework.load_framework( diff --git a/python/tank/log.py b/python/tank/log.py index 65317cb624..c3bfe3848f 100644 --- a/python/tank/log.py +++ b/python/tank/log.py @@ -304,7 +304,7 @@ def doRollover(self): try: os.rename(self.baseFilename, temp_backup_name) - except: + except OSError: # It failed, so we'll simply append from now on. log.debug( "Cannot rotate log file '%s'. Logging will continue to this file, " @@ -319,7 +319,7 @@ def doRollover(self): # so doRollover can do its work. try: os.rename(temp_backup_name, self.baseFilename) - except: + except OSError: # For some reason we couldn't move the backup in its place. log.debug( "Unexpected issue while rotating log file '%s'. Logging will continue to this file, " @@ -344,7 +344,7 @@ def doRollover(self): # disable rollover and append to the current log. try: RotatingFileHandler.doRollover(self) - except: + except OSError: # Something probably failed trying to rollover the backups, # since the code above proved that in theory the main log file # should be renamable. In any case, we didn't succeed in renaming, diff --git a/python/tank/pipelineconfig_utils.py b/python/tank/pipelineconfig_utils.py index 0ab344816d..6838fc4b6b 100644 --- a/python/tank/pipelineconfig_utils.py +++ b/python/tank/pipelineconfig_utils.py @@ -260,6 +260,7 @@ def get_core_path_for_config(pipeline_config_path): studio_folder = os.path.normpath(studio_folder) return studio_folder except Exception: + logger.debug("Cant get core path for config %s" % pipeline_config_path, exc_info=True) return None @@ -472,6 +473,7 @@ def _get_version_from_manifest(info_yml_path): data = yaml_cache.g_yaml_cache.get(info_yml_path, deepcopy_data=False) or {} data = str(data.get("version", "unknown")) except Exception: + logger.debug("Cant get version from manifest %s" % info_yml_path, exc_info=True) data = "unknown" return data diff --git a/python/tank/platform/bundle.py b/python/tank/platform/bundle.py index 86576c0925..5b4f8cb904 100644 --- a/python/tank/platform/bundle.py +++ b/python/tank/platform/bundle.py @@ -1065,7 +1065,8 @@ def _get_engine_name(self): # therefore get an error. try: engine_name = self.engine.name - except: + except AttributeError as e: + self.logger.debug("Cant get engine name: %s" % e) engine_name = None return engine_name diff --git a/python/tank/platform/qt/tankqdialog.py b/python/tank/platform/qt/tankqdialog.py index 2bac56427b..44a31d84ec 100644 --- a/python/tank/platform/qt/tankqdialog.py +++ b/python/tank/platform/qt/tankqdialog.py @@ -361,8 +361,8 @@ def _format_context_property(p, show_type=False): context_info += "You are currently running in the %s environment." % ( self._bundle.engine.environment["name"] ) - except: - pass + except Exception as e: + context_info += "Cant get current engine environment name: %s" % e self.ui.app_work_area_info.setText(context_info) diff --git a/python/tank/util/login.py b/python/tank/util/login.py index 442cb3776d..0a4894dc08 100644 --- a/python/tank/util/login.py +++ b/python/tank/util/login.py @@ -14,11 +14,12 @@ """ import os -import sys from . import constants from .platforms import is_windows +from .. import LogManager +log = LogManager.get_logger(__name__) def get_login_name(): """ @@ -34,7 +35,8 @@ def get_login_name(): pwd_entry = pwd.getpwuid(os.geteuid()) return pwd_entry[0] - except: + except Exception as e: + log.debug("Cant get login name: %s" % e) return None diff --git a/python/tank/util/metrics.py b/python/tank/util/metrics.py index 2662788143..403ef65563 100644 --- a/python/tank/util/metrics.py +++ b/python/tank/util/metrics.py @@ -30,9 +30,12 @@ # use api json to cover py 2.5 from tank_vendor import shotgun_api3, six +from .. import LogManager json = shotgun_api3.shotgun.json +log = LogManager.get_logger(__name__) + # From Python 3.8 and later, platform.linux_distribution has been removed, # so we need something else. Fortunately, the functionality was preserved # as the distro package on pypi.org. Given that the functionality is @@ -80,7 +83,8 @@ def get_darwin_version(cls): # For macOS / OSX we keep only the Major.minor os_version = re.findall(r"\d*\.\d*", raw_version_str)[0] - except: + except Exception: + log.debug("Cant get Darwin version.", exc_info=True) pass return os_version @@ -104,7 +108,9 @@ def get_linux_version(cls): major_version_str = re.findall(r"\d*", raw_version_str)[0] os_version = "%s %s" % (distribution, major_version_str) - except: + + except Exception: + log.debug("Cant get Linux version.", exc_info=True) pass return os_version @@ -124,7 +130,8 @@ def get_windows_version(cls): # as it returns a friendly name e.g: XP, 7, 10 etc. os_version = platform.release() - except: + except Exception: + log.debug("Cant get Windows version.", exc_info=True) pass return os_version @@ -169,9 +176,10 @@ def get_platform_info(cls): else: os_info["OS"] = "Unsupported system: (%s)" % (system) - except: + + except Exception: # On any exception we fallback to default value - pass + log.debug("Cant get platform info.", exc_info=True) # Cache information to save on subsequent calls cls.__cached_platform_info = os_info @@ -251,8 +259,8 @@ def log(self, metric, log_once=False): # remember that we've logged this one already self.__logged_metrics.add(metric_identifier) - except: - pass + except Exception as e: + log.debug(e) finally: self._lock.release() @@ -283,8 +291,8 @@ def get_metrics(self, count=None): # would be nice to be able to pop N from deque. oh well. metrics = [self._queue.popleft() for i in range(0, count)] - except: - pass + except Exception as e: + log.debug(e) finally: self._lock.release() @@ -443,7 +451,7 @@ def run(self): break except Exception as e: - pass + log.debug(e) finally: # wait, checking for halt event before more processing self._halt_event.wait(self.DISPATCH_INTERVAL) @@ -732,8 +740,8 @@ def log(cls, group, name, properties=None, log_once=False, bundle=None): from sgtk.platform.util import current_bundle bundle = current_bundle() - except: - pass + except Exception as e: + log.debug(e) if not bundle: # Still no bundle? Fallback to engine @@ -742,9 +750,8 @@ def log(cls, group, name, properties=None, log_once=False, bundle=None): from ..platform.engine import current_engine bundle = current_engine() - except: - # Bailing out trying to guess bundle - pass + except Exception as e: + log.debug(e) if bundle: # Add base properties to specified properties (if any) diff --git a/python/tank/util/pyside2_patcher.py b/python/tank/util/pyside2_patcher.py index c20df2bcb2..489098243a 100644 --- a/python/tank/util/pyside2_patcher.py +++ b/python/tank/util/pyside2_patcher.py @@ -21,8 +21,9 @@ import subprocess import webbrowser -from .. import constants +from .. import constants, LogManager from .platforms import is_linux, is_macos, is_windows +log = LogManager.get_logger(__name__) class PySide2Patcher(object): @@ -326,7 +327,8 @@ def openUrl(cls, url): # returns False or raises some error. try: return webbrowser.open_new_tab(url.toString().encode("utf-8")) - except: + except Exception as e: + log.debug(e) return False @classmethod diff --git a/python/tank/util/qt_importer.py b/python/tank/util/qt_importer.py index 90785e0b65..b03c443ed4 100644 --- a/python/tank/util/qt_importer.py +++ b/python/tank/util/qt_importer.py @@ -364,13 +364,15 @@ def _import_modules(self, interface_version_requested): logger.debug("Imported PySide2 as PySide.") return pyside2 except ImportError as e: + logger.debug("Cant import PySide2 as PySide: %s" % e) pass elif interface_version_requested == self.QT5: try: pyside2 = self._import_pyside2() logger.debug("Imported PySide2.") return pyside2 - except ImportError: + except ImportError as e: + logger.debug("Cant import PySide2: %s" % e) pass # We do not test for PyQt5 since it is supported on Python 3 only at the moment. @@ -381,7 +383,8 @@ def _import_modules(self, interface_version_requested): pyside = self._import_pyside() logger.debug("Imported PySide1.") return pyside - except ImportError: + except ImportError as e: + logger.debug("Cant import PySide1: %s" % e) pass # Now try PyQt4 @@ -390,7 +393,8 @@ def _import_modules(self, interface_version_requested): pyqt = self._import_pyqt4() logger.debug("Imported PyQt4.") return pyqt - except ImportError: + except ImportError as e: + logger.debug("Cant import PyQt4: %s" % e) pass logger.debug("No Qt matching that interface was found.") diff --git a/python/tank/util/shotgun/publish_util.py b/python/tank/util/shotgun/publish_util.py index af3576b480..ed324f168c 100644 --- a/python/tank/util/shotgun/publish_util.py +++ b/python/tank/util/shotgun/publish_util.py @@ -52,7 +52,8 @@ def get_entity_type_display_name(tk, entity_type_code): try: if entity_type_code in schema_data: display_name = schema_data[entity_type_code]["name"]["value"] - except: + except Exception as e: + log.exception("Cant get entity type display name %s" % entity_type_code) pass return display_name diff --git a/setup.py b/setup.py index 4c98f175b9..84af847532 100644 --- a/setup.py +++ b/setup.py @@ -35,17 +35,15 @@ def get_version(): ["git", "describe", "--abbrev=0"], universal_newlines=True ).rstrip() return version_git - except: - # Blindly ignore problems, git might be not available, or the user could - # be installing from zip archive, etc... - pass - - # If everything fails, return a sensible string highlighting that the version - # couldn't be extracted. If a version is not specified in `setup`, 0.0.0 - # will be used by default, it seems better to have an explicit keyword for - # this case, following TK "dev" locator pattern and the convention described here: - # http://peak.telecommunity.com/DevCenter/setuptools#specifying-your-project-s-version - return "dev" + except Exception as e: + print(e) + print("Fallback on `dev` version") + # If everything fails, return a sensible string highlighting that the version + # couldn't be extracted. If a version is not specified in `setup`, 0.0.0 + # will be used by default, it seems better to have an explicit keyword for + # this case, following TK "dev" locator pattern and the convention described here: + # http://peak.telecommunity.com/DevCenter/setuptools#specifying-your-project-s-version + return "dev" # Retrieve long description and licence from external files diff --git a/tests/platform_tests/test_application.py b/tests/platform_tests/test_application.py index 91234ac7b5..b19da07481 100644 --- a/tests/platform_tests/test_application.py +++ b/tests/platform_tests/test_application.py @@ -21,9 +21,8 @@ from tank_test.tank_test_base import * import tank from tank.errors import TankError, TankHookMethodDoesNotExistError -from tank.platform import application, constants, validation +from tank.platform import application, validation from tank.template import Template -from tank.deploy import descriptor from tank_vendor import six from tank_vendor.six import StringIO diff --git a/tests/python/tank_test/tank_test_base.py b/tests/python/tank_test/tank_test_base.py index 5f52b6f71a..5a29cf3653 100644 --- a/tests/python/tank_test/tank_test_base.py +++ b/tests/python/tank_test/tank_test_base.py @@ -94,9 +94,8 @@ def _is_git_missing(): try: sgtk.util.process.subprocess_check_output(["git", "--version"]) git_missing = False - except Exception: - # no git! - pass + except Exception as e: + print("Git not found: %s" % e) return git_missing