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

SG-38064 Python 2 Removal #189

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.

from __future__ import print_function
import os
import sys
import optparse
Expand Down
2 changes: 1 addition & 1 deletion engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def show_panel(self, panel_id, title, bundle, widget_class, *args, **kwargs):
)
else:
# fall back on base class implementation
return super(DesktopEngine, self).show_panel(
return super().show_panel(
panel_id, title, bundle, widget_class, *args, **kwargs
)

Expand Down
2 changes: 1 addition & 1 deletion python/tk_desktop/banner_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, notifications_mgr, notification, parent=None):
:param notification: ``Notification`` instance to display.
:param parent: Parent widget
"""
super(BannerWidget, self).__init__(parent)
super().__init__(parent)

self.ui = Ui_BannerWidget()
self.ui.setupUi(self)
Expand Down
2 changes: 1 addition & 1 deletion python/tk_desktop/command_panel/base_icon_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, parent, layout):
:param parent: Parent widget.
:param layout: Qt layout for this widget.
"""
super(BaseIconList, self).__init__(parent)
super().__init__(parent)
self._layout = layout
self.setLayout(layout)
self._layout.setContentsMargins(0, 0, 0, 0)
6 changes: 2 additions & 4 deletions python/tk_desktop/command_panel/command_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from sgtk.deploy import util

from sgtk.platform.qt import QtCore, QtGui
from tank_vendor import six

from .shared import ICON_SIZE, BUTTON_STYLE

Expand Down Expand Up @@ -41,7 +40,7 @@ def __init__(self, parent, command_name, button_name, icon, tooltip):
:param str icon: Path to the icon.
:param str tooltip: Tooltip for the button.
"""
super(CommandButton, self).__init__(parent)
super().__init__(parent)
self.setSizePolicy(
QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.MinimumExpanding
)
Expand All @@ -61,8 +60,7 @@ def __init__(self, parent, command_name, button_name, icon, tooltip):
self._button_name = button_name
# The data of an action contains the command name.
self._menu.triggered.connect(
# The .data method returns a unicode string in Python 2, so force it to a utf8 str.
lambda action: self.command_triggered.emit(six.ensure_str(action.data()))
lambda action: self.command_triggered.emit(str(action.data()))
)

# This is a workaround for a PySide2 issue where the hover state of the button
Expand Down
2 changes: 1 addition & 1 deletion python/tk_desktop/command_panel/command_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, parent):
:param QtGui.QWidget: Parent widget.
"""
# The Commands are displayed on a grid.
super(CommandList, self).__init__(parent, QtGui.QGridLayout())
super().__init__(parent, QtGui.QGridLayout())
# The filler is a widget that prevents the button on the last row
# from taking up the whole row if there is only one.
self._filler = QtGui.QWidget(self)
Expand Down
12 changes: 2 additions & 10 deletions python/tk_desktop/command_panel/command_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
from .recent_section import RecentSection
from .command_section import CommandSection

try:
from tank_vendor import sgutils
except ImportError:
from tank_vendor import six as sgutils

TIME_STAMP_FORMAT = "%m/%d/%Y, %H:%M:%S"


Expand All @@ -45,7 +40,7 @@ def __init__(self, parent, settings):
:param parent: Parent widget.
:param settings: Settings object to persist and restore state.
"""
super(CommandPanel, self).__init__(parent)
super().__init__(parent)
# The app style sheet styles this widget so give it the proper name.
self.setObjectName("command_panel")
self._layout = QtGui.QVBoxLayout(self)
Expand Down Expand Up @@ -189,10 +184,7 @@ def _update_recents_list(self, command_name):
if self._show_recents is False:
return

# Make sure the string is a str and not unicode. This happens in
# Python 2.7.
command_name = sgutils.ensure_str(command_name)

command_name = str(command_name)
self._recents[command_name] = {"timestamp": datetime.utcnow()}
self._store_recents()
self._refresh_recent_list(command_name)
Expand Down
2 changes: 1 addition & 1 deletion python/tk_desktop/command_panel/command_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, name):
"""
:param str name: Name of the section.
"""
super(CommandSection, self).__init__(name, CommandList)
super().__init__(name, CommandList)

def add_command(
self, command_name, button_name, menu_name, icon, tooltip, is_menu_default
Expand Down
11 changes: 3 additions & 8 deletions python/tk_desktop/command_panel/recent_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@

from sgtk.platform.qt import QtGui, QtCore

try:
from tank_vendor import sgutils
except ImportError:
from tank_vendor import six as sgutils

from .shared import ICON_SIZE, BUTTON_STYLE, MAX_RECENTS


Expand All @@ -38,7 +33,7 @@ def __init__(self, parent, command_name, button_name, icon, tooltip, timestamp):
:param str tooltip: Toolkit for this command.
:param datetime.datetime timestamp: When the command was last launched.
"""
super(RecentButton, self).__init__(parent)
super().__init__(parent)

# No borders
self.setFlat(True)
Expand Down Expand Up @@ -81,15 +76,15 @@ def __init__(self, parent, command_name, button_name, icon, tooltip, timestamp):
self._command_name = command_name

self.clicked.connect(
lambda: self.command_triggered.emit(sgutils.ensure_str(self._command_name))
lambda: self.command_triggered.emit(str(self._command_name))
)

@property
def name(self):
"""
Name of the button.
"""
return sgutils.ensure_str(self.text_label.text())
return str(self.text_label.text())

@property
def timestamp(self):
Expand Down
2 changes: 1 addition & 1 deletion python/tk_desktop/command_panel/recent_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class RecentList(BaseIconList):
"""

def __init__(self, parent):
super(RecentList, self).__init__(parent, QtGui.QHBoxLayout())
super().__init__(parent, QtGui.QHBoxLayout())
self._layout.setSpacing(3)

# Fill the recents list with invisible stretchers to start with.
Expand Down
2 changes: 1 addition & 1 deletion python/tk_desktop/command_panel/recent_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class RecentSection(Section):
"""

def __init__(self):
super(RecentSection, self).__init__("Recent", RecentList)
super().__init__("Recent", RecentList)

def add_command(self, command_name, button_name, icon, tooltip, timestamp):
"""
Expand Down
2 changes: 1 addition & 1 deletion python/tk_desktop/command_panel/section.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, name, list_factory):
:param str name: Name of the section.
:param class list_factory: Class of the list widget to instantiate.
"""
super(Section, self).__init__(parent=None)
super().__init__(parent=None)

self._layout = QtGui.QVBoxLayout(self)
self.setLayout(self._layout)
Expand Down
2 changes: 1 addition & 1 deletion python/tk_desktop/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def emit(self, record):

class Console(QtGui.QDialog):
def __init__(self, parent=None):
super(Console, self).__init__(parent)
super().__init__(parent)

self.setWindowTitle("Flow Production Tracking Console")
self.setWindowIcon(QtGui.QIcon(":/tk-desktop/default_systray_icon.png"))
Expand Down
4 changes: 1 addition & 3 deletions python/tk_desktop/desktop_engine_project_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
Flow Production Tracking project-level engine implementation.
"""

from __future__ import with_statement

import time
import os
import sys
Expand Down Expand Up @@ -451,7 +449,7 @@ def _emit_log_message(self, handle, record):
msg = record.msg

# Do the string interpolation this side of the communication. This is important
# because Python 2 and 3 may serialize objects differently and Toolkit objects
# because Python may serialize objects differently and Toolkit objects
# may be coming from different versions of the API.
if record.args:
msg = msg % record.args
Expand Down
22 changes: 2 additions & 20 deletions python/tk_desktop/desktop_engine_site_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.

from __future__ import with_statement
import os
import re
import sys
Expand All @@ -18,17 +17,11 @@
from distutils.version import LooseVersion
import sgtk
from tank_vendor.shotgun_authentication import ShotgunAuthenticator, DefaultsManager
from tank_vendor import six

from sgtk import LogManager

from .site_communication import SiteCommunication

try:
from tank_vendor import sgutils
except ImportError:
from tank_vendor import six as sgutils

shotgun_globals = sgtk.platform.import_framework(
"tk-framework-shotgunutils", "shotgun_globals"
)
Expand Down Expand Up @@ -355,11 +348,7 @@ def project_commands_finished(self):
def _handle_button_command_triggered(self, name):
"""Button clicked from a registered command."""
self.refresh_user_credentials()
# Make sure the string is a str and not unicode. This happens in
# Python 2.7.
self.site_comm.call_no_response(
"trigger_callback", "__commands", sgutils.ensure_str(name)
)
self.site_comm.call_no_response("trigger_callback", "__commands", str(name))

# Leave app_version as is for backwards compatibility.
def run(self, splash, version, **kwargs):
Expand Down Expand Up @@ -533,14 +522,7 @@ def uses_legacy_authentication(self):

:returns: True the bootstrap logic is older than 1.1.0, False otherwise.
"""
# Desktop versions have been using the vX.Y.Z notation for a while now.
# While this didn't pose a problem when using a LooseVersion comparison
# to the X.Y.Z notation, in Python 3 this blows up.
#
# Since Python 3 builds of the PTR desktop app and greater do not support
# the legacy authentication, we'll test for Python 2 and return False
# automatically in Python 3 environments.
return six.PY2 and LooseVersion(self.app_version) < LooseVersion("1.1.0")
return LooseVersion(self.app_version) < LooseVersion("1.1.0")

def create_legacy_login_instance(self):
"""
Expand Down
3 changes: 1 addition & 2 deletions python/tk_desktop/desktop_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

from tank.platform.qt import QtCore, QtGui
from sgtk.platform import constants
from tank_vendor import six
import sgtk
from sgtk.util import shotgun
from sgtk.bootstrap import ToolkitManager
Expand Down Expand Up @@ -106,7 +105,7 @@ def __init__(self, parent, config_descriptor, toolkit_manager):
:param toolkit_manager: Configuration manager that will be used to bootstrap
this configuration.
"""
super(ConfigDownloadThread, self).__init__(parent)
super().__init__(parent)
self._config_descriptor = config_descriptor
self._toolkit_manager = toolkit_manager

Expand Down
25 changes: 0 additions & 25 deletions python/tk_desktop/licenses.html
Original file line number Diff line number Diff line change
Expand Up @@ -1320,31 +1320,6 @@
</pre>
</div>

<!-- six - 1.16.0 -->
<div>
<p><strong>six</strong></p>
<pre>
Copyright (c) 2010-2020 Benjamin Peterson

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
</pre>
</div>

<!-- urllib3-->
<div>
<p><strong>urllib3</strong></p>
Expand Down
2 changes: 1 addition & 1 deletion python/tk_desktop/loading_project_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, parent=None):
"""
:param parent: Parent widget.
"""
super(LoadingProjectWidget, self).__init__(parent)
super().__init__(parent)

self._ui = Ui_LoadingProjectWidget()
self._ui.setupUi(self)
Expand Down
2 changes: 1 addition & 1 deletion python/tk_desktop/project_synchronization_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, manager, project):
:param manager: ToolkitManager to prepare to prepare the engine with.
:param project: Project for which we require the engine to be prepared.
"""
super(ProjectSynchronizationThread, self).__init__()
super().__init__()
self._toolkit_manager = manager
self._toolkit_manager.progress_callback = self._report_progress
self._abort = False
Expand Down
Loading