text stringlengths 81 112k |
|---|
Create QImage from ARGB array.
The ARGB must have shape (width, height, 4) and dtype=ubyte.
NOTE: The order of values in the 3rd axis must be (blue, green, red, alpha).
:return:
def create_image(data: np.ndarray, colormap, data_min=None, data_max=None, normalize=True) -> QImage:
"""
... |
0 - "ASK", 1 - "FSK", 2 - "PSK", 3 - "APSK (QAM)"
:param value:
:return:
def modulation_type(self, value: int):
"""
0 - "ASK", 1 - "FSK", 2 - "PSK", 3 - "APSK (QAM)"
:param value:
:return:
"""
if self.__modulation_type != value:
self.__modul... |
Estimate the frequency of the baseband signal using FFT
:param start: Start of the area that shall be investigated
:param end: End of the area that shall be investigated
:param sample_rate: Sample rate of the signal
:return:
def estimate_frequency(self, start: int, end: int, sample_rat... |
:rtype: int, int, int, int
def selection_range(self):
"""
:rtype: int, int, int, int
"""
selected = self.selectionModel().selection()
""":type: QItemSelection """
if selected.isEmpty():
return -1, -1, -1, -1
min_row = numpy.min([rng.top() for rng in... |
Processes can't write to stdout/stderr on frozen windows apps because they do not exist here
if process tries it anyway we get a nasty dialog window popping up, so we redirect the streams to a dummy
see https://github.com/jopohl/urh/issues/370
def fix_windows_stdout_stderr():
"""
Processes can't write ... |
Build the order of component based on their priority and predecessors
:rtype: list of Component
def build_component_order(self):
"""
Build the order of component based on their priority and predecessors
:rtype: list of Component
"""
present_components = [item for item ... |
This method clusters some bitvectors based on their length. An example output is
2: [0.5, 1]
4: [1, 0.75, 1, 1]
Meaning there were two message lengths: 2 and 4 bit.
(0.5, 1) means, the first bit was equal in 50% of cases (meaning maximum difference) and bit 2 was equal in all messages
... |
Find candidate addresses using LCS algorithm
perform a scoring based on how often a candidate appears in a longer candidate
Input is something like
------------------------
['1b6033', '1b6033fd57', '701b603378e289', '20701b603378e289000c62',
'1b603300', '78e289757e', '7078e2891b... |
Choose a pair of address candidates ensuring they have the same length and starting with the highest scored ones
:type candidates: dict[str, int]
:param candidates: Count how often the longest common substrings appeared in the messages
:return:
def choose_candidate_pair(candidates):
""... |
Extract each archive from the list of filenames.
Normal files stay untouched.
Add all files to the Recent Files.
:type file_names: list of str
:type temp_dir: str
:rtype: list of str
def uncompress_archives(file_names, temp_dir):
"""
Extract each archive from the list of filenames.
Norm... |
:type modulators: list of Modulator
:return:
def write_modulators_to_project_file(self, tree=None):
"""
:type modulators: list of Modulator
:return:
"""
if self.project_file is None or not self.modulators:
return
if tree is None:
tree = E... |
continuous haar wavelet transform based on the paper
"A practical guide to wavelet analysis" by Christopher Torrence and Gilbert P Compo
def cwt_haar(x: np.ndarray, scale=10):
"""
continuous haar wavelet transform based on the paper
"A practical guide to wavelet analysis" by Christopher Torrence and Gi... |
Finding the synchronization works by finding the first difference between two messages.
This is performed for all messages and the most frequent first difference is chosen
:type messages: list of Message
:param preamble_end: End of preamble = start of search
:param search_end: End of se... |
Pad message in given row with zeros until given column so user can enter values behind end of message
:return:
def __pad_until_index(self, row: int, bit_pos: int):
"""
Pad message in given row with zeros until given column so user can enter values behind end of message
:return:
... |
Search all differences between protocol messages regarding a reference message
:param refindex: index of reference message
:rtype: dict[int, set[int]]
def find_differences(self, refindex: int):
"""
Search all differences between protocol messages regarding a reference message
... |
Demodulates received IQ data and adds demodulated bits to messages
:param data:
:return:
def __demodulate_data(self, data):
"""
Demodulates received IQ data and adds demodulated bits to messages
:param data:
:return:
"""
if len(data) == 0:
ret... |
:type proto_bits: list of str
def create_rectangle(proto_bits, pulse_len=100):
"""
:type proto_bits: list of str
"""
ones = np.ones(pulse_len, dtype=np.float32) * 1
zeros = np.ones(pulse_len, dtype=np.float32) * -1
n = 0
y = []
for msg in proto_bits:
... |
Return true if redraw is needed
def set_parameters(self, samples: np.ndarray, window_size, data_min, data_max) -> bool:
"""
Return true if redraw is needed
"""
redraw_needed = False
if self.samples_need_update:
self.spectrogram.samples = samples
redraw_ne... |
:type parent: QTableView
:type undo_stack: QUndoStack
:type protocol_analyzers: list of ProtocolAnalyzer
def get_action(self, parent, undo_stack: QUndoStack, sel_range, protocol: ProtocolAnalyzer, view: int):
"""
:type parent: QTableView
:type undo_stack: QUndoStack
:typ... |
Return the length of this message in byte.
def get_byte_length(self, decoded=True) -> int:
"""
Return the length of this message in byte.
"""
end = len(self.decoded_bits) if decoded else len(self.__plain_bits)
end = self.convert_index(end, 0, 2, decoded=decoded)[0]
retu... |
Return the SRC address of a message if SRC_ADDRESS label is present in message type of the message
Return None otherwise
:param decoded:
:return:
def get_src_address_from_data(self, decoded=True):
"""
Return the SRC address of a message if SRC_ADDRESS label is present in messag... |
Für das Bit-Alignment (neu Ausrichten von Hex, ASCII-View)
:rtype: list of array.array
def split(self, decode=True):
"""
Für das Bit-Alignment (neu Ausrichten von Hex, ASCII-View)
:rtype: list of array.array
"""
start = 0
result = []
message = self.deco... |
:type: encoding
def set_e(self):
if self.ui.combobox_decodings.count() < 1: # Empty list
return
self.e = copy.deepcopy(self.decodings[self.ui.combobox_decodings.currentIndex()])
""":type: encoding """
chain = self.e.get_chain()
self.ui.decoderchain.clear()
... |
:rtype: dict[int, list of ProtocolAnalyzer]
def protocols(self):
"""
:rtype: dict[int, list of ProtocolAnalyzer]
"""
result = {}
for i, group in enumerate(self.rootItem.children):
result[i] = [child.protocol for child in group.children]
return result |
:rtype: dict[int, list of ProtocolTreeItem]
def protocol_tree_items(self):
"""
:rtype: dict[int, list of ProtocolTreeItem]
"""
result = {}
for i, group in enumerate(self.rootItem.children):
result[i] = [child for child in group.children]
return result |
:type items: list of ProtocolTreeItem
def move_to_group(self, items, new_group_id: int):
"""
:type items: list of ProtocolTreeItem
"""
group = self.rootItem.child(new_group_id)
for item in items:
group.appendChild(item)
self.controller.refresh() |
Set all protocols in copy mode. They will return a copy of their protocol.
This is used for writable mode in CFC.
:param use_copy:
:return:
def set_copy_mode(self, use_copy: bool):
"""
Set all protocols in copy mode. They will return a copy of their protocol.
This is us... |
Get a representation of the ring buffer for plotting. This is expensive, so it should only be used in frontend
:return:
def view_data(self):
"""
Get a representation of the ring buffer for plotting. This is expensive, so it should only be used in frontend
:return:
"""
le... |
Push values to buffer. If buffer can't store all values a ValueError is raised
def push(self, values: np.ndarray):
"""
Push values to buffer. If buffer can't store all values a ValueError is raised
"""
n = len(values)
if len(self) + n > self.size:
raise ValueError("T... |
Pop number of elements. If there are not enough elements, all remaining elements are returned and the
buffer is cleared afterwards. If buffer is empty, an empty numpy array is returned.
If number is -1 (or any other value below zero) than complete buffer is returned
def pop(self, number: int, ensure_e... |
XOR Data Whitening
:param decoding:
:param inpt:
:return:
def code_data_whitening(self, decoding, inpt):
"""
XOR Data Whitening
:param decoding:
:param inpt:
:return:
"""
inpt_copy = array.array("B", inpt)
return self.apply_data_wh... |
:type parent: QTableView
:type undo_stack: QUndoStack
def get_action(self, parent, undo_stack: QUndoStack, sel_range, protocol, view: int):
"""
:type parent: QTableView
:type undo_stack: QUndoStack
"""
self.command = ZeroHideAction(protocol, self.following_zeros, view, s... |
Scrolls the mouse if ROI Selection reaches corner of view
:param mouse_x:
:return:
def scroll_mouse(self, mouse_x: int):
"""
Scrolls the mouse if ROI Selection reaches corner of view
:param mouse_x:
:return:
"""
scrollbar = self.horizontalScrollBar()
... |
Refresh selection area in case scene was resized/scaled.
This happens e.g. when switching from Signal View to Quad Demod view
:return:
def refresh_selection_area(self):
"""
Refresh selection area in case scene was resized/scaled.
This happens e.g. when switching from Signal View... |
Return the boundaries of the view in scene coordinates
def view_rect(self) -> QRectF:
"""
Return the boundaries of the view in scene coordinates
"""
top_left = self.mapToScene(0, 0)
bottom_right = self.mapToScene(self.viewport().width() - 1, self.viewport().height() - 1)
... |
:type: list of ProtocolTreeItem
def dropEvent(self, event: QDropEvent):
items = [item for item in self.items(event.scenePos()) if isinstance(item, GraphicsItem) and item.acceptDrops()]
item = None if len(items) == 0 else items[0]
if len(event.mimeData().urls()) > 0:
self.files_dropp... |
Convert bit array to string
:param endianness: Endianness little or big
:param bits: Bit array
:param output_view_type: Output view type index
0 = bit, 1=hex, 2=ascii, 3=decimal 4=binary coded decimal (bcd)
:param pad_zeros:
:param lsb: Least Significant Bit -> Reverse bits first
:param ls... |
In case of ASK modulation, this method tries to use pauses after messages as zero bits so that
the bit lengths of messages are divisible by divisor
:param bit_data: List of bit arrays
:param bit_len: Bit length that was used for demodulation
:param pauses: List of pauses
:param b... |
Determine on which place (regarding samples) a bit sequence is
:rtype: tuple[int,int]
def get_samplepos_of_bitseq(self, start_message: int, start_index: int, end_message: int, end_index: int,
include_pause: bool):
"""
Determine on which place (regarding samples) ... |
get start and end index of bit sequence from selected samples
:rtype: tuple[int,int,int,int]
:return: start_message index, start index, end message index, end index
def get_bitseq_from_selection(self, selection_start: int, selection_width: int):
"""
get start and end index of bit seque... |
Konvertiert einen Index aus der einen Sicht (z.B. Bit) in eine andere (z.B. Hex)
:param message_indx: if -1, the message with max length is chosen
:return:
def convert_index(self, index: int, from_view: int, to_view: int, decoded: bool, message_indx=-1) -> tuple:
"""
Konvertiert einen ... |
Calculates the frequency of at most nbits logical ones and returns the mean of these frequencies
:param nbits:
:return:
def estimate_frequency_for_one(self, sample_rate: float, nbits=42) -> float:
"""
Calculates the frequency of at most nbits logical ones and returns the mean of these ... |
Calculates the frequency of at most nbits logical zeros and returns the mean of these frequencies
:param nbits:
:return:
def estimate_frequency_for_zero(self, sample_rate: float, nbits=42) -> float:
"""
Calculates the frequency of at most nbits logical zeros and returns the mean of the... |
:type decodings: list of Encoding
def auto_assign_decodings(self, decodings):
"""
:type decodings: list of Encoding
"""
nrz_decodings = [decoding for decoding in decodings if decoding.is_nrz or decoding.is_nrzi]
fallback = nrz_decodings[0] if nrz_decodings else None
cand... |
:rtype: int, int
def selection_range(self):
"""
:rtype: int, int
"""
selected = self.selectionModel().selection()
""":type: QItemSelection """
if selected.isEmpty():
return -1, -1
min_row = min(rng.top() for rng in selected)
max_row = max(rn... |
Remove all cache directories
:return:
def cleanup():
"""
Remove all cache directories
:return:
"""
script_dir = os.path.dirname(__file__) if not os.path.islink(__file__) else os.path.dirname(os.readlink(__file__))
script_dir = os.path.realpath(os.path.join(script_dir, ".."))
shutil.rmtr... |
:rtype: int, int, int, int
def selection_range(self):
"""
:rtype: int, int, int, int
"""
selected = self.selectionModel().selection() # type: QItemSelection
if self.selection_is_empty:
return -1, -1, -1, -1
def range_to_tuple(rng):
return rng.ro... |
Return the most frequent value in list.
If there is no unique one, return the maximum of the most frequent values
:param values:
:return:
def get_most_frequent_value(values: list):
"""
Return the most frequent value in list.
If there is no unique one, return the maximum of the most frequent va... |
Get the list of start, end indices of messages
:param magnitudes: Magnitudes of samples
:param noise_threshold: Threshold for noise
:return:
def segment_messages_from_magnitudes(magnitudes: np.ndarray, noise_threshold: float):
"""
Get the list of start, end indices of messages
:param magnitud... |
Round plateau lengths to next divisible number of digit count e.g. 99 -> 100, 293 -> 300
:param plateau_lengths:
:return:
def round_plateau_lengths(plateau_lengths: list):
"""
Round plateau lengths to next divisible number of digit count e.g. 99 -> 100, 293 -> 300
:param plateau_lengths:
:ret... |
:param group_id:
:type files: list of QtCore.QUrl
def on_files_dropped_on_group(self, files, group_id: int):
"""
:param group_id:
:type files: list of QtCore.QUrl
"""
self.__add_urls_to_group(files, group_id=group_id) |
:rtype: list of Plugin
def load_installed_plugins(self):
""" :rtype: list of Plugin """
result = []
plugin_dirs = [d for d in os.listdir(self.plugin_path) if os.path.isdir(os.path.join(self.plugin_path, d))]
settings = constants.SETTINGS
for d in plugin_dirs:
if d =... |
:rtype: list[tuple of int]
def __get_zero_seq_indexes(self, message: str, following_zeros: int):
"""
:rtype: list[tuple of int]
"""
result = []
if following_zeros > len(message):
return result
zero_counter = 0
for i in range(0, len(message)):
... |
returns a string of new device messages separated by newlines
:return:
def read_messages(self) -> str:
"""
returns a string of new device messages separated by newlines
:return:
"""
if self.backend == Backends.grc:
errors = self.__dev.read_errors()
... |
:type parent: QTableView
:type undo_stack: QUndoStack
:type groups: list of ProtocolGroups
def get_action(self, parent, undo_stack: QUndoStack, sel_range, groups,
view: int) -> QUndoCommand:
"""
:type parent: QTableView
:type undo_stack: QUndoStack
:ty... |
Get the checksum for a WSP message. There are three hashes possible:
1) 4 Bit Checksum - For Switch Telegram (RORG=5 or 6 and STATUS = 0x20 or 0x30)
2) 8 Bit Checksum: STATUS bit 2^7 = 0
3) 8 Bit CRC: STATUS bit 2^7 = 1
:param msg: the message without Preamble/SOF and EOF. Message start... |
:type number: int
:rtype: ProtocolTreeItem
def child(self, number):
"""
:type number: int
:rtype: ProtocolTreeItem
"""
if number < self.childCount():
return self.__childItems[number]
else:
return False |
Convenience function for creating a ready-to-go CloudflareScraper object.
def create_scraper(cls, sess=None, **kwargs):
"""
Convenience function for creating a ready-to-go CloudflareScraper object.
"""
scraper = cls(**kwargs)
if sess:
attrs = ["auth", "cert", "cooki... |
Convenience function for building a Cookie HTTP header value.
def get_cookie_string(cls, url, user_agent=None, **kwargs):
"""
Convenience function for building a Cookie HTTP header value.
"""
tokens, user_agent = cls.get_tokens(url, user_agent=user_agent, **kwargs)
return "; ".j... |
Save Config
def save_config(self, cmd="save config", confirm=False, confirm_response=""):
"""Save Config"""
return super(ExtremeErsSSH, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) |
Adding a delay after login.
def special_login_handler(self, delay_factor=1):
"""Adding a delay after login."""
delay_factor = self.select_delay_factor(delay_factor)
self.write_channel(self.RETURN)
time.sleep(1 * delay_factor) |
Save Config for Extreme SLX.
def save_config(
self,
cmd="copy running-config startup-config",
confirm=True,
confirm_response="y",
):
"""Save Config for Extreme SLX."""
return super(ExtremeSlxSSH, self).save_config(
cmd=cmd, confirm=confirm, confirm_respon... |
Execute show version command using Netmiko.
def show_version(a_device):
"""Execute show version command using Netmiko."""
remote_conn = ConnectHandler(**a_device)
print()
print("#" * 80)
print(remote_conn.send_command_expect("show version"))
print("#" * 80)
print() |
Use threads and Netmiko to connect to each of the devices. Execute
'show version' on each device. Record the amount of time required to do this.
def main():
"""
Use threads and Netmiko to connect to each of the devices. Execute
'show version' on each device. Record the amount of time required to do thi... |
Saves Config
def save_config(
self,
cmd="copy running-configuration startup-configuration",
confirm=False,
confirm_response="",
):
"""Saves Config"""
return super(DellForce10SSH, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_respon... |
Prepare the session after the connection has been established.
def session_preparation(self):
"""Prepare the session after the connection has been established."""
# 0 will defer to the global delay factor
delay_factor = self.select_delay_factor(delay_factor=0)
self._test_channel_read()
... |
Strip 'Done' from command output
def strip_prompt(self, a_string):
""" Strip 'Done' from command output """
output = super(NetscalerSSH, self).strip_prompt(a_string)
lines = output.split(self.RESPONSE_RETURN)
if "Done" in lines[-1]:
return self.RESPONSE_RETURN.join(lines[:-1... |
Saves configuration.
def save_config(self, cmd="write memory", confirm=False, confirm_response=""):
"""Saves configuration."""
return super(UbiquitiEdgeSSH, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) |
Establish the secure copy connection.
def establish_scp_conn(self):
"""Establish the secure copy connection."""
ssh_connect_params = self.ssh_ctl_chan._connect_params_dict()
self.scp_conn = self.ssh_ctl_chan._build_ssh_client()
self.scp_conn.connect(**ssh_connect_params)
self.sc... |
Return space available on remote device.
def remote_space_available(self, search_pattern=r"(\d+) \w+ free"):
"""Return space available on remote device."""
remote_cmd = "dir {}".format(self.file_system)
remote_output = self.ssh_ctl_chan.send_command_expect(remote_cmd)
match = re.search(... |
Return space available on *nix system (BSD/Linux).
def _remote_space_available_unix(self, search_pattern=""):
"""Return space available on *nix system (BSD/Linux)."""
self.ssh_ctl_chan._enter_shell()
remote_cmd = "/bin/df -k {}".format(self.file_system)
remote_output = self.ssh_ctl_chan... |
Verify sufficient space is available on destination file system (return boolean).
def verify_space_available(self, search_pattern=r"(\d+) \w+ free"):
"""Verify sufficient space is available on destination file system (return boolean)."""
if self.direction == "put":
space_avail = self.remote... |
Check if the dest_file already exists on the file system (return boolean).
def _check_file_exists_unix(self, remote_cmd=""):
"""Check if the dest_file already exists on the file system (return boolean)."""
if self.direction == "put":
self.ssh_ctl_chan._enter_shell()
remote_cmd =... |
Get the file size of the remote file.
def remote_file_size(self, remote_cmd="", remote_file=None):
"""Get the file size of the remote file."""
if remote_file is None:
if self.direction == "put":
remote_file = self.dest_file
elif self.direction == "get":
... |
Get the file size of the remote file.
def _remote_file_size_unix(self, remote_cmd="", remote_file=None):
"""Get the file size of the remote file."""
if remote_file is None:
if self.direction == "put":
remote_file = self.dest_file
elif self.direction == "get":
... |
Compute MD5 hash of file.
def file_md5(self, file_name):
"""Compute MD5 hash of file."""
with open(file_name, "rb") as f:
file_contents = f.read()
file_hash = hashlib.md5(file_contents).hexdigest()
return file_hash |
Process the string to retrieve the MD5 hash
Output from Cisco IOS (ASA is similar)
.MD5 of flash:file_name Done!
verify /md5 (flash:file_name) = 410db2a7015eaa42b1fe71f1bf3d59a2
def process_md5(md5_output, pattern=r"=\s+(\S+)"):
"""
Process the string to retrieve the MD5 hash
... |
Compare md5 of file on network device to md5 of local file.
def compare_md5(self):
"""Compare md5 of file on network device to md5 of local file."""
if self.direction == "put":
remote_md5 = self.remote_md5()
return self.source_md5 == remote_md5
elif self.direction == "ge... |
SCP transfer file.
def transfer_file(self):
"""SCP transfer file."""
if self.direction == "put":
self.put_file()
elif self.direction == "get":
self.get_file() |
SCP copy the file from the local system to the remote device.
def put_file(self):
"""SCP copy the file from the local system to the remote device."""
destination = "{}/{}".format(self.file_system, self.dest_file)
self.scp_conn.scp_transfer_file(self.source_file, destination)
# Must clos... |
Enable SCP on remote device.
Defaults to Cisco IOS command
def enable_scp(self, cmd=None):
"""
Enable SCP on remote device.
Defaults to Cisco IOS command
"""
if cmd is None:
cmd = ["ip scp server enable"]
elif not hasattr(cmd, "__iter__"):
... |
Disable SCP on remote device.
Defaults to Cisco IOS command
def disable_scp(self, cmd=None):
"""
Disable SCP on remote device.
Defaults to Cisco IOS command
"""
if cmd is None:
cmd = ["no ip scp server enable"]
elif not hasattr(cmd, "__iter__"):
... |
Exit configuration mode.
def exit_config_mode(self, exit_config="exit", pattern=r">"):
"""Exit configuration mode."""
return super(PaloAltoPanosBase, self).exit_config_mode(
exit_config=exit_config, pattern=pattern
) |
Commit the candidate configuration.
Commit the entered configuration. Raise an error and return the failure
if the commit fails.
Automatically enters configuration mode
default:
command_string = commit
(device_and_network or policy_and_objects or vsys or
... |
Strip command_string from output string.
def strip_command(self, command_string, output):
"""Strip command_string from output string."""
output_list = output.split(command_string)
return self.RESPONSE_RETURN.join(output_list) |
Strip the trailing router prompt from the output.
def strip_prompt(self, a_string):
"""Strip the trailing router prompt from the output."""
response_list = a_string.split(self.RESPONSE_RETURN)
new_response_list = []
for line in response_list:
if self.base_prompt not in line:... |
Strip PaloAlto-specific output.
PaloAlto will also put a configuration context:
[edit]
This method removes those lines.
def strip_context_items(self, a_string):
"""Strip PaloAlto-specific output.
PaloAlto will also put a configuration context:
[edit]
This met... |
Palo Alto requires an extra delay
def send_command(self, *args, **kwargs):
"""Palo Alto requires an extra delay"""
kwargs["delay_factor"] = kwargs.get("delay_factor", 2.5)
return super(PaloAltoPanosBase, self).send_command(*args, **kwargs) |
Gracefully exit the SSH session.
def cleanup(self):
"""Gracefully exit the SSH session."""
try:
self.exit_config_mode()
except Exception:
# Always try to send 'exit' regardless of whether exit_config_mode works or not.
pass
self._session_log_fin = Tru... |
Sets self.base_prompt: used as delimiter for stripping of trailing prompt in output.
def set_base_prompt(
self, pri_prompt_terminator=":", alt_prompt_terminator=">", delay_factor=2
):
"""Sets self.base_prompt: used as delimiter for stripping of trailing prompt in output."""
super(CoriantSSH... |
Checks if the device is in configuration mode or not.
Cisco IOS devices abbreviate the prompt at 20 chars in config mode
def check_config_mode(self, check_string=")#", pattern="#"):
"""
Checks if the device is in configuration mode or not.
Cisco IOS devices abbreviate the prompt at 20... |
Saves Config Using Copy Run Start
def save_config(self, cmd="write mem", confirm=False, confirm_response=""):
"""Saves Config Using Copy Run Start"""
return super(CiscoIosBase, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) |
When using put inside a TCL {} section the newline is considered a new TCL
statement and causes a missing curly-brace message. Convert "\n" to "\r". TCL
will convert the "\r" to a "\n" i.e. you will see a "\n" inside the file on the
Cisco IOS device.
def _tcl_newline_rationalize(tcl_string):
... |
Compute MD5 hash of file.
def file_md5(self, file_name):
"""Compute MD5 hash of file."""
file_contents = self._read_file(file_name)
file_contents = file_contents + "\n" # Cisco IOS automatically adds this
file_contents = file_contents.encode("UTF-8")
return hashlib.md5(file_con... |
Compute MD5 hash of file.
def config_md5(self, source_config):
"""Compute MD5 hash of file."""
file_contents = source_config + "\n" # Cisco IOS automatically adds this
file_contents = file_contents.encode("UTF-8")
return hashlib.md5(file_contents).hexdigest() |
Prepare the session after the connection has been established.
Extra time to read HP banners.
def session_preparation(self):
"""
Prepare the session after the connection has been established.
Extra time to read HP banners.
"""
delay_factor = self.select_delay_factor(dela... |
Exit config mode.
def exit_config_mode(self, exit_config="return", pattern=r">"):
"""Exit config mode."""
return super(HPComwareBase, self).exit_config_mode(
exit_config=exit_config, pattern=pattern
) |
Sets self.base_prompt
Used as delimiter for stripping of trailing prompt in output.
Should be set to something that is general and applies in multiple contexts. For Comware
this will be the router prompt with < > or [ ] stripped off.
This will be set on logging in, but not when enteri... |
Save Config.
def save_config(self, cmd="save force", confirm=False, confirm_response=""):
"""Save Config."""
return super(HPComwareBase, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) |
Try to send an SNMP GET operation using SNMPv3 for the specified OID.
Parameters
----------
oid : str
The SNMP OID that you want to get.
Returns
-------
string : str
The string as part of the value from the OID you are trying to retrieve.
def _g... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.