Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/modules/bl_ui_utils/bug_report_url.py
| Show All 12 Lines | |||||
| # You should have received a copy of the GNU General Public License | # You should have received a copy of the GNU General Public License | ||||
| # along with this program; if not, write to the Free Software Foundation, | # along with this program; if not, write to the Free Software Foundation, | ||||
| # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| # | # | ||||
| # ##### END GPL LICENSE BLOCK ##### | # ##### END GPL LICENSE BLOCK ##### | ||||
| # <pep8-80 compliant> | # <pep8-80 compliant> | ||||
| def url_prefill_from_blender(): | def url_prefill_from_blender(addon_info = None): | ||||
| import bpy | import bpy | ||||
| import bgl | import bgl | ||||
| import struct | import struct | ||||
| import platform | import platform | ||||
| import urllib.parse | import urllib.parse | ||||
| import io | import io | ||||
| fh = io.StringIO() | fh = io.StringIO() | ||||
| Show All 9 Lines | fh.write( | ||||
| "Graphics card: {!s} {!s} {!s}\n".format( | "Graphics card: {!s} {!s} {!s}\n".format( | ||||
| bgl.glGetString(bgl.GL_RENDERER), | bgl.glGetString(bgl.GL_RENDERER), | ||||
| bgl.glGetString(bgl.GL_VENDOR), | bgl.glGetString(bgl.GL_VENDOR), | ||||
| bgl.glGetString(bgl.GL_VERSION), | bgl.glGetString(bgl.GL_VERSION), | ||||
| ) | ) | ||||
| ) | ) | ||||
| fh.write( | fh.write( | ||||
| "\n" | "\n" | ||||
| "\n**Blender Version**\n" | "**Blender Version**\n" | ||||
| ) | ) | ||||
| fh.write( | fh.write( | ||||
| "Broken: version: {!s}, branch: {!s}, commit date: {!s} {!s}, hash: `rB{!s}`\n".format( | "Broken: version: {!s}, branch: {!s}, commit date: {!s} {!s}, hash: `rB{!s}`\n".format( | ||||
| bpy.app.version_string, | bpy.app.version_string, | ||||
| bpy.app.build_branch.decode('utf-8', 'replace'), | bpy.app.build_branch.decode('utf-8', 'replace'), | ||||
| bpy.app.build_commit_date.decode('utf-8', 'replace'), | bpy.app.build_commit_date.decode('utf-8', 'replace'), | ||||
| bpy.app.build_commit_time.decode('utf-8', 'replace'), | bpy.app.build_commit_time.decode('utf-8', 'replace'), | ||||
| bpy.app.build_hash.decode('ascii'), | bpy.app.build_hash.decode('ascii'), | ||||
| ) | ) | ||||
| ) | ) | ||||
| fh.write( | fh.write( | ||||
| "Worked: (optional)\n" | "Worked: (optional)\n" | ||||
| ) | |||||
| if addon_info: | |||||
| fh.write( | |||||
| "\n" | "\n" | ||||
| "**Addon Information**\n" | |||||
| ) | |||||
| fh.write(( | |||||
| "Name: {name} {version}\n" | |||||
| "Author: {author}\n").format(**addon_info) | |||||
| ) | |||||
| fh.write( | |||||
| "\n" | "\n" | ||||
| "**Short description of error**\n" | "**Short description of error**\n" | ||||
| "[Please fill out a short description of the error here]\n" | "[Please fill out a short description of the error here]\n" | ||||
| "\n" | "\n" | ||||
| "**Exact steps for others to reproduce the error**\n" | "**Exact steps for others to reproduce the error**\n" | ||||
| "[Please describe the exact steps needed to reproduce the issue]\n" | "[Please describe the exact steps needed to reproduce the issue]\n" | ||||
| "[Based on the default startup or an attached .blend file (as simple as possible)]\n" | "[Based on the default startup or an attached .blend file (as simple as possible)]\n" | ||||
| "\n" | "\n" | ||||
| ) | ) | ||||
| fh.seek(0) | fh.seek(0) | ||||
| form_number = 2 if addon_info else 1 | |||||
| return ( | return ( | ||||
| "https://developer.blender.org/maniphest/task/edit/form/1?description=" + | "https://developer.blender.org/maniphest/task/edit/form/%i?description=" % form_number + | ||||
brecht: It's not bug type, but the number of the form.
Since it's tied to this URL, I'd keep the code… | |||||
| urllib.parse.quote(fh.read()) | urllib.parse.quote(fh.read()) | ||||
| ) | ) | ||||
It's not bug type, but the number of the form.
Since it's tied to this URL, I'd keep the code close together and write it like this:
form_number = 2 if addon_info else 1 return ( "https://developer.blender.org/maniphest/task/edit/form/%i?description=" % form_number +