def complete_str(self):
"""Return a string representating the complete state."""
-
# general
parts = [
'ConndState: online mode = "{0}" (default provider: {1})\n'
.. todo:: Use reST parameter description here.
"""
-
state = ConndState()
err_code, all_lines = ConndState.run_tell_connd(tell_connd_binary,
# first section
line = next(output).strip()
- state.online_mode = regexp('online mode\s*:\s*(.+)$', line).groups()[0]
+ state.online_mode = regexp(r'online mode\s*:\s*(.+)$', line).groups()[0]
assert state.online_mode in ALL_MODES, \
'unexpected online mode: {0}'.format(state.online_mode)
line = next(output).strip()
- state.default_provider = regexp('default provider\s*:\s*(.*)$',
+ state.default_provider = regexp(r'default provider\s*:\s*(.*)$',
line).groups()[0]
if len(state.default_provider) == 0:
state.default_provider = None
line = next(output).strip()
assert line == 'subsys', 'expected subsys but got {0}'.format(line)
line = next(output).strip()
- state.subsys_online = regexp('online\s*:\s*(.*)$', line) \
+ state.subsys_online = regexp(r'online\s*:\s*(.*)$', line) \
.groups()[0].split()
for subsys in state.subsys_online:
assert subsys in ALL_SUBSYS, \
'unexpected subsys: {0}'.format(subsys)
line = next(output).strip()
- state.subsys_offline = regexp('offline\s*:\s*(.*)$', line) \
+ state.subsys_offline = regexp(r'offline\s*:\s*(.*)$', line) \
.groups()[0].split()
for subsys in state.subsys_offline:
assert subsys in ALL_SUBSYS, \
'unexpected subsys: {0}'.format(subsys)
line = next(output).strip()
- state.subsys_disabled = regexp('disabled\s*:\s*(.*)$', line) \
+ state.subsys_disabled = regexp(r'disabled\s*:\s*(.*)$', line) \
.groups()[0].split()
for subsys in state.subsys_disabled:
assert subsys in ALL_SUBSYS, \
if line == 'end of connection map':
break
conn_name, conn_info = regexp(
- '\[\s*(.+)\s*\]\s*:\s*\(\s*(.*)\s*\)', line).groups()
+ r'\[\s*(.+)\s*\]\s*:\s*\(\s*(.*)\s*\)', line).groups()
expect_new = False
else:
- conn_actions = regexp('actions\s*:\s*\[\s*(.+)\s*\]', line) \
+ conn_actions = regexp(r'actions\s*:\s*\[\s*(.+)\s*\]', line) \
.groups()
assert conn_name is not None and conn_info is not None, \
'error parsing connection maps'
# actions
line = next(output).strip()
- state.actions = regexp('actions\s*:\s*(.*)', line).groups()[0].split()
+ state.actions = regexp(r'actions\s*:\s*(.*)', line).groups()[0].split()
if len(state.actions) == 1 and state.actions[0].strip() == '-':
state.actions = []
line = next(output).strip()
# online IPs
line = next(output).strip()
- state.online_ips = regexp('list of online ips\s*:\s*(.*)', line) \
+ state.online_ips = regexp(r'list of online ips\s*:\s*(.*)', line) \
.groups()[0].split()
if len(state.online_ips) == 1 \
and state.online_ips[0].strip() == 'NONE':
# log level
line = next(output).strip()
state.log_level, state.log_file = \
- regexp('Logging with level (.+)(?:\s+to\s+(.+))?', line).groups()
+ regexp(r'Logging with level (.+)(?:\s+to\s+(.+))?', line).groups()
# done
line = next(output).strip()
Returns result of :py:func:`run_tell_connd`: (error_code, output_lines).
"""
-
# check args
need_provider = True
if state == ONLINE_MODE_DIAL_ON_DEMAND:
def get_mountpoints_by_type(fstype):
"""
+ Use */proc/mounts* to find filesystem mount points.
+
Determine where some filesystem is mounted by reading the list
of mountpoints from */proc/mounts*.
lines = list(m)
pat = re.compile(r"^\S+\s+(\S+)\s+" + fstype + r"\s+.*$")
mps = [mp.group(1)
- for mp in map(lambda l: re.match(pat, l), lines)
+ for mp in map(lambda line: re.match(pat, line), lines)
if mp]
except IOError:
raise IOError(f"Failed to read {procmounts}")
class ServiceState(enum.Enum):
"""State of a system service, see `get_service_state`."""
+
RUNNING = 0
DEAD_WITH_PIDFILE = 1
DEAD_WITH_LOCKFILE = 2
searched into the config text but matched within a larger regex in
in order to avoid any mismatch.
- Example:
- provider.cnf, 'PROVIDER_LOCALIP,0: "(\\d+)"', 127.0.0.1
+ Example: provider.cnf, 'PROVIDER_LOCALIP,0: "(\\d+)"', 127.0.0.1
"""
pattern = regex.encode() if regex else "(.+)"