Skip to content

Commit

Permalink
feat: add error log and environment variable to the ticket
Browse files Browse the repository at this point in the history
update the GUI to support separate widget for error log
  • Loading branch information
alijafargholi committed Sep 27, 2018
1 parent c152fb2 commit 32b4555
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 28 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,7 @@ $RECYCLE.BIN/

# Windows shortcuts
*.lnk
.idea/inspectionProfiles/
.idea/vcs.xml
Pipfile
Pipfile.lock
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# Bug-Reporter App
A Shotgun app for submit ticket for reporting bugs and request.

![Bug Report](./resources/app_ui.png)

This app originally was created by
[Shotgun Software](https://www.shotgunsoftware.com/), I believe by
[Jeff Beeland](https://www.linkedin.com/in/jefferybeeland/), and was
demonstrated in [this video](https://www.youtube.com/watch?v=bT2WlQaJVmY). I
modified it a bit to accommodate my need in our studio.

### New Features
* Ability to add the _error_ messages
* Include the environment variable
* Include the current _engine_ and _context_

### Future Features
* Specify Ticket Type _ex: bug or feature_
* Specify the priority

### Icon
The Bug Icon is by youtube.com/AlfredoCreates & Flaticondesign.com from the
Noun Project
Binary file modified icon_256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 41 additions & 25 deletions python/app/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,32 @@
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.

import sgtk
import os
import sys
import threading
import tempfile
import re
import tempfile

import sgtk
# by importing QT from sgtk rather than directly, we ensure that
# the code will be compatible with both PySide and PyQt.
from sgtk.platform.qt import QtCore, QtGui

from .ui.dialog import Ui_Dialog

screen_grab = sgtk.platform.import_framework("tk-framework-qtwidgets", "screen_grab")
shotgun_fields = sgtk.platform.import_framework("tk-framework-qtwidgets", "shotgun_fields")
screen_grab = sgtk.platform.import_framework("tk-framework-qtwidgets",
"screen_grab")
shotgun_fields = sgtk.platform.import_framework("tk-framework-qtwidgets",
"shotgun_fields")


def show_dialog(app_instance):
"""
Shows the main dialog window.
"""
# in order to handle UIs seamlessly, each toolkit engine has methods for launching
# different types of windows. By using these methods, your windows will be correctly
# decorated and handled in a consistent fashion by the system.

# in order to handle UIs seamlessly, each toolkit engine has methods for
# launching different types of windows. By using these methods, your
# windows will be correctly decorated and handled in a consistent fashion
# by the system.

# we pass the dialog class to this method and leave the actual construction
# to be carried out by toolkit.
app_instance.engine.show_dialog("Report Bugs!", app_instance, AppDialog)
Expand All @@ -40,27 +43,27 @@ class AppDialog(QtGui.QWidget):
"""
Main application dialog window
"""

def __init__(self):
"""
Constructor
"""
# first, call the base class and let it do its thing.
QtGui.QWidget.__init__(self)
super(AppDialog, self).__init__()

# now load in the UI that was created in the UI designer
self.ui = Ui_Dialog()
self.ui.setupUi(self)

# most of the useful accessors are available through the Application class instance
# it is often handy to keep a reference to this. You can get it via the following method:

# most of the useful accessors are available through the Application
# class instance it is often handy to keep a reference to this. You can
# get it via the following method:
self._app = sgtk.platform.current_bundle()

# via the self._app handle we can for example access:
# - The engine, via self._app.engine
# - A Shotgun API instance, via self._app.shotgun
# - A tk API instance, via self._app.tk

self.ui.buttons.accepted.connect(self.create_ticket)
self.ui.buttons.rejected.connect(self.close)
self.ui.screen_grab.clicked.connect(self.screen_grab)
Expand All @@ -69,10 +72,10 @@ def __init__(self):
self._cc_widget = None

# The ShotgunFieldManager is a factory used to build widgets for fields
# associated with an entity type in Shotgun. It pulls down the schema from
# Shotgun asynchronously when the initialize method is called, so before
# we do that we need to hook up the signal it emits when it's done to our
# method that gets the widget we want and adds it to the UI.
# associated with an entity type in Shotgun. It pulls down the schema
# from Shotgun asynchronously when the initialize method is called, so
# before we do that we need to hook up the signal it emits when it's
# done to our method that gets the widget we want and adds it to the UI.
self._field_manager = shotgun_fields.ShotgunFieldManager(parent=self)
self._field_manager.initialized.connect(self._get_shotgun_fields)
self._field_manager.initialize()
Expand Down Expand Up @@ -117,12 +120,27 @@ def create_ticket(self):
"""
# Create the new Ticket entity, pulling the project from the current
# context, and the title, ticket body, and cc list from the UI.
context_info = "__Engine Name__: {}\n__Engine Version__: " \
"{}\n__Context__: {}".format(self._app.engine.name,
self._app.engine.version,
self._app.context)
environment_info = "\n".join(["{} = {}".format(env, value)
for env, value in os.environ.items()])
description = self.ui.ticket_body.toPlainText()
error_log = '```\n{}\n```'.format(self.ui.error_log.toPlainText())

ticket_body = "{}\n### Description \n{}\n ### Error Log\n{}\n " \
"### Environment Variable\n{}".format(context_info,
description,
error_log,
environment_info)

result = self._app.shotgun.create(
"Ticket",
dict(
project=self._app.context.project,
title=self.ui.ticket_title.text(),
description=self.ui.ticket_body.toPlainText(),
description=ticket_body,
addressings_cc=self._cc_widget.get_value(),
)
)
Expand All @@ -148,5 +166,3 @@ def create_ticket(self):
"Ticket #%s successfully submitted!" % result["id"],
)
self.close()


18 changes: 17 additions & 1 deletion python/app/ui/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(431, 392)
Dialog.resize(452, 490)
self.verticalLayout = QtGui.QVBoxLayout(Dialog)
self.verticalLayout.setObjectName("verticalLayout")
self.horizontalLayout_2 = QtGui.QHBoxLayout()
Expand All @@ -30,6 +30,9 @@ def setupUi(self, Dialog):
self.cc_label.setObjectName("cc_label")
self.cc_layout.addWidget(self.cc_label)
self.verticalLayout.addLayout(self.cc_layout)
self.label_2 = QtGui.QLabel(Dialog)
self.label_2.setObjectName("label_2")
self.verticalLayout.addWidget(self.label_2)
self.ticket_body = QtGui.QPlainTextEdit(Dialog)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
Expand All @@ -38,6 +41,17 @@ def setupUi(self, Dialog):
self.ticket_body.setSizePolicy(sizePolicy)
self.ticket_body.setObjectName("ticket_body")
self.verticalLayout.addWidget(self.ticket_body)
self.label_3 = QtGui.QLabel(Dialog)
self.label_3.setObjectName("label_3")
self.verticalLayout.addWidget(self.label_3)
self.error_log = QtGui.QPlainTextEdit(Dialog)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(1)
sizePolicy.setHeightForWidth(self.error_log.sizePolicy().hasHeightForWidth())
self.error_log.setSizePolicy(sizePolicy)
self.error_log.setObjectName("error_log")
self.verticalLayout.addWidget(self.error_log)
self.lower_layout = QtGui.QHBoxLayout()
self.lower_layout.setSpacing(5)
self.lower_layout.setContentsMargins(-1, 0, -1, -1)
Expand Down Expand Up @@ -67,6 +81,8 @@ def retranslateUi(self, Dialog):
Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Report a bug!", None, QtGui.QApplication.UnicodeUTF8))
self.label.setText(QtGui.QApplication.translate("Dialog", "Subject:", None, QtGui.QApplication.UnicodeUTF8))
self.cc_label.setText(QtGui.QApplication.translate("Dialog", "CC:", None, QtGui.QApplication.UnicodeUTF8))
self.label_2.setText(QtGui.QApplication.translate("Dialog", "Description:", None, QtGui.QApplication.UnicodeUTF8))
self.label_3.setText(QtGui.QApplication.translate("Dialog", "Error Log:", None, QtGui.QApplication.UnicodeUTF8))
self.screen_grab.setText(QtGui.QApplication.translate("Dialog", "Take a screenshot!", None, QtGui.QApplication.UnicodeUTF8))

from . import resources_rc
Binary file added resources/app_ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 26 additions & 2 deletions resources/dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>431</width>
<height>392</height>
<width>452</width>
<height>490</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -42,6 +42,13 @@
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Description:</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="ticket_body">
<property name="sizePolicy">
Expand All @@ -52,6 +59,23 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Error Log:</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="error_log">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="lower_layout">
<property name="spacing">
Expand Down

0 comments on commit 32b4555

Please sign in to comment.