Kiln » TortoiseHg » TortoiseHg
Clone URL:  
bugtraq.py
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
from ctypes import * import comtypes import pythoncom from comtypes import IUnknown, GUID, COMMETHOD, POINTER from comtypes.typeinfo import ITypeInfo from comtypes.client import CreateObject from comtypes.automation import _midlSAFEARRAY from _winreg import * class IBugTraqProvider(IUnknown): _iid_ = GUID("{298B927C-7220-423C-B7B4-6E241F00CD93}") _methods_ = [ COMMETHOD([], HRESULT, "ValidateParameters", (['in'], comtypes.c_long, "hParentWnd"), (['in'], comtypes.BSTR, "parameters"), (['out', 'retval'], POINTER(comtypes.c_int16), "pRetVal") ), COMMETHOD([], HRESULT, "GetLinkText", (['in'], comtypes.c_long, "hParentWnd"), (['in'], comtypes.BSTR, "parameters"), (['out', 'retval'], POINTER(comtypes.BSTR), "pRetVal") ), COMMETHOD([], HRESULT, "GetCommitMessage", (['in'], comtypes.c_long, "hParentWnd"), (['in'], comtypes.BSTR, "parameters"), (['in'], comtypes.BSTR, "commonRoot"), (['in'], _midlSAFEARRAY(comtypes.BSTR), "pathList"), (['in'], comtypes.BSTR, "originalMessage"), (['out', 'retval'], POINTER(comtypes.BSTR), "pRetVal") ) ] class IBugTraqProvider2(IBugTraqProvider): _iid_ = GUID("{C5C85E31-2F9B-4916-A7BA-8E27D481EE83}") _methods_ = [ COMMETHOD([], HRESULT, "GetCommitMessage2", (['in'], comtypes.c_long, "hParentWnd"), (['in'], comtypes.BSTR, "parameters"), (['in'], comtypes.BSTR, "commonURL"), (['in'], comtypes.BSTR, "commonRoot"), (['in'], _midlSAFEARRAY(comtypes.BSTR), "pathList"), (['in'], comtypes.BSTR, "originalMessage"), (['in'], comtypes.BSTR, "bugID"), (['out'], POINTER(comtypes.BSTR), "bugIDOut"), (['out'], POINTER(_midlSAFEARRAY(comtypes.BSTR)), "revPropNames"), (['out'], POINTER(_midlSAFEARRAY(comtypes.BSTR)), "revPropValues"), (['out', 'retval'], POINTER(comtypes.BSTR), "pRetVal") ), COMMETHOD([], HRESULT, "CheckCommit", (['in'], comtypes.c_long, "hParentWnd"), (['in'], comtypes.BSTR, "parameters"), (['in'], comtypes.BSTR, "commonURL"), (['in'], comtypes.BSTR, "commonRoot"), (['in'], _midlSAFEARRAY(comtypes.BSTR), "pathList"), (['in'], comtypes.BSTR, "commitMessage"), (['out', 'retval'], POINTER(comtypes.BSTR), "pRetVal") ), COMMETHOD([], HRESULT, "OnCommitFinished", (['in'], comtypes.c_long, "hParentWnd"), (['in'], comtypes.BSTR, "commonRoot"), (['in'], _midlSAFEARRAY(comtypes.BSTR), "pathList"), (['in'], comtypes.BSTR, "logMessage"), (['in'], comtypes.c_long, "revision"), (['out', 'retval'], POINTER(comtypes.BSTR), "pRetVal") ), COMMETHOD([], HRESULT, "HasOptions", (['out', 'retval'], POINTER(comtypes.c_int16), "pRetVal") ), COMMETHOD([], HRESULT, "ShowOptionsDialog", (['in'], comtypes.c_long, "hParentWnd"), (['in'], comtypes.BSTR, "parameters"), (['out', 'retval'], POINTER(comtypes.BSTR), "pRetVal") ) ] class BugTraq: #svnjiraguid = "{CF732FD7-AA8A-4E9D-9E15-025E4D1A7E9D}" def __init__(self, guid): self.guid = guid self.bugtr = None def _get_bugtraq_object(self): if self.bugtr == None: obj = CreateObject(self.guid) try: self.bugtr = obj.QueryInterface(IBugTraqProvider2) except COMError: return None return self.bugtr def get_commit_message(self, parameters, logmessage): commonurl = "" commonroot = "" bugid = "" bstrarray = _midlSAFEARRAY(comtypes.BSTR) pathlist = bstrarray.from_param(()) bugtr = self._get_bugtraq_object() if self.supports_bugtraq2_interface(): (bugid, revPropNames, revPropValues, newmessage) = bugtr.GetCommitMessage2( 0, parameters, commonurl, commonroot, pathlist, logmessage, bugid) else: newmessage = bugtr.GetCommitMessage( 0, parameters, commonroot, pathlist, logmessage) return newmessage def on_commit_finished(self, logmessage): if not self.supports_bugtraq2_interface(): return "" commonroot = "" bstrarray = _midlSAFEARRAY(comtypes.BSTR) pathlist = bstrarray.from_param(()) bugtr = self._get_bugtraq_object() errormessage = bugtr.OnCommitFinished(0, commonroot, pathlist, logmessage, 0) return errormessage def show_options_dialog(self, options): if not self.has_options(): return "" bugtr = self._get_bugtraq_object() options = bugtr.ShowOptionsDialog(0, options) return options def has_options(self): if not self.supports_bugtraq2_interface(): return False bugtr = self._get_bugtraq_object() return bugtr.HasOptions() != 0 def get_link_text(self, parameters): bugtr = self._get_bugtraq_object() return bugtr.GetLinkText(0, parameters) def supports_bugtraq2_interface(self): bugtr = self._get_bugtraq_object() try: bugtr.HasOptions() return True except (ValueError, AttributeError): return False def get_issue_plugins(): cm = pythoncom.CoCreateInstance(pythoncom.CLSID_StdComponentCategoriesMgr, None, pythoncom.CLSCTX_INPROC,pythoncom.IID_ICatInformation) CATID_BugTraqProvider = pythoncom.MakeIID( "{3494FA92-B139-4730-9591-01135D5E7831}") ret = [] enumerator = cm.EnumClassesOfCategories((CATID_BugTraqProvider,),()) while 1: try: clsid = enumerator.Next() if clsid == (): break except pythoncom.com_error: break ret.extend(clsid) return ret def get_plugin_name(clsid): key = OpenKey(HKEY_CLASSES_ROOT, r"CLSID\%s" % clsid) try: keyvalue = QueryValueEx(key, None)[0] except WindowsError: keyvalue = None key.Close() return keyvalue def get_issue_plugins_with_names(): pluginclsids = get_issue_plugins() keyandnames = [(key, get_plugin_name(key)) for key in pluginclsids] return [kn for kn in keyandnames if kn[1] is not None]