genocide 232__tar.gz → 234__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- genocide-234/MANIFEST.in +1 -0
- {genocide-232 → genocide-234}/PKG-INFO +6 -2
- {genocide-232 → genocide-234}/README.rst +4 -0
- genocide-234/bin/genocide +1 -0
- genocide-234/genocide/booting.py +194 -0
- {genocide-232 → genocide-234}/genocide/brokers.py +23 -23
- genocide-234/genocide/command.py +77 -0
- genocide-234/genocide/configs.py +38 -0
- {genocide-232 → genocide-234}/genocide/encoder.py +21 -11
- {genocide-232 → genocide-234}/genocide/handler.py +75 -33
- genocide-234/genocide/modules/adm.py +54 -0
- genocide-234/genocide/modules/bsc.py +40 -0
- genocide-234/genocide/modules/cfg.py +49 -0
- genocide-232/genocide/modules/atr.py → genocide-234/genocide/modules/fie.py +7 -7
- {genocide-232 → genocide-234}/genocide/modules/flt.py +1 -1
- {genocide-232 → genocide-234}/genocide/modules/fnd.py +15 -0
- {genocide-232 → genocide-234}/genocide/modules/irc.py +38 -25
- genocide-234/genocide/modules/log.py +25 -0
- {genocide-232 → genocide-234}/genocide/modules/man.py +31 -20
- genocide-234/genocide/modules/mbx.py +90 -0
- {genocide-232 → genocide-234}/genocide/modules/mdl.py +13 -15
- {genocide-232 → genocide-234}/genocide/modules/pth.py +1 -1
- genocide-234/genocide/modules/pwd.py +18 -0
- {genocide-232 → genocide-234}/genocide/modules/req.py +2 -1
- {genocide-232 → genocide-234}/genocide/modules/rss.py +55 -46
- {genocide-232 → genocide-234}/genocide/modules/rst.py +4 -4
- {genocide-232 → genocide-234}/genocide/modules/slg.py +1 -1
- genocide-234/genocide/modules/tbl.py +93 -0
- {genocide-232 → genocide-234}/genocide/modules/tdo.py +4 -14
- {genocide-232 → genocide-234}/genocide/modules/tmr.py +28 -41
- {genocide-232 → genocide-234}/genocide/modules/udp.py +10 -6
- {genocide-232 → genocide-234}/genocide/modules/web.py +18 -15
- {genocide-232 → genocide-234}/genocide/modules/wsd.py +1 -2
- genocide-234/genocide/network/_images/abilifynew2.png +0 -0
- genocide-234/genocide/network/_images/clozapinenew2.png +0 -0
- genocide-234/genocide/network/_images/haloperidolnew2.png +0 -0
- genocide-234/genocide/network/_images/zyprexanew2.png +0 -0
- {genocide-232 → genocide-234}/genocide/network/_static/documentation_options.js +1 -1
- {genocide-232 → genocide-234}/genocide/network/_static/genocide.css +1 -1
- {genocide-232 → genocide-234}/genocide/network/_static/opensearch.xml +4 -4
- genocide-234/genocide/network/_static/otpcr.css +72 -0
- {genocide-232 → genocide-234}/genocide/network/_static/sitemap.xml +6 -6
- genocide-234/genocide/network/about.html +61 -0
- genocide-234/genocide/network/echa.html +68 -0
- {genocide-232 → genocide-234}/genocide/network/evidence.html +7 -7
- {genocide-232 → genocide-234}/genocide/network/genindex-all.html +2 -2
- {genocide-232 → genocide-234}/genocide/network/genindex.html +2 -2
- genocide-234/genocide/network/googlea6568bcc05c8d50b.html +1 -0
- {genocide-232 → genocide-234}/genocide/network/guilty.html +7 -6
- genocide-232/genocide/network/about.html → genocide-234/genocide/network/index.html +12 -11
- {genocide-232 → genocide-234}/genocide/network/manual.html +199 -63
- genocide-234/genocide/network/objects.inv +0 -0
- {genocide-232 → genocide-234}/genocide/network/pubchem.html +9 -9
- genocide-232/genocide/network/index.html → genocide-234/genocide/network/reconsider.html +10 -8
- genocide-232/genocide/network/reconsider.html → genocide-234/genocide/network/reconsider2.html +9 -7
- {genocide-232 → genocide-234}/genocide/network/request.html +6 -6
- genocide-234/genocide/network/robots.txt +4 -0
- {genocide-232 → genocide-234}/genocide/network/search.html +2 -2
- genocide-234/genocide/network/searchindex.js +1 -0
- genocide-234/genocide/network/writing.html +165 -0
- {genocide-232 → genocide-234}/genocide/network/writings.html +6 -6
- {genocide-232 → genocide-234}/genocide/objects.py +86 -63
- genocide-234/genocide/package.py +155 -0
- genocide-234/genocide/persist.py +225 -0
- genocide-234/genocide/runtime.py +141 -0
- {genocide-232 → genocide-234}/genocide/threads.py +38 -31
- {genocide-232 → genocide-234}/genocide/utility.py +108 -29
- {genocide-232 → genocide-234}/genocide.egg-info/PKG-INFO +6 -2
- {genocide-232 → genocide-234}/genocide.egg-info/SOURCES.txt +19 -4
- {genocide-232 → genocide-234}/pyproject.toml +3 -2
- genocide-232/genocide/command.py +0 -61
- genocide-232/genocide/defines.py +0 -42
- genocide-232/genocide/loggers.py +0 -38
- genocide-232/genocide/modules/log.py +0 -35
- genocide-232/genocide/modules/mbx.py +0 -133
- genocide-232/genocide/modules/upt.py +0 -17
- genocide-232/genocide/network/objects.inv +0 -0
- genocide-232/genocide/network/robots.txt +0 -2
- genocide-232/genocide/network/searchindex.js +0 -1
- genocide-232/genocide/package.py +0 -109
- genocide-232/genocide/persist.py +0 -233
- genocide-232/genocide/runtime.py +0 -377
- {genocide-232 → genocide-234}/genocide/modules/__init__.py +0 -0
- {genocide-232 → genocide-234}/genocide/modules/sil.py +0 -0
- {genocide-232 → genocide-234}/genocide/modules/thr.py +0 -0
- {genocide-232 → genocide-234}/genocide/modules/wdr.py +0 -0
- {genocide-232 → genocide-234}/genocide/network/_images/ECHAabilify.png +0 -0
- {genocide-232 → genocide-234}/genocide/network/_images/ECHAclozapine.png +0 -0
- {genocide-232 → genocide-234}/genocide/network/_images/ECHAhaldol.png +0 -0
- {genocide-232 → genocide-234}/genocide/network/_images/ECHAzyprexa.png +0 -0
- {genocide-232 → genocide-234}/genocide/network/_images/OTP111.png +0 -0
- {genocide-232 → genocide-234}/genocide/network/_images/OTP222.png +0 -0
- {genocide-232 → genocide-234}/genocide/network/_images/abilifypubchem.png +0 -0
- {genocide-232 → genocide-234}/genocide/network/_images/ack3.png +0 -0
- {genocide-232 → genocide-234}/genocide/network/_images/bevestigd.jpg +0 -0
- {genocide-232 → genocide-234}/genocide/network/_images/clozapinepubchem.png +0 -0
- {genocide-232 → genocide-234}/genocide/network/_images/genocide.png +0 -0
- {genocide-232 → genocide-234}/genocide/network/_images/haldolpubchem.png +0 -0
- {genocide-232 → genocide-234}/genocide/network/_images/informed.jpg +0 -0
- {genocide-232 → genocide-234}/genocide/network/_images/kamer2.png +0 -0
- {genocide-232 → genocide-234}/genocide/network/_images/skull3.png +0 -0
- {genocide-232 → genocide-234}/genocide/network/_images/zyprexapubchem.png +0 -0
- {genocide-232 → genocide-234}/genocide/network/_static/alabaster.css +0 -0
- {genocide-232 → genocide-234}/genocide/network/_static/basic.css +0 -0
- {genocide-232 → genocide-234}/genocide/network/_static/custom.css +0 -0
- {genocide-232 → genocide-234}/genocide/network/_static/doctools.js +0 -0
- {genocide-232 → genocide-234}/genocide/network/_static/file.png +0 -0
- {genocide-232 → genocide-234}/genocide/network/_static/language_data.js +0 -0
- {genocide-232 → genocide-234}/genocide/network/_static/minus.png +0 -0
- {genocide-232 → genocide-234}/genocide/network/_static/plus.png +0 -0
- {genocide-232 → genocide-234}/genocide/network/_static/pygments.css +0 -0
- {genocide-232 → genocide-234}/genocide/network/_static/searchtools.js +0 -0
- {genocide-232 → genocide-234}/genocide/network/_static/skull3.png +0 -0
- {genocide-232 → genocide-234}/genocide/network/_static/sphinx_highlight.js +0 -0
- {genocide-232 → genocide-234}/genocide/network/pdf/EM_Ack_OTP-CR-117_19.pdf +0 -0
- {genocide-232 → genocide-234}/genocide/network/pdf/EM_T04_OTP-CR-117_19.pdf +0 -0
- {genocide-232 → genocide-234}/genocide/network/pdf/EM_T07_OTP-CR-117_19_001.pdf +0 -0
- {genocide-232 → genocide-234}/genocide/network/pdf/Kamer.pdf +0 -0
- {genocide-232 → genocide-234}/genocide/network/pdf/Rome-Statute.pdf +0 -0
- {genocide-232 → genocide-234}/genocide/network/pdf/bevestigd.pdf +0 -0
- {genocide-232 → genocide-234}/genocide.egg-info/dependency_links.txt +0 -0
- {genocide-232 → genocide-234}/genocide.egg-info/entry_points.txt +0 -0
- {genocide-232 → genocide-234}/genocide.egg-info/top_level.txt +0 -0
- {genocide-232 → genocide-234}/setup.cfg +0 -0
genocide-234/MANIFEST.in
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include bin/genocide
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: genocide
|
|
3
|
-
Version:
|
|
4
|
-
Summary: Since 4
|
|
3
|
+
Version: 234
|
|
4
|
+
Summary: Since 4 March 2019.
|
|
5
5
|
Author-email: Bart Thate <bthate@dds.nl>
|
|
6
6
|
License-Expression: Unlicense
|
|
7
7
|
Project-URL: home, https://pypi.org/project/genocide
|
|
@@ -66,3 +66,7 @@ are poison at the time they voted for this law and the day the Wfz law took
|
|
|
66
66
|
effect (1-1-2019), i ask the prosecutor to prosecute the king for making the
|
|
67
67
|
commiting of the above mentioned crimes (killing, torture and impotent making)
|
|
68
68
|
possible.
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
**(*)** Since January 2026 the **ECHA** <European Chemical Agency> no longer shows a skull and bones when visited.
|
|
@@ -51,3 +51,7 @@ are poison at the time they voted for this law and the day the Wfz law took
|
|
|
51
51
|
effect (1-1-2019), i ask the prosecutor to prosecute the king for making the
|
|
52
52
|
commiting of the above mentioned crimes (killing, torture and impotent making)
|
|
53
53
|
possible.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
**(*)** Since January 2026 the **ECHA** <European Chemical Agency> no longer shows a skull and bones when visited.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
python3 -c "from genocide.runtime import main ; main()" $* ;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# This file is placed in the Public Domain.
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
"in the beginning"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import logging
|
|
8
|
+
import os
|
|
9
|
+
import pathlib
|
|
10
|
+
import sys
|
|
11
|
+
import time
|
|
12
|
+
import _thread
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from .command import Commands
|
|
16
|
+
from .configs import Main
|
|
17
|
+
from .package import Mods
|
|
18
|
+
from .persist import Disk, Workdir
|
|
19
|
+
from .threads import Thread
|
|
20
|
+
from .utility import Log, Utils
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class Boot:
|
|
24
|
+
|
|
25
|
+
inits = []
|
|
26
|
+
md5 = {}
|
|
27
|
+
path = os.path.dirname(__spec__.loader.path)
|
|
28
|
+
|
|
29
|
+
@classmethod
|
|
30
|
+
def banner(cls):
|
|
31
|
+
"hello."
|
|
32
|
+
tme = time.ctime(time.time()).replace(" ", " ")
|
|
33
|
+
print("%s since %s %s (%s)" % (
|
|
34
|
+
Main.name.upper(),
|
|
35
|
+
tme,
|
|
36
|
+
Main.level.upper() or "warning",
|
|
37
|
+
Utils.md5sum(Mods.path("tbl") or "")[:7],
|
|
38
|
+
))
|
|
39
|
+
sys.stdout.flush()
|
|
40
|
+
|
|
41
|
+
@classmethod
|
|
42
|
+
def check(cls, opts):
|
|
43
|
+
"check for command line options."
|
|
44
|
+
for arg in sys.argv:
|
|
45
|
+
if not arg.startswith("-"):
|
|
46
|
+
continue
|
|
47
|
+
for opt in opts:
|
|
48
|
+
if opt in arg:
|
|
49
|
+
return True
|
|
50
|
+
return False
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
def configure(cls, cfg):
|
|
54
|
+
"in the beginning."
|
|
55
|
+
Main.name = cfg.name or Main.name or Utils.pkgname(Boot)
|
|
56
|
+
if cfg.read:
|
|
57
|
+
Disk.read(Main, "main", "config")
|
|
58
|
+
Workdir.configure(cfg)
|
|
59
|
+
Log.configure(cfg)
|
|
60
|
+
Mods.configure(cfg)
|
|
61
|
+
if Main.all:
|
|
62
|
+
Main.mods = Mods.list()
|
|
63
|
+
if Main.noignore:
|
|
64
|
+
Main.ignore = ""
|
|
65
|
+
|
|
66
|
+
@classmethod
|
|
67
|
+
def daemon(cls, verbose=False, nochdir=False):
|
|
68
|
+
"run in the background."
|
|
69
|
+
pid = os.fork()
|
|
70
|
+
if pid != 0:
|
|
71
|
+
os._exit(0)
|
|
72
|
+
os.setsid()
|
|
73
|
+
pid2 = os.fork()
|
|
74
|
+
if pid2 != 0:
|
|
75
|
+
os._exit(0)
|
|
76
|
+
if not verbose:
|
|
77
|
+
with open('/dev/null', 'r', encoding="utf-8") as sis:
|
|
78
|
+
os.dup2(sis.fileno(), sys.stdin.fileno())
|
|
79
|
+
with open('/dev/null', 'a+', encoding="utf-8") as sos:
|
|
80
|
+
os.dup2(sos.fileno(), sys.stdout.fileno())
|
|
81
|
+
with open('/dev/null', 'a+', encoding="utf-8") as ses:
|
|
82
|
+
os.dup2(ses.fileno(), sys.stderr.fileno())
|
|
83
|
+
os.umask(0)
|
|
84
|
+
if not nochdir:
|
|
85
|
+
os.chdir("/")
|
|
86
|
+
os.nice(10)
|
|
87
|
+
|
|
88
|
+
@classmethod
|
|
89
|
+
def forever(cls):
|
|
90
|
+
"run forever until ctrl-c."
|
|
91
|
+
while True:
|
|
92
|
+
try:
|
|
93
|
+
time.sleep(0.1)
|
|
94
|
+
except (KeyboardInterrupt, EOFError):
|
|
95
|
+
break
|
|
96
|
+
|
|
97
|
+
@classmethod
|
|
98
|
+
def init(cls, cfg):
|
|
99
|
+
"scan named modules for commands."
|
|
100
|
+
thrs = []
|
|
101
|
+
for name, mod in Mods.iter(cfg.mods, cfg.ignore):
|
|
102
|
+
if "init" in dir(mod):
|
|
103
|
+
thrs.append((name, Thread.launch(mod.init)))
|
|
104
|
+
cls.inits.append(name)
|
|
105
|
+
if cfg.wait:
|
|
106
|
+
for name, thr in thrs:
|
|
107
|
+
thr.join()
|
|
108
|
+
|
|
109
|
+
@classmethod
|
|
110
|
+
def md5s(cls):
|
|
111
|
+
"set md5 sums."
|
|
112
|
+
cls.md5.update(Utils.md5dir(cls.path))
|
|
113
|
+
|
|
114
|
+
@staticmethod
|
|
115
|
+
def pidfile(name):
|
|
116
|
+
"write pidfile."
|
|
117
|
+
filename = os.path.join(Workdir.wdr, f"{name}.pid")
|
|
118
|
+
if os.path.exists(filename):
|
|
119
|
+
os.unlink(filename)
|
|
120
|
+
path2 = pathlib.Path(filename)
|
|
121
|
+
path2.parent.mkdir(parents=True, exist_ok=True)
|
|
122
|
+
with open(filename, "w", encoding="utf-8") as fds:
|
|
123
|
+
fds.write(str(os.getpid()))
|
|
124
|
+
|
|
125
|
+
@classmethod
|
|
126
|
+
def privileges(cls):
|
|
127
|
+
"drop privileges."
|
|
128
|
+
import getpass
|
|
129
|
+
import pwd
|
|
130
|
+
pwnam2 = pwd.getpwnam(getpass.getuser())
|
|
131
|
+
os.setgid(pwnam2.pw_gid)
|
|
132
|
+
os.setuid(pwnam2.pw_uid)
|
|
133
|
+
|
|
134
|
+
@classmethod
|
|
135
|
+
def scan(cls, cfg):
|
|
136
|
+
"load tables or scan directories."
|
|
137
|
+
if cfg.read:
|
|
138
|
+
cls.scanner(cfg)
|
|
139
|
+
else:
|
|
140
|
+
Commands.table()
|
|
141
|
+
Mods.sums()
|
|
142
|
+
if not Commands.names:
|
|
143
|
+
cls.scanner(cfg)
|
|
144
|
+
|
|
145
|
+
@classmethod
|
|
146
|
+
def scanner(cls, cfg):
|
|
147
|
+
"scan named modules for commands."
|
|
148
|
+
res = []
|
|
149
|
+
for name, mod in Mods.iter(cfg.mods, cfg.ignore):
|
|
150
|
+
Commands.scan(mod)
|
|
151
|
+
if "configure" in dir(mod):
|
|
152
|
+
mod.configure()
|
|
153
|
+
res.append((name, mod))
|
|
154
|
+
return res
|
|
155
|
+
|
|
156
|
+
@classmethod
|
|
157
|
+
def shutdown(cls):
|
|
158
|
+
"call shutdown on modules."
|
|
159
|
+
for name in cls.inits:
|
|
160
|
+
mod = Mods.get(name)
|
|
161
|
+
if "shutdown" in dir(mod):
|
|
162
|
+
logging.info("shutdown %s", name)
|
|
163
|
+
try:
|
|
164
|
+
mod.shutdown()
|
|
165
|
+
except (KeyboardInterrupt, EOFError):
|
|
166
|
+
_thread.interrupt_main()
|
|
167
|
+
except Exception as ex:
|
|
168
|
+
logging.exception(ex)
|
|
169
|
+
return
|
|
170
|
+
|
|
171
|
+
@classmethod
|
|
172
|
+
def wrap(cls, func, *args):
|
|
173
|
+
"restore console."
|
|
174
|
+
import termios
|
|
175
|
+
old = None
|
|
176
|
+
try:
|
|
177
|
+
old = termios.tcgetattr(sys.stdin.fileno())
|
|
178
|
+
except termios.error:
|
|
179
|
+
pass
|
|
180
|
+
try:
|
|
181
|
+
func(*args)
|
|
182
|
+
cls.shutdown()
|
|
183
|
+
except (KeyboardInterrupt, EOFError):
|
|
184
|
+
return
|
|
185
|
+
except Exception as ex:
|
|
186
|
+
logging.exception(ex)
|
|
187
|
+
if old:
|
|
188
|
+
termios.tcsetattr(sys.stdin.fileno(), termios.TCSADRAIN, old)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def __dir__():
|
|
192
|
+
return (
|
|
193
|
+
"Boot",
|
|
194
|
+
)
|
|
@@ -8,40 +8,40 @@ class Broker:
|
|
|
8
8
|
|
|
9
9
|
objects = {}
|
|
10
10
|
|
|
11
|
-
@
|
|
12
|
-
def add(obj):
|
|
11
|
+
@classmethod
|
|
12
|
+
def add(cls, obj):
|
|
13
13
|
"add object to the broker, key is repr(obj)."
|
|
14
|
-
|
|
14
|
+
cls.objects[repr(obj)] = obj
|
|
15
15
|
|
|
16
|
-
@
|
|
17
|
-
def announce(txt):
|
|
16
|
+
@classmethod
|
|
17
|
+
def announce(cls, txt):
|
|
18
18
|
"announce text on all objects with an announce method."
|
|
19
|
-
for obj in
|
|
19
|
+
for obj in cls.objs("announce"):
|
|
20
20
|
obj.announce(txt)
|
|
21
21
|
|
|
22
|
-
@
|
|
23
|
-
def get(origin):
|
|
22
|
+
@classmethod
|
|
23
|
+
def get(cls, origin):
|
|
24
24
|
"object by repr(obj)."
|
|
25
|
-
return
|
|
25
|
+
return cls.objects.get(origin)
|
|
26
26
|
|
|
27
|
-
@
|
|
28
|
-
def
|
|
29
|
-
"objects with a certain attribute."
|
|
30
|
-
for obj in Broker.objects.values():
|
|
31
|
-
if attr in dir(obj):
|
|
32
|
-
yield obj
|
|
33
|
-
|
|
34
|
-
@staticmethod
|
|
35
|
-
def has(obj):
|
|
27
|
+
@classmethod
|
|
28
|
+
def has(cls, obj):
|
|
36
29
|
"whether the Broker has object."
|
|
37
|
-
return repr(obj) in
|
|
30
|
+
return repr(obj) in cls.objects
|
|
38
31
|
|
|
39
|
-
@
|
|
40
|
-
def like(txt):
|
|
32
|
+
@classmethod
|
|
33
|
+
def like(cls, txt):
|
|
41
34
|
"all keys with a substring in their key."
|
|
42
|
-
for orig in
|
|
35
|
+
for orig in cls.objects:
|
|
43
36
|
if txt in orig.split()[0]:
|
|
44
|
-
yield orig
|
|
37
|
+
yield orig, cls.get(orig)
|
|
38
|
+
|
|
39
|
+
@classmethod
|
|
40
|
+
def objs(cls, attr):
|
|
41
|
+
"objects with a certain attribute."
|
|
42
|
+
for obj in cls.objects.values():
|
|
43
|
+
if attr in dir(obj):
|
|
44
|
+
yield obj
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
def __dir__():
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# This file is placed in the Public Domain.
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
"write your own commands"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import inspect
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
from .objects import Methods
|
|
11
|
+
from .package import Mods
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Commands:
|
|
15
|
+
|
|
16
|
+
cmds = {}
|
|
17
|
+
names = {}
|
|
18
|
+
|
|
19
|
+
@classmethod
|
|
20
|
+
def add(cls, *args):
|
|
21
|
+
"add functions to commands."
|
|
22
|
+
for func in args:
|
|
23
|
+
name = func.__name__
|
|
24
|
+
cls.cmds[name] = func
|
|
25
|
+
modname = func.__module__.split(".")[-1]
|
|
26
|
+
if "__" in modname:
|
|
27
|
+
continue
|
|
28
|
+
cls.names[name] = modname
|
|
29
|
+
|
|
30
|
+
@classmethod
|
|
31
|
+
def command(cls, evt):
|
|
32
|
+
"command callback."
|
|
33
|
+
Methods.parse(evt, evt.text)
|
|
34
|
+
func = cls.get(evt.cmd)
|
|
35
|
+
if not func:
|
|
36
|
+
name = cls.names.get(evt.cmd)
|
|
37
|
+
mod = None
|
|
38
|
+
if name:
|
|
39
|
+
mod = Mods.get(name)
|
|
40
|
+
if mod:
|
|
41
|
+
cls.scan(mod)
|
|
42
|
+
func = cls.get(evt.cmd)
|
|
43
|
+
if func:
|
|
44
|
+
func(evt)
|
|
45
|
+
evt.display()
|
|
46
|
+
evt.ready()
|
|
47
|
+
|
|
48
|
+
@classmethod
|
|
49
|
+
def commands(cls, orig):
|
|
50
|
+
"list cpmmands available."
|
|
51
|
+
return cls.names.keys()
|
|
52
|
+
|
|
53
|
+
@classmethod
|
|
54
|
+
def get(cls, cmd):
|
|
55
|
+
"get function for command."
|
|
56
|
+
return cls.cmds.get(cmd, None)
|
|
57
|
+
|
|
58
|
+
@classmethod
|
|
59
|
+
def scan(cls, module):
|
|
60
|
+
"scan a module for functions with event as argument."
|
|
61
|
+
for key, cmdz in inspect.getmembers(module, inspect.isfunction):
|
|
62
|
+
if 'event' in inspect.signature(cmdz).parameters:
|
|
63
|
+
cls.add(cmdz)
|
|
64
|
+
|
|
65
|
+
@classmethod
|
|
66
|
+
def table(cls):
|
|
67
|
+
"load names from table."
|
|
68
|
+
mod = Mods.get("tbl")
|
|
69
|
+
names = getattr(mod, "NAMES", None)
|
|
70
|
+
if names:
|
|
71
|
+
cls.names.update(names)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def __dir__():
|
|
75
|
+
return (
|
|
76
|
+
'Commands',
|
|
77
|
+
)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# This file is placed in the Public Domain.
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
"one config to rule them all"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
from .objects import Base, Object
|
|
8
|
+
from .utility import Utils
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Configuration(Base):
|
|
12
|
+
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class MainConfig(type):
|
|
17
|
+
|
|
18
|
+
def __getattr__(cls, key):
|
|
19
|
+
if key not in dir(cls):
|
|
20
|
+
return ""
|
|
21
|
+
return cls.__getattribute__(key)
|
|
22
|
+
|
|
23
|
+
def __str__(cls):
|
|
24
|
+
return str(Object.skip(cls.__dict__))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class Main(metaclass=MainConfig):
|
|
28
|
+
|
|
29
|
+
level = "warning"
|
|
30
|
+
name = Utils.pkgname(MainConfig)
|
|
31
|
+
wdr = ""
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def __dir__():
|
|
35
|
+
return (
|
|
36
|
+
'Configuration',
|
|
37
|
+
'Main'
|
|
38
|
+
)
|
|
@@ -5,25 +5,35 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
import json
|
|
8
|
+
import threading
|
|
8
9
|
import types
|
|
9
10
|
|
|
10
11
|
|
|
12
|
+
from .objects import Object
|
|
13
|
+
|
|
14
|
+
|
|
11
15
|
class Encoder(json.JSONEncoder):
|
|
12
16
|
|
|
17
|
+
lock = threading.RLock()
|
|
18
|
+
|
|
13
19
|
def default(self, o):
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
"generate serializable versions."
|
|
21
|
+
with Encoder.lock:
|
|
22
|
+
if isinstance(o, type):
|
|
23
|
+
return Object.skip(o)
|
|
24
|
+
if isinstance(o, dict):
|
|
25
|
+
return o.items()
|
|
26
|
+
if isinstance(o, list):
|
|
27
|
+
return iter(o)
|
|
28
|
+
if isinstance(o, types.MappingProxyType):
|
|
29
|
+
return dict(o)
|
|
23
30
|
try:
|
|
24
|
-
return
|
|
31
|
+
return json.JSONEncoder.default(self, o)
|
|
25
32
|
except TypeError:
|
|
26
|
-
|
|
33
|
+
try:
|
|
34
|
+
return vars(o)
|
|
35
|
+
except TypeError:
|
|
36
|
+
return repr(o)
|
|
27
37
|
|
|
28
38
|
|
|
29
39
|
class Json:
|
|
@@ -1,35 +1,46 @@
|
|
|
1
1
|
# This file is placed in the Public Domain.
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
"
|
|
4
|
+
"event handling"
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
import logging
|
|
8
8
|
import queue
|
|
9
9
|
import threading
|
|
10
|
-
import time
|
|
11
10
|
import _thread
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
from .brokers import Broker
|
|
14
|
+
from .command import Commands
|
|
15
|
+
from .objects import Base
|
|
15
16
|
from .threads import Thread
|
|
16
17
|
|
|
17
18
|
|
|
18
|
-
class Event:
|
|
19
|
+
class Event(Base):
|
|
19
20
|
|
|
20
21
|
def __init__(self):
|
|
22
|
+
Base.__init__(self)
|
|
21
23
|
self._ready = threading.Event()
|
|
22
24
|
self._thr = None
|
|
23
|
-
self.result = {}
|
|
24
25
|
self.args = []
|
|
26
|
+
self.channel = ""
|
|
25
27
|
self.index = 0
|
|
26
28
|
self.kind = "event"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def
|
|
32
|
-
|
|
29
|
+
self.orig = ""
|
|
30
|
+
self.result = []
|
|
31
|
+
self.text = ""
|
|
32
|
+
|
|
33
|
+
def display(self):
|
|
34
|
+
"print results."
|
|
35
|
+
bot = Broker.get(self.orig)
|
|
36
|
+
if bot:
|
|
37
|
+
bot.display(self)
|
|
38
|
+
|
|
39
|
+
def ok(self, txt=""):
|
|
40
|
+
"print ok response."
|
|
41
|
+
if not txt:
|
|
42
|
+
txt = self.text
|
|
43
|
+
self.reply(f"ok {txt}".strip())
|
|
33
44
|
|
|
34
45
|
def ready(self):
|
|
35
46
|
"flag message as ready."
|
|
@@ -37,13 +48,13 @@ class Event:
|
|
|
37
48
|
|
|
38
49
|
def reply(self, text):
|
|
39
50
|
"add text to result."
|
|
40
|
-
self.result
|
|
51
|
+
self.result.append(text)
|
|
41
52
|
|
|
42
53
|
def wait(self, timeout=0.0):
|
|
43
54
|
"wait for completion."
|
|
44
|
-
self._ready.wait(timeout or None)
|
|
45
55
|
if self._thr:
|
|
46
56
|
self._thr.join(timeout or None)
|
|
57
|
+
self._ready.wait(timeout or None)
|
|
47
58
|
|
|
48
59
|
|
|
49
60
|
class Handler:
|
|
@@ -66,7 +77,7 @@ class Handler:
|
|
|
66
77
|
"event loop."
|
|
67
78
|
while self.running.is_set():
|
|
68
79
|
event = self.queue.get()
|
|
69
|
-
if
|
|
80
|
+
if event is None:
|
|
70
81
|
break
|
|
71
82
|
event.orig = repr(self)
|
|
72
83
|
self.callback(event)
|
|
@@ -79,16 +90,19 @@ class Handler:
|
|
|
79
90
|
"register callback."
|
|
80
91
|
self.cbs[kind] = callback
|
|
81
92
|
|
|
82
|
-
def start(self):
|
|
93
|
+
def start(self, daemon=True):
|
|
83
94
|
"start event handler loop."
|
|
84
95
|
self.running.set()
|
|
85
|
-
Thread.launch(self.loop)
|
|
96
|
+
Thread.launch(self.loop, daemon=daemon)
|
|
86
97
|
|
|
87
98
|
def stop(self):
|
|
88
99
|
"stop event handler loop."
|
|
89
100
|
self.running.clear()
|
|
90
101
|
self.queue.put(None)
|
|
91
102
|
|
|
103
|
+
def wait(self):
|
|
104
|
+
pass
|
|
105
|
+
|
|
92
106
|
|
|
93
107
|
class Client(Handler):
|
|
94
108
|
|
|
@@ -108,8 +122,8 @@ class Client(Handler):
|
|
|
108
122
|
def display(self, event):
|
|
109
123
|
"display event results."
|
|
110
124
|
with self.olock:
|
|
111
|
-
for
|
|
112
|
-
self.dosay(event.channel,
|
|
125
|
+
for txt in event.result:
|
|
126
|
+
self.dosay(event.channel, txt)
|
|
113
127
|
|
|
114
128
|
def dosay(self, channel, text):
|
|
115
129
|
"say called by display."
|
|
@@ -117,18 +131,15 @@ class Client(Handler):
|
|
|
117
131
|
|
|
118
132
|
def loop(self):
|
|
119
133
|
"input loop."
|
|
120
|
-
while
|
|
121
|
-
event = self.
|
|
122
|
-
if not event
|
|
134
|
+
while self.running.is_set():
|
|
135
|
+
event = self.iqueue.get()
|
|
136
|
+
if not event:
|
|
123
137
|
break
|
|
124
138
|
event.orig = repr(self)
|
|
125
139
|
self.callback(event)
|
|
126
140
|
|
|
127
|
-
def poll(self):
|
|
128
|
-
"return event."
|
|
129
|
-
return self.iqueue.get()
|
|
130
|
-
|
|
131
141
|
def put(self, event):
|
|
142
|
+
"put event into queue."
|
|
132
143
|
self.iqueue.put(event)
|
|
133
144
|
|
|
134
145
|
def raw(self, text):
|
|
@@ -138,25 +149,56 @@ class Client(Handler):
|
|
|
138
149
|
"say text in channel."
|
|
139
150
|
self.raw(text)
|
|
140
151
|
|
|
152
|
+
def stop(self):
|
|
153
|
+
"stop client."
|
|
154
|
+
super().stop()
|
|
155
|
+
self.running.clear()
|
|
156
|
+
self.iqueue.put(None)
|
|
141
157
|
|
|
142
|
-
|
|
158
|
+
|
|
159
|
+
class Polled(Client):
|
|
143
160
|
|
|
144
161
|
def loop(self):
|
|
145
|
-
"
|
|
146
|
-
while
|
|
162
|
+
"polling loop."
|
|
163
|
+
while self.running.is_set():
|
|
147
164
|
event = self.poll()
|
|
148
|
-
if
|
|
165
|
+
if event is None:
|
|
149
166
|
break
|
|
167
|
+
if not event.text:
|
|
168
|
+
event.ready()
|
|
169
|
+
continue
|
|
150
170
|
event.orig = repr(self)
|
|
151
171
|
self.callback(event)
|
|
152
|
-
event.wait()
|
|
153
172
|
|
|
154
173
|
def poll(self):
|
|
155
174
|
"return event."
|
|
156
175
|
return self.iqueue.get()
|
|
157
176
|
|
|
177
|
+
def start(self, daemon=True):
|
|
178
|
+
super().start(daemon=daemon)
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
class Console(Polled):
|
|
182
|
+
|
|
183
|
+
def __init__(self):
|
|
184
|
+
super().__init__()
|
|
185
|
+
self.register("command", Commands.command)
|
|
186
|
+
|
|
187
|
+
def loop(self):
|
|
188
|
+
"input loop."
|
|
189
|
+
while self.running.is_set():
|
|
190
|
+
event = self.poll()
|
|
191
|
+
if event is None:
|
|
192
|
+
break
|
|
193
|
+
if not event.text:
|
|
194
|
+
event.ready()
|
|
195
|
+
continue
|
|
196
|
+
event.orig = repr(self)
|
|
197
|
+
self.callback(event)
|
|
198
|
+
event.wait()
|
|
199
|
+
|
|
158
200
|
|
|
159
|
-
class Output(
|
|
201
|
+
class Output(Polled):
|
|
160
202
|
|
|
161
203
|
def __init__(self):
|
|
162
204
|
super().__init__()
|
|
@@ -164,7 +206,7 @@ class Output(Client):
|
|
|
164
206
|
|
|
165
207
|
def output(self):
|
|
166
208
|
"output loop."
|
|
167
|
-
while
|
|
209
|
+
while self.running.is_set():
|
|
168
210
|
event = self.oqueue.get()
|
|
169
211
|
if event is None:
|
|
170
212
|
self.oqueue.task_done()
|
|
@@ -172,10 +214,10 @@ class Output(Client):
|
|
|
172
214
|
self.display(event)
|
|
173
215
|
self.oqueue.task_done()
|
|
174
216
|
|
|
175
|
-
def start(self):
|
|
217
|
+
def start(self, daemon=True):
|
|
176
218
|
"start output loop."
|
|
177
219
|
super().start()
|
|
178
|
-
Thread.launch(self.output)
|
|
220
|
+
Thread.launch(self.output, daemon=daemon)
|
|
179
221
|
|
|
180
222
|
def stop(self):
|
|
181
223
|
"stop output loop."
|