aboutsummaryrefslogtreecommitdiff
path: root/Core/Scripts/System/ART_Reporter.py
blob: ed062a40ff9aeb70920f7dae8111277ac9da14de (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
from ThirdParty.Qt import QtGui, QtCore, QtWidgets
import maya.cmds as cmds
import utils
import System.interfaceUtils as interfaceUtils
import System.git_utils as git
reload(git)



windowTitle = "ARTv2: Report an Issue"
windowObject = "pyArtReporterWin"


class ART_Reporter(QtWidgets.QMainWindow):

    def __init__(self, parent = None):

        super(ART_Reporter, self).__init__(parent)

        #get the directory path of the tools
        settings = QtCore.QSettings("Epic Games", "ARTv2")
        self.toolsPath = settings.value("toolsPath")
        self.iconsPath = settings.value("iconPath")
        self.scriptPath = settings.value("scriptPath")
        self.projPath = settings.value("projectPath")


        #build the UI
        self.buildSettingsUi()


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    def buildSettingsUi(self):

        #fonts
        self.font = QtGui.QFont()
        self.font.setPointSize(10)
        self.font.setBold(False)

        self.fontSmall = QtGui.QFont()
        self.fontSmall .setPointSize(9)
        self.fontSmall .setBold(False)

        self.titleFont = QtGui.QFont()
        self.titleFont.setPointSize(40)
        self.titleFont.setBold(True)


        #load stylesheet
        styleSheetFile = utils.returnNicePath(self.toolsPath, "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
        f = open(styleSheetFile, "r")
        self.style = f.read()
        f.close()


        self.setStyleSheet(self.style)

        #size policies
        mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)

        #create the main widget
        self.mainWidget = QtWidgets.QWidget()
        self.mainWidget.setStyleSheet(self.style)
        self.mainWidget.setStyleSheet("background-color: rgb(0, 0, 0);, color: rgb(0,0,0);")
        self.setCentralWidget(self.mainWidget)

        #set qt object name
        self.setObjectName(windowObject)
        self.setWindowTitle(windowTitle)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        #create the mainLayout for the rig creator UI
        self.layout = QtWidgets.QVBoxLayout(self.mainWidget)

        self.resize(300, 600)
        self.setSizePolicy(mainSizePolicy)
        self.setMinimumSize(QtCore.QSize( 300, 600 ))
        self.setMaximumSize(QtCore.QSize( 300, 600 ))

        #create the QFrame
        self.frame = QtWidgets.QFrame()
        self.frame.setObjectName("epic")
        self.layout.addWidget(self.frame)
        self.widgetLayout = QtWidgets.QVBoxLayout(self.frame)


        #Title of Issue
        self.titleLayout = QtWidgets.QHBoxLayout()
        self.widgetLayout.addLayout(self.titleLayout)

        titleLabel = QtWidgets.QLabel("Title: ")
        self.titleLayout.addWidget(titleLabel)

        self.issueTitle = QtWidgets.QLineEdit()
        self.issueTitle.setPlaceholderText("Title of Issue")
        self.titleLayout.addWidget(self.issueTitle)
        self.issueTitle.setMinimumWidth(200)
        self.issueTitle.setMaximumWidth(200)

        #Type of Issue (from labels)
        self.labelLayout = QtWidgets.QHBoxLayout()
        self.widgetLayout.addLayout(self.labelLayout)

        typeLabel = QtWidgets.QLabel("Issue Type: ")
        self.labelLayout.addWidget(typeLabel)

        self.issueType = QtWidgets.QComboBox()
        self.labelLayout.addWidget(self.issueType)
        self.issueType.setMinimumWidth(200)
        self.issueType.setMaximumWidth(200)



        #Information
        summaryLabel = QtWidgets.QLabel("Summary: ")
        self.widgetLayout.addWidget(summaryLabel)

        infoText = QtWidgets.QTextEdit()
        infoText.setReadOnly(True)
        infoText.setEnabled(False)
        self.widgetLayout.addWidget(infoText)
        infoText.setMinimumHeight(60)
        infoText.setMaximumHeight(60)
        infoText.setTextColor(QtGui.QColor(120,120,120))
        infoText.append("(Please include any errors and stacktrace if applicable. Also include any reproduction steps if possible.)")

        self.issueInfo = QtWidgets.QTextEdit()
        self.widgetLayout.addWidget(self.issueInfo)
        self.issueInfo.setObjectName("light")
        #Create Issue
        self.createIssueBtn = QtWidgets.QPushButton("Create Issue")
        self.createIssueBtn.setObjectName("blueButton")
        self.widgetLayout.addWidget(self.createIssueBtn)
        self.createIssueBtn.clicked.connect(self.createIssue)

        self.credentials = git.getGitCreds()
        if self.credentials == None:
            git.gitCredsUI(self)
            self.credentials = git.getGitCreds()

        self.getLabels()

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    def getLabels(self):

        labels = self.githubInfo("label")
        ignoreLabel = ["wontfix", "duplicate", "invalid"]
        if labels != None:
            for label in labels:
                if label.name not in ignoreLabel:
                    self.issueType.addItem(label.name)


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    def createIssue(self):

        title = self.issueTitle.text()
        issueType = self.issueType.currentText()

        body = "User: " + str(self.credentials[0]) + "\n"
        body += "Maya Version: " + str(cmds.about(iv = True)) + "\n"
        body += "OS: " + str(cmds.about(os = True)) + "\n" + "\n"
        body += self.issueInfo.toPlainText()

        repo = self.githubInfo("repo")
        issueCreated = False
        try:
            issue = repo.create_issue(title, body)
            issue.set_labels(issueType)
            issueCreated = True

        except Exception, e:
            cmds.warning("unable to create issue. Error: " + str(e))
            self.close()
            return

        if issueCreated:
            msgBox = QtWidgets.QMessageBox()
            msgBox.setText("Your issue has been created")
            msgBox.setDetailedText("To view your issue, please visit:\nhttps://github.com/epicernst/Test/issues")
            ret = msgBox.exec_()
            self.close()



# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    def githubInfo(self, type):

        #github section
        # try:
        from ThirdParty.github import Github
        # except:
        #     cmds.warning("unable to import github module. You will not be able to create an issue")
        #     self.close()
        #     return

        repoOwner = "epicernst"
        try:
            g = Github(self.credentials[0], self.credentials[1])
            repo = g.get_user(repoOwner).get_repo("Test")
            labels = repo.get_labels()

            if type == "repo":
                return repo
            if type == "label":
                return labels
        except:
            return None
            pass




# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def run():

    if cmds.window("pyArtReporterWin", exists = True):
        cmds.deleteUI("pyArtReporterWin", wnd = True)

    gui = ART_Reporter(interfaceUtils.getMainWindow())
    gui.show()