# Copyright (c) 2016-2022 Intra2net AG <info@intra2net.com>
"""
-arnied_api: wrappers around the arnied varlink API.
+Wrappers around the arnied varlink API.
-Featuring
-- Arnied: stateless class with methods as exposed in the varlink API.
+Featuring:
+ - Arnied: stateless class with methods as exposed in the varlink API.
For documentation of Exceptions, methods and their arguments, refer to arnied
source code (arnied/client/arnieclient.hxx). For compatibility, argument names
# Copyright (c) 2016-2018 Intra2net AG <info@intra2net.com>
"""
-
-SUMMARY
-------------------------------------------------------
Interaction with central arnied daemon.
All functions (except :py:func:`schedule` result in calling a binary
For changes of configuration (*set_cnf*, *get_cnf*), refer to :py:mod:`pyi2ncommon.cnfvar`.
Copyright: Intra2net AG
-
-
-INTERFACE
-------------------------------------------------------
-
"""
import os
# Copyright (c) 2016-2018 Intra2net AG <info@intra2net.com>
"""
-string: functionality for parsing cnfvars from strings
+Functionality for parsing cnfvars from strings.
.. codeauthor:: Intra2net
-
-contents
--------------------------------------------------------------------------------
-
This module provides read and parse functionality for the Intra2net *CNF*
format from strings and by extension cnf files.
structure that needs fixup or something like that.
.. note::
- The variable values of get_cnf seems to be encoded in latin1, and set_cnf
- seems to assume latin1-encoded values (not var names). Function
- :py:func:`read_cnf` converts this to unicode and other functions convert
- unicode back to latin1.
-
-
-notes on Python 3 conversion
--------------------------------------------------------------------------------
-
-Since the original *CNF* format assumes latin-1 encoded data pretty much
-exclusively, we preserve the original encoding while parsing the file.
-When assembling the data structures returned to the user, values are then
-converted to strings so they can be used naturally at the Python end.
-
-implementation
--------------------------------------------------------------------------------
+ Since the original *CNF* format assumes latin-1 encoded data pretty much
+ exclusively, we preserve the original encoding while parsing the file.
+ When assembling the data structures returned to the user, values are then
+ converted to strings so they can be used naturally at the Python end.
"""
import functools
# Copyright (c) 2016-2018 Intra2net AG <info@intra2net.com>
"""
-
-summary
-------------------------------------------------------
Module for one-step dynamic cnfvar generation from default value templates.
.. codeauthor:: Intra2net
-
-contents
--------------------------------------------------------
These templates contain the bare defaults the UI adds upon
creation of each major and frequently used cnfvar.
-
-
-interface
-------------------------------------------------------
-
"""
import time
# Copyright (c) 2016-2018 Intra2net AG <info@intra2net.com>
"""
-
-SUMMARY
-------------------------------------------------------
Representation for connd state as returned by "tell-connd --status".
Copyright: Intra2net AG
-
-
-INTERFACE
-------------------------------------------------------
-
"""
import subprocess
# Copyright (c) 2016-2018 Intra2net AG <info@intra2net.com>
"""
-
-SUMMARY
-------------------------------------------------------
Dialing, hangup, general provider online/offline state control.
Copyright: 2017 Intra2net AG
This used to be part of the sysmisc utilitiy initially which caused an include
circle with the arnied wrapper.
-
-CONTENTS
-------------------------------------------------------
-dialout
- Generic access to the system’s dialing mode. Allows for requesting manual
- or permanently online dial state.
-
-arnied_dial_permanent
- Enter permantly online dialing state.
-
-arnied_dial_do
- Enter dial on command state.
-
-arnied_dial_hangup
- Terminate uplink unconditionally.
+Contents:
+ * dialout
+ Generic access to the system’s dialing mode. Allows for requesting manual
+ or permanently online dial state.
+ * arnied_dial_permanent
+ Enter permantly online dialing state.
+ * arnied_dial_do
+ Enter dial on command state.
+ * arnied_dial_hangup
+ Terminate uplink unconditionally.
All API methods come with the optional argument ``block`` (bool) to request the
call to block until the system completes the state transition successfully. The
completion timeout is currently 10 seconds (see the definition of
``DIALTOOLS_TIMEOUT`` below).
-
-
-IMPLEMENTATION
-------------------------------------------------------
-
"""
# Copyright (c) 2016-2018 Intra2net AG <info@intra2net.com>
"""
-
-SUMMARY
-------------------------------------------------------
Connection to an IMAP mailbox
Convenience wrapper around :py:class:`imaplib.IMAP4`
* use SSL connection per default, unencrypted only as option
Copyright: Intra2net AG
-
-
-INTERFACE
-------------------------------------------------------
-
"""
import imaplib
# Copyright (c) 2016-2018 Intra2net AG <info@intra2net.com>
"""
-
-SUMMARY
-------------------------------------------------------
Iterative reading of log files, similar to shell command `tail -f`.
Copyright: Intra2net AG
-
-CONTENTS
-------------------------------------------------------
-
Basic Functionality (class :py:class:`IterativeReader`):
Runs stat in a loop to find out whether file size has changed. Then reads the
new data and forwards that
like date, time, module name, urgency and message.
.. todo:: auto-detect log line layout
-
-
-INTERFACE
-------------------------------------------------------
-
"""
import os
import os.path
# Copyright (c) 2016-2018 Intra2net AG <info@intra2net.com>
"""
-
-SUMMARY
-------------------------------------------------------
-Utilities for dealing with email
+Utilities for dealing with email.
.. seealso:: :py:mod:`pyi2ncommon.mail_validator`,
:py:mod:`pyi2ncommon.imap_mailbox`
Copyright: Intra2net AG
-
-
-INTERFACE
-------------------------------------------------------
-
"""
from base64 import b64decode
# Copyright (c) 2016-2018 Intra2net AG <info@intra2net.com>
"""
-
-SUMMARY
-------------------------------------------------------
Class :py:class:`MailValidator`, a fully-featured email sender and checker.
Copyright: Intra2net AG
-
-
-INTERFACE
-------------------------------------------------------
-
"""
import time
# Copyright (c) 2016-2018 Intra2net AG <info@intra2net.com>
"""
-
-SUMMARY
-------------------------------------------------------
Miscellaneous system utility: Collection of various common system stuff / idioms.
Copyright: 2015 Intra2net AG
-
-CONTENTS
-------------------------------------------------------
The library exports the symbols below and some custom logging functions.
-run_cmd_with_pipe
- Wrapper for the default use case of the cumbersome "subprocess" library.
- Accepts a list of arguments that describe the command invocation. Returns
- ``True`` and the contents of ``stdout`` if the pipe returned sucessfully,
- ``False`` plus ``stderr`` and the exit status otherwise. For example::
-
- import sysmisc
- (success, output, _ret) = sysmisc.run_cmd_with_pipe([ "/usr/bin/date", "+%F" ])
- if success is True:
- print("Today is %s" % output)
- else:
- print("Failed to read date from pipe.")
-
-get_mountpoints_by_type
- Extract mount points for the given file system type from */proc/mounts*.
- Returns ``None`` if the file system is not mounted, a list of mount points
- otherwise. Raises a test error if */proc/mounts* cannot be accessed.
-
-read_linewise
- Similar to run_cmd_with_pipe but allows processing of output line-by-line
- as it becomes available. This may be necessary when the underlying binary
- creates lots of output that cannot be buffered until the process finishes.
- Example::
-
- import re
- import sysmisc
- def parse(line):
- if re.match(r'\d', line):
- print('found digits in line!')
- sysmisc.read_linewise('dump_db', parse)
-
-hash_file
- Return a hash of a file.
-
-cheat_reboot
- Replace the reboot binary with a fake one.
-
-cmd_block_till
- Run a command and wait until a condition evaluates to True.
-
-cd
- A context manager that temporarily changes the current working directory
+ * run_cmd_with_pipe
+ Wrapper for the default use case of the cumbersome "subprocess" library.
+ Accepts a list of arguments that describe the command invocation. Returns
+ ``True`` and the contents of ``stdout`` if the pipe returned sucessfully,
+ ``False`` plus ``stderr`` and the exit status otherwise. For example::
+
+ import sysmisc
+ (success, output, _ret) = sysmisc.run_cmd_with_pipe([ "/usr/bin/date", "+%F" ])
+ if success is True:
+ print("Today is %s" % output)
+ else:
+ print("Failed to read date from pipe.")
+
+ * get_mountpoints_by_type
+ Extract mount points for the given file system type from */proc/mounts*.
+ Returns ``None`` if the file system is not mounted, a list of mount points
+ otherwise. Raises a test error if */proc/mounts* cannot be accessed.
+
+ * read_linewise
+ Similar to run_cmd_with_pipe but allows processing of output line-by-line
+ as it becomes available. This may be necessary when the underlying binary
+ creates lots of output that cannot be buffered until the process finishes.
+ Example::
+
+ import re
+ import sysmisc
+ def parse(line):
+ if re.match(r'\d', line):
+ print('found digits in line!')
+ sysmisc.read_linewise('dump_db', parse)
+
+ * hash_file
+ Return a hash of a file.
+
+ * cheat_reboot
+ Replace the reboot binary with a fake one.
+
+ * cmd_block_till
+ Run a command and wait until a condition evaluates to True.
+
+ * cd
+ A context manager that temporarily changes the current working directory
The logging functions either use the format capability or play
the simple role of providing shorter names.
-
-
-INTERFACE
-------------------------------------------------------
-
"""
import re
# Copyright (c) 2016-2018 Intra2net AG <info@intra2net.com>
"""
-
-SUMMARY
-------------------------------------------------------
Utility to customize email and other test data.
Copyright: Intra2net AG
-
-
-INTERFACE
-------------------------------------------------------
-
"""
import os
# Copyright (c) 2016-2018 Intra2net AG <info@intra2net.com>
"""
-
-SUMMARY
-------------------------------------------------------
Functions for improving textual output.
Copyright: 2015 Intra2net AG
-
-CONTENTS
-------------------------------------------------------
This module has two parts. Part 1 includes:
- head_and_tail: shows the first few and last few elements of an iterable that
could potentially be pretty long
.. seealso:: http://stackoverflow.com/questions/287871/print-in-terminal-with-colors-using-python
.. seealso:: https://en.wikipedia.org/wiki/ANSI_escape_code
.. seealso:: :py:mod:`textwrap`
-
-
-INTERFACE
-------------------------------------------------------
"""
from builtins import print as _builtin_print
# Copyright (c) 2016-2018 Intra2net AG <info@intra2net.com>
"""
-
-SUMMARY
-------------------------------------------------------
-V4_addr_range class
+V4_addr_range class.
Copyright: Intra2net AG
-
-
-INTERFACE
-------------------------------------------------------
-
"""
default_addr_lo = 42
# Copyright (c) 2016-2018 Intra2net AG <info@intra2net.com>
"""
-
-SUMMARY
-------------------------------------------------------
Utility for HTTP based interaction with the arnied web page.
Copyright: Intra2net AG
-
-
-INTERFACE
-------------------------------------------------------
-
"""
import re