Engine¶
x84.engine
¶
Command-line launcher and event loop for x/84.
-
x84.engine.
accept
(log, server, check_ban)[source]¶ Accept new connection from server, spawning an unmanaged thread.
Connecting socket accepted is server.server_socket, instantiate a new instance of client_factory, with optional keyword arguments defined by server.client_factory_kwargs, registering it with dictionary server.clients, and spawning an unmanaged thread using connect_factory, with optional keyword arguments server.connect_factory_kwargs.
-
x84.engine.
client_recv
(servers, ready_fds, log)[source]¶ Test all clients for recv_ready().
If any data is available, then
client.socket_recv()
is called, buffering the data for the session which is exhausted bysession_send()
.
-
x84.engine.
client_send
(terminals, log)[source]¶ Test all clients for send_ready().
If any data is available, then
tty.client.send()
is called. This is data sent from the session to the tcp client.
-
x84.engine.
find_server
(servers, fd)[source]¶ Find matching
server.server_socket
for given file descriptor.
-
x84.engine.
get_session_output_fds
(servers)[source]¶ Return file descriptors of all
tty.master_read
pipes.
-
x84.engine.
handle_lock
(locks, tty, event, data, tap_events, log)[source]¶ handle locking event of
(lock-key, (method, stale))
.
-
x84.engine.
main
()[source]¶ x84 main entry point. The system begins and ends here.
Command line arguments to engine.py:
--config=
location of alternate configuration file--logger=
location of alternate logging.ini file
x84.db
¶
Database request handler for x/84.
-
class
x84.db.
DBHandler
(queue, event, data)[source]¶ Bases:
threading.Thread
This handler receives and handles a dictionary-based “database command”.
See complimenting
x84.bbs.dbproxy.DBProxy
, which behaves as a dictionary and “packs” command iterables through an IPC event queue which is then dispatched by the engine.The return values are sent to the session queue with equal ‘event’ name.
Class initializer.
Parameters: - queue (multiprocessing.Pipe) – parent input end of a tty session
ipc queue (
tty.master_write
). - event (str) – database schema in form of string
'db-schema'
or'db=schema'
. When'-'
is used, the result is returned as a single transfer. When'='
, an iterable is yielded and the data is transfered via the IPC Queue as a stream. - data (tuple) – a dict method proxy command sequence in form of
(table, command, arguments)
. For example, ``(‘unnamed’, ‘pop’, 0).
- queue (multiprocessing.Pipe) – parent input end of a tty session
ipc queue (
-
x84.db.
check_db
(filepath)[source]¶ Verify permission access of given database file.
Raises: - AssertionError – file or folder is not writable.
- OSError – could not write containing folder.
-
x84.db.
get_database
(filepath, table)[source]¶ Return
sqlitedict.SqliteDict
instance for given database.
-
x84.db.
get_db_func
(dictdb, cmd)[source]¶ Return callable function of method on
dictdb
.Raises: AssertionError – not a valid method or not callable.