1 |
commit: b74f56d404379fa3d4e1a7256ddd0f14a34ecfc5 |
2 |
Author: Andrea Postiglione <andrea.postiglione <AT> gmail <DOT> com> |
3 |
AuthorDate: Sat Apr 2 13:26:37 2022 +0000 |
4 |
Commit: Andrea Postiglione <andrea.postiglione <AT> gmail <DOT> com> |
5 |
CommitDate: Sat Apr 2 13:26:37 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=b74f56d4 |
7 |
|
8 |
dev-python/pyagentx-0.4 first release |
9 |
|
10 |
Signed-off-by: Andrea Postiglione <andrea.postiglione <AT> gmail.com> |
11 |
|
12 |
dev-python/pyagentx/Manifest | 5 + |
13 |
dev-python/pyagentx/files/python3.patch | 255 ++++++++++++++++++++++++++++++++ |
14 |
dev-python/pyagentx/files/updater.patch | 27 ++++ |
15 |
dev-python/pyagentx/metadata.xml | 16 ++ |
16 |
dev-python/pyagentx/pyagentx-0.4.ebuild | 21 +++ |
17 |
5 files changed, 324 insertions(+) |
18 |
|
19 |
diff --git a/dev-python/pyagentx/Manifest b/dev-python/pyagentx/Manifest |
20 |
new file mode 100644 |
21 |
index 000000000..6037dcd45 |
22 |
--- /dev/null |
23 |
+++ b/dev-python/pyagentx/Manifest |
24 |
@@ -0,0 +1,5 @@ |
25 |
+AUX python3.patch 7481 BLAKE2B 2142c64935f067f88e7a59daa505a6ae4f44b5999191d43787fd9e2bddc6e79bf1a687c4ee341677958ba473f5f347a19a2ec0c09da3ab6049f2d3423c72ba50 SHA512 6b3a57c8bb5436b2a32970051a91d22f3c990aa52130c85ffc44a77413d424926f88f96426d2ce60b0123ee0b9b6a20c33fe485e591e048a7ac2783d97ad1a9b |
26 |
+AUX updater.patch 798 BLAKE2B 3e8ada0c8cef641b490cd797f8e610e7b6bc30443c65510d050cc8d0ca417fde58b2046ab2da6947cb8246c3bc36588e2936d5aaa76fd6c79a2a552d36d29a28 SHA512 d19e5647c9a0879908f93adf1d295f2ef4e35de48185824db6e0145cf78d85597a9f597fa2408aa1db009b100360fe5337f05a373e7c5b9ae9e8e5166f9d8f0e |
27 |
+DIST pyagentx-0.4.tar.gz 11353 BLAKE2B 1ae8197431a60651de61577d384ff3168ee2beb4bf6ce5cb2ccb4fbd9482f808c875301225e2d871e3fde94828e3291604f61e358570074b64af2271005e3f7f SHA512 2c13dc04b926fa0d6d7df24d577fc37d08440145adbc5e9ec45f99157da40d92afd7bd7e875e3d980b83330ee66ccde8649698cd967c150056db19cbbc4f7f6b |
28 |
+EBUILD pyagentx-0.4.ebuild 493 BLAKE2B a12f8e9d5ace3b69ca67edc5766d9e367e3c8761d3e42868c65f249712db57cd37a6408d0c70c48acd922f9c6a6f74226f3606a79aa620ad84ea4739b57ab7a8 SHA512 3a12026be830c0bf488d551e1819be58bdc39e69d1df99ab019317d90e1d37eb1d0fc595c8ad0cecc3a263867c98a5edbc24845d0a8e85ff06fd3e747d4369d6 |
29 |
+MISC metadata.xml 626 BLAKE2B c3db5c408e852c05ab7b0eee7feef9cd52d2f42b7180b4a1071087f94e5326bb7797d2865bc8cb0612a3537b4ea870a8e1010c5975c52127957bf3ca575b6546 SHA512 c3e9f17b07bb9f1ba849901a3697552dd015242f08856a156642532d7eec9180efc02d6af2846c5b211b7f71c1f79cc9c7d6ff40a783b6bc0c8a2d27f51e5f3b |
30 |
|
31 |
diff --git a/dev-python/pyagentx/files/python3.patch b/dev-python/pyagentx/files/python3.patch |
32 |
new file mode 100644 |
33 |
index 000000000..63ea7d1a6 |
34 |
--- /dev/null |
35 |
+++ b/dev-python/pyagentx/files/python3.patch |
36 |
@@ -0,0 +1,255 @@ |
37 |
+commit dd1f0e84f8e321789264aec5ada0f1cb4d9ac8af |
38 |
+Author: Ondrej Mular <omular@××××××.com> |
39 |
+Date: Tue Nov 21 08:40:55 2017 +0100 |
40 |
+ |
41 |
+ Port to python3 |
42 |
+ |
43 |
+diff --git a/pyagentx/__init__.py b/pyagentx/__init__.py |
44 |
+index efeef10..d4fd627 100644 |
45 |
+--- a/pyagentx/__init__.py |
46 |
++++ b/pyagentx/__init__.py |
47 |
+@@ -1,5 +1,10 @@ |
48 |
+ #!/usr/bin/env python |
49 |
+ # -*- coding: utf-8 -*- |
50 |
++from __future__ import ( |
51 |
++ absolute_import, |
52 |
++ division, |
53 |
++ print_function, |
54 |
++) |
55 |
+ |
56 |
+ import logging |
57 |
+ |
58 |
+diff --git a/pyagentx/agent.py b/pyagentx/agent.py |
59 |
+index b6c0e2a..2db39db 100644 |
60 |
+--- a/pyagentx/agent.py |
61 |
++++ b/pyagentx/agent.py |
62 |
+@@ -1,5 +1,10 @@ |
63 |
+ #!/usr/bin/env python |
64 |
+ # -*- coding: utf-8 -*- |
65 |
++from __future__ import ( |
66 |
++ absolute_import, |
67 |
++ division, |
68 |
++ print_function, |
69 |
++) |
70 |
+ |
71 |
+ # -------------------------------------------- |
72 |
+ import logging |
73 |
+@@ -11,8 +16,11 @@ logger.addHandler(NullHandler()) |
74 |
+ # -------------------------------------------- |
75 |
+ |
76 |
+ import time |
77 |
+-import Queue |
78 |
+ import inspect |
79 |
++try: |
80 |
++ import queue |
81 |
++except ImportError: |
82 |
++ import Queue as queue |
83 |
+ |
84 |
+ import pyagentx |
85 |
+ from pyagentx.updater import Updater |
86 |
+@@ -57,18 +65,18 @@ class Agent(object): |
87 |
+ pass |
88 |
+ |
89 |
+ def start(self): |
90 |
+- queue = Queue.Queue(maxsize=20) |
91 |
++ update_queue = queue.Queue(maxsize=20) |
92 |
+ self.setup() |
93 |
+ # Start Updaters |
94 |
+ for u in self._updater_list: |
95 |
+ logger.debug('Starting updater [%s]' % u['oid']) |
96 |
+ t = u['class']() |
97 |
+- t.agent_setup(queue, u['oid'], u['freq']) |
98 |
++ t.agent_setup(update_queue, u['oid'], u['freq']) |
99 |
+ t.start() |
100 |
+ self._threads.append(t) |
101 |
+ # Start Network |
102 |
+ oid_list = [u['oid'] for u in self._updater_list] |
103 |
+- t = Network(queue, oid_list, self._sethandlers) |
104 |
++ t = Network(update_queue, oid_list, self._sethandlers) |
105 |
+ t.start() |
106 |
+ self._threads.append(t) |
107 |
+ # Do nothing ... just wait for someone to stop you |
108 |
+diff --git a/pyagentx/network.py b/pyagentx/network.py |
109 |
+index 9711398..f30edad 100644 |
110 |
+--- a/pyagentx/network.py |
111 |
++++ b/pyagentx/network.py |
112 |
+@@ -1,5 +1,10 @@ |
113 |
+ #!/usr/bin/env python |
114 |
+ # -*- coding: utf-8 -*- |
115 |
++from __future__ import ( |
116 |
++ absolute_import, |
117 |
++ division, |
118 |
++ print_function, |
119 |
++) |
120 |
+ |
121 |
+ # -------------------------------------------- |
122 |
+ import logging |
123 |
+@@ -13,7 +18,10 @@ logger.addHandler(NullHandler()) |
124 |
+ import socket |
125 |
+ import time |
126 |
+ import threading |
127 |
+-import Queue |
128 |
++try: |
129 |
++ import queue |
130 |
++except ImportError: |
131 |
++ import Queue as queue |
132 |
+ |
133 |
+ import pyagentx |
134 |
+ from pyagentx.pdu import PDU |
135 |
+@@ -21,10 +29,10 @@ from pyagentx.pdu import PDU |
136 |
+ |
137 |
+ class Network(threading.Thread): |
138 |
+ |
139 |
+- def __init__(self, queue, oid_list, sethandlers): |
140 |
++ def __init__(self, update_queue, oid_list, sethandlers): |
141 |
+ threading.Thread.__init__(self) |
142 |
+ self.stop = threading.Event() |
143 |
+- self._queue = queue |
144 |
++ self._queue = update_queue |
145 |
+ self._oid_list = oid_list |
146 |
+ self._sethandlers = sethandlers |
147 |
+ |
148 |
+@@ -84,7 +92,7 @@ class Network(threading.Thread): |
149 |
+ update_oid = item['oid'] |
150 |
+ update_data = item['data'] |
151 |
+ # clear values with prefix oid |
152 |
+- for oid in self.data.keys(): |
153 |
++ for oid in list(self.data.keys()): |
154 |
+ if oid.startswith(update_oid): |
155 |
+ del(self.data[oid]) |
156 |
+ # insert updated value |
157 |
+@@ -94,7 +102,7 @@ class Network(threading.Thread): |
158 |
+ 'value':row['value']} |
159 |
+ # recalculate reverse index if data changed |
160 |
+ self.data_idx = sorted(self.data.keys(), key=lambda k: tuple(int(part) for part in k.split('.'))) |
161 |
+- except Queue.Empty: |
162 |
++ except queue.Empty: |
163 |
+ break |
164 |
+ |
165 |
+ |
166 |
+diff --git a/pyagentx/pdu.py b/pyagentx/pdu.py |
167 |
+index 0af8e82..ac02a77 100644 |
168 |
+--- a/pyagentx/pdu.py |
169 |
++++ b/pyagentx/pdu.py |
170 |
+@@ -1,5 +1,10 @@ |
171 |
+ #!/usr/bin/env python |
172 |
+ # -*- coding: utf-8 -*- |
173 |
++from __future__ import ( |
174 |
++ absolute_import, |
175 |
++ division, |
176 |
++ print_function, |
177 |
++) |
178 |
+ |
179 |
+ # -------------------------------------------- |
180 |
+ import logging |
181 |
+@@ -68,10 +73,11 @@ class PDU(object): |
182 |
+ |
183 |
+ |
184 |
+ def encode_octet(self, octet): |
185 |
++ octet = octet.encode("utf-8") |
186 |
+ buf = struct.pack('!L', len(octet)) |
187 |
+- buf += str(octet) |
188 |
++ buf += octet |
189 |
+ padding = ( 4 - ( len(octet) % 4 ) ) % 4 |
190 |
+- buf += chr(0)* padding |
191 |
++ buf += chr(0).encode() * padding |
192 |
+ return buf |
193 |
+ |
194 |
+ |
195 |
+@@ -107,7 +113,7 @@ class PDU(object): |
196 |
+ |
197 |
+ |
198 |
+ def encode(self): |
199 |
+- buf = '' |
200 |
++ buf = b'' |
201 |
+ if self.type == pyagentx.AGENTX_OPEN_PDU: |
202 |
+ # timeout |
203 |
+ buf += struct.pack('!BBBB', 5, 0, 0, 0) |
204 |
+@@ -169,7 +175,7 @@ class PDU(object): |
205 |
+ sub_ids.append(t[0]) |
206 |
+ oid = '.'.join(str(i) for i in sub_ids) |
207 |
+ return oid, ret['include'] |
208 |
+- except Exception, e: |
209 |
++ except Exception as e: |
210 |
+ logger.exception('Invalid packing OID header') |
211 |
+ logger.debug('%s' % pprint.pformat(self.decode_buf)) |
212 |
+ |
213 |
+@@ -196,7 +202,7 @@ class PDU(object): |
214 |
+ buf = self.decode_buf[:l] |
215 |
+ self.decode_buf = self.decode_buf[l+padding:] |
216 |
+ return buf |
217 |
+- except Exception, e: |
218 |
++ except Exception as e: |
219 |
+ logger.exception('Invalid packing octet header') |
220 |
+ |
221 |
+ |
222 |
+@@ -204,7 +210,7 @@ class PDU(object): |
223 |
+ try: |
224 |
+ vtype,_ = struct.unpack('!HH', self.decode_buf[:4]) |
225 |
+ self.decode_buf = self.decode_buf[4:] |
226 |
+- except Exception, e: |
227 |
++ except Exception as e: |
228 |
+ logger.exception('Invalid packing value header') |
229 |
+ oid,_ = self.decode_oid() |
230 |
+ if vtype in [pyagentx.TYPE_INTEGER, pyagentx.TYPE_COUNTER32, pyagentx.TYPE_GAUGE32, pyagentx.TYPE_TIMETICKS]: |
231 |
+@@ -252,7 +258,7 @@ class PDU(object): |
232 |
+ context = self.decode_octet() |
233 |
+ logger.debug('Context: %s' % context) |
234 |
+ return ret |
235 |
+- except Exception, e: |
236 |
++ except Exception as e: |
237 |
+ logger.exception('Invalid packing: %d' % len(self.decode_buf)) |
238 |
+ logger.debug('%s' % pprint.pformat(self.decode_buf)) |
239 |
+ |
240 |
+diff --git a/pyagentx/sethandler.py b/pyagentx/sethandler.py |
241 |
+index 30a2db5..97839b2 100644 |
242 |
+--- a/pyagentx/sethandler.py |
243 |
++++ b/pyagentx/sethandler.py |
244 |
+@@ -1,5 +1,10 @@ |
245 |
+ #!/usr/bin/env python |
246 |
+ # -*- coding: utf-8 -*- |
247 |
++from __future__ import ( |
248 |
++ absolute_import, |
249 |
++ division, |
250 |
++ print_function, |
251 |
++) |
252 |
+ |
253 |
+ # -------------------------------------------- |
254 |
+ import logging |
255 |
+diff --git a/pyagentx/updater.py b/pyagentx/updater.py |
256 |
+index 5fb06d4..711f87e 100644 |
257 |
+--- a/pyagentx/updater.py |
258 |
++++ b/pyagentx/updater.py |
259 |
+@@ -1,5 +1,10 @@ |
260 |
+ #!/usr/bin/env python |
261 |
+ # -*- coding: utf-8 -*- |
262 |
++from __future__ import ( |
263 |
++ absolute_import, |
264 |
++ division, |
265 |
++ print_function, |
266 |
++) |
267 |
+ |
268 |
+ # -------------------------------------------- |
269 |
+ import logging |
270 |
+@@ -12,7 +17,11 @@ logger.addHandler(NullHandler()) |
271 |
+ |
272 |
+ import time |
273 |
+ import threading |
274 |
+-import Queue |
275 |
++try: |
276 |
++ import queue |
277 |
++except ImportError: |
278 |
++ import Queue as queue |
279 |
++ |
280 |
+ |
281 |
+ import pyagentx |
282 |
+ |
283 |
+@@ -39,7 +48,7 @@ class Updater(threading.Thread): |
284 |
+ self.update() |
285 |
+ self._queue.put_nowait({'oid': self._oid, |
286 |
+ 'data':self._data}) |
287 |
+- except Queue.Full: |
288 |
++ except queue.Full: |
289 |
+ logger.error('Queue full') |
290 |
+ except: |
291 |
+ logger.exception('Unhandled update exception') |
292 |
|
293 |
diff --git a/dev-python/pyagentx/files/updater.patch b/dev-python/pyagentx/files/updater.patch |
294 |
new file mode 100644 |
295 |
index 000000000..6c0b9c4ab |
296 |
--- /dev/null |
297 |
+++ b/dev-python/pyagentx/files/updater.patch |
298 |
@@ -0,0 +1,27 @@ |
299 |
+commit 1f0337b2d481d16936a4921498fe67614687bd38 |
300 |
+Author: Mohammed Alshohayeb <moshohayeb@×××××.com> |
301 |
+Date: Tue Jun 30 14:40:00 2015 +0300 |
302 |
+ |
303 |
+ permit remote descendants of Updater to be useable |
304 |
+ |
305 |
+diff --git a/pyagentx/agent.py b/pyagentx/agent.py |
306 |
+index 173a966..b6c0e2a 100644 |
307 |
+--- a/pyagentx/agent.py |
308 |
++++ b/pyagentx/agent.py |
309 |
+@@ -12,6 +12,7 @@ logger.addHandler(NullHandler()) |
310 |
+ |
311 |
+ import time |
312 |
+ import Queue |
313 |
++import inspect |
314 |
+ |
315 |
+ import pyagentx |
316 |
+ from pyagentx.updater import Updater |
317 |
+@@ -30,7 +31,7 @@ class Agent(object): |
318 |
+ self._threads = [] |
319 |
+ |
320 |
+ def register(self, oid, class_, freq=10): |
321 |
+- if Updater not in class_.__bases__: |
322 |
++ if Updater not in inspect.getmro(class_): |
323 |
+ raise AgentError('Class given isn\'t an updater') |
324 |
+ # cleanup and test oid |
325 |
+ try: |
326 |
|
327 |
diff --git a/dev-python/pyagentx/metadata.xml b/dev-python/pyagentx/metadata.xml |
328 |
new file mode 100644 |
329 |
index 000000000..30cc8f236 |
330 |
--- /dev/null |
331 |
+++ b/dev-python/pyagentx/metadata.xml |
332 |
@@ -0,0 +1,16 @@ |
333 |
+<?xml version="1.0" encoding="UTF-8"?> |
334 |
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> |
335 |
+<pkgmetadata> |
336 |
+ <maintainer type="person"> |
337 |
+ <email>andrea.postiglione@×××××.com</email> |
338 |
+ <name>Andrea Postiglione</name> |
339 |
+ </maintainer> |
340 |
+ <longdescription lang="en"> |
341 |
+ Pcs is a Corosync and Pacemaker configuration tool. It permits users to easily view, modify and |
342 |
+ create Pacemaker based clusters. Pcs contains pcsd, a pcs daemon, which operates as a remote server |
343 |
+ for pcs and provides a web UI. |
344 |
+ </longdescription> |
345 |
+ <upstream> |
346 |
+ <remote-id type="github">ClusterLabs/pcs</remote-id> |
347 |
+ </upstream> |
348 |
+</pkgmetadata> |
349 |
|
350 |
diff --git a/dev-python/pyagentx/pyagentx-0.4.ebuild b/dev-python/pyagentx/pyagentx-0.4.ebuild |
351 |
new file mode 100644 |
352 |
index 000000000..10dfac0e2 |
353 |
--- /dev/null |
354 |
+++ b/dev-python/pyagentx/pyagentx-0.4.ebuild |
355 |
@@ -0,0 +1,21 @@ |
356 |
+# Copyright 1999-2022 Gentoo Authors |
357 |
+# Distributed under the terms of the GNU General Public License v2 |
358 |
+ |
359 |
+EAPI=8 |
360 |
+ |
361 |
+PYTHON_COMPAT=( python3_{7..10} ) |
362 |
+ |
363 |
+inherit distutils-r1 |
364 |
+ |
365 |
+DESCRIPTION="Python AgentX Implementation" |
366 |
+HOMEPAGE="https://github.com/hosthvo/pyagentx" |
367 |
+SRC_URI="https://github.com/hosthvo/pyagentx/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz" |
368 |
+ |
369 |
+LICENSE="BSD-2" |
370 |
+SLOT="0" |
371 |
+KEYWORDS="~amd64" |
372 |
+ |
373 |
+PATCHES="${FILESDIR}/updater.patch |
374 |
+ ${FILESDIR}/python3.patch" |
375 |
+ |
376 |
+distutils_enable_tests pytest |