mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 13:11:31 +00:00
Refactor HistoryMonitor
This commit is contained in:
parent
44a1433d3b
commit
491eaf6d5e
@ -21,7 +21,6 @@ class HistoryMonitor(ABC, InotifyObserver):
|
|||||||
See examples below.
|
See examples below.
|
||||||
"""
|
"""
|
||||||
def __init__(self, uplink, histfile):
|
def __init__(self, uplink, histfile):
|
||||||
self._domain = ''
|
|
||||||
self.histfile = histfile
|
self.histfile = histfile
|
||||||
self.history = []
|
self.history = []
|
||||||
self._last_length = len(self.history)
|
self._last_length = len(self.history)
|
||||||
@ -29,12 +28,9 @@ class HistoryMonitor(ABC, InotifyObserver):
|
|||||||
super().__init__(self.histfile)
|
super().__init__(self.histfile)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@abstractmethod
|
||||||
def domain(self):
|
def domain(self):
|
||||||
return self._domain
|
raise NotImplementedError()
|
||||||
|
|
||||||
@domain.setter
|
|
||||||
def domain(self, domain):
|
|
||||||
self._domain = domain
|
|
||||||
|
|
||||||
def on_modified(self, event):
|
def on_modified(self, event):
|
||||||
self._fetch_history()
|
self._fetch_history()
|
||||||
@ -78,9 +74,9 @@ class BashMonitor(HistoryMonitor):
|
|||||||
shopt -s histappend
|
shopt -s histappend
|
||||||
unset HISTCONTROL
|
unset HISTCONTROL
|
||||||
"""
|
"""
|
||||||
def __init__(self, uplink, histfile):
|
@property
|
||||||
super().__init__(uplink, histfile)
|
def domain(self):
|
||||||
self.domain = 'bash'
|
return 'bash'
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def command_pattern(self):
|
def command_pattern(self):
|
||||||
@ -95,9 +91,9 @@ class GDBMonitor(HistoryMonitor):
|
|||||||
HistoryMonitor to monitor GDB sessions.
|
HistoryMonitor to monitor GDB sessions.
|
||||||
For this to work "set trace-commands on" must be set in GDB.
|
For this to work "set trace-commands on" must be set in GDB.
|
||||||
"""
|
"""
|
||||||
def __init__(self, histfile):
|
@property
|
||||||
super().__init__(histfile)
|
def domain(self):
|
||||||
self.domain = 'gdb'
|
return 'gdb'
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def command_pattern(self):
|
def command_pattern(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user