repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
jopohl/urh
src/urh/signalprocessing/Spectrogram.py
Spectrogram.create_image
def create_image(data: np.ndarray, colormap, data_min=None, data_max=None, normalize=True) -> QImage: """ 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). :retu...
python
def create_image(data: np.ndarray, colormap, data_min=None, data_max=None, normalize=True) -> QImage: """ 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). :retu...
[ "def", "create_image", "(", "data", ":", "np", ".", "ndarray", ",", "colormap", ",", "data_min", "=", "None", ",", "data_max", "=", "None", ",", "normalize", "=", "True", ")", "->", "QImage", ":", "image_data", "=", "Spectrogram", ".", "apply_bgra_lookup",...
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:
[ "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", "(",...
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/Spectrogram.py#L164-L185
train
jopohl/urh
src/urh/signalprocessing/Signal.py
Signal.modulation_type
def modulation_type(self, value: int): """ 0 - "ASK", 1 - "FSK", 2 - "PSK", 3 - "APSK (QAM)" :param value: :return: """ if self.__modulation_type != value: self.__modulation_type = value self._qad = None self.modulation_type_changed.e...
python
def modulation_type(self, value: int): """ 0 - "ASK", 1 - "FSK", 2 - "PSK", 3 - "APSK (QAM)" :param value: :return: """ if self.__modulation_type != value: self.__modulation_type = value self._qad = None self.modulation_type_changed.e...
[ "def", "modulation_type", "(", "self", ",", "value", ":", "int", ")", ":", "if", "self", ".", "__modulation_type", "!=", "value", ":", "self", ".", "__modulation_type", "=", "value", "self", ".", "_qad", "=", "None", "self", ".", "modulation_type_changed", ...
0 - "ASK", 1 - "FSK", 2 - "PSK", 3 - "APSK (QAM)" :param value: :return:
[ "0", "-", "ASK", "1", "-", "FSK", "2", "-", "PSK", "3", "-", "APSK", "(", "QAM", ")" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/Signal.py#L171-L184
train
jopohl/urh
src/urh/signalprocessing/Signal.py
Signal.estimate_frequency
def estimate_frequency(self, start: int, end: int, sample_rate: float): """ 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 o...
python
def estimate_frequency(self, start: int, end: int, sample_rate: float): """ 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 o...
[ "def", "estimate_frequency", "(", "self", ",", "start", ":", "int", ",", "end", ":", "int", ",", "sample_rate", ":", "float", ")", ":", "# ensure power of 2 for faster fft", "length", "=", "2", "**", "int", "(", "math", ".", "log2", "(", "end", "-", "sta...
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:
[ "Estimate", "the", "frequency", "of", "the", "baseband", "signal", "using", "FFT" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/Signal.py#L410-L433
train
jopohl/urh
src/urh/ui/views/FuzzingTableView.py
FuzzingTableView.selection_range
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 selected]) max_row ...
python
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 selected]) max_row ...
[ "def", "selection_range", "(", "self", ")", ":", "selected", "=", "self", ".", "selectionModel", "(", ")", ".", "selection", "(", ")", "\"\"\":type: QItemSelection \"\"\"", "if", "selected", ".", "isEmpty", "(", ")", ":", "return", "-", "1", ",", "-", "1",...
:rtype: int, int, int, int
[ ":", "rtype", ":", "int", "int", "int", "int" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/ui/views/FuzzingTableView.py#L22-L37
train
jopohl/urh
src/urh/main.py
fix_windows_stdout_stderr
def fix_windows_stdout_stderr(): """ 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 """ if hasattr...
python
def fix_windows_stdout_stderr(): """ 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 """ if hasattr...
[ "def", "fix_windows_stdout_stderr", "(", ")", ":", "if", "hasattr", "(", "sys", ",", "\"frozen\"", ")", "and", "sys", ".", "platform", "==", "\"win32\"", ":", "try", ":", "sys", ".", "stdout", ".", "write", "(", "\"\\n\"", ")", "sys", ".", "stdout", "....
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
[ "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", ...
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/main.py#L23-L47
train
jopohl/urh
src/urh/awre/FormatFinder.py
FormatFinder.build_component_order
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 in self.__dict__.values() if isinstance(item, Component) and item.enabled] result = [None] * len(p...
python
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 in self.__dict__.values() if isinstance(item, Component) and item.enabled] result = [None] * len(p...
[ "def", "build_component_order", "(", "self", ")", ":", "present_components", "=", "[", "item", "for", "item", "in", "self", ".", "__dict__", ".", "values", "(", ")", "if", "isinstance", "(", "item", ",", "Component", ")", "and", "item", ".", "enabled", "...
Build the order of component based on their priority and predecessors :rtype: list of Component
[ "Build", "the", "order", "of", "component", "based", "on", "their", "priority", "and", "predecessors" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/awre/FormatFinder.py#L48-L70
train
jopohl/urh
src/urh/awre/FormatFinder.py
FormatFinder.cluster_lengths
def cluster_lengths(self): """ 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 d...
python
def cluster_lengths(self): """ 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 d...
[ "def", "cluster_lengths", "(", "self", ")", ":", "number_ones", "=", "dict", "(", ")", "# dict of tuple. 0 = number ones vector, 1 = number of blocks for this vector", "for", "vector", "in", "self", ".", "bitvectors", ":", "vec_len", "=", "4", "*", "(", "len", "(", ...
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 ...
[ "This", "method", "clusters", "some", "bitvectors", "based", "on", "their", "length", ".", "An", "example", "output", "is" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/awre/FormatFinder.py#L77-L106
train
jopohl/urh
src/urh/awre/components/Address.py
Address.find_candidates
def find_candidates(candidates): """ 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', '20701b603378e2890...
python
def find_candidates(candidates): """ 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', '20701b603378e2890...
[ "def", "find_candidates", "(", "candidates", ")", ":", "result", "=", "defaultdict", "(", "int", ")", "for", "i", ",", "c_i", "in", "enumerate", "(", "candidates", ")", ":", "for", "j", "in", "range", "(", "i", ",", "len", "(", "candidates", ")", ")"...
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...
[ "Find", "candidate", "addresses", "using", "LCS", "algorithm", "perform", "a", "scoring", "based", "on", "how", "often", "a", "candidate", "appears", "in", "a", "longer", "candidate" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/awre/components/Address.py#L190-L217
train
jopohl/urh
src/urh/awre/components/Address.py
Address.choose_candidate_pair
def choose_candidate_pair(candidates): """ 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 ...
python
def choose_candidate_pair(candidates): """ 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 ...
[ "def", "choose_candidate_pair", "(", "candidates", ")", ":", "highscored", "=", "sorted", "(", "candidates", ",", "key", "=", "candidates", ".", "get", ",", "reverse", "=", "True", ")", "for", "i", ",", "h_i", "in", "enumerate", "(", "highscored", ")", "...
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:
[ "Choose", "a", "pair", "of", "address", "candidates", "ensuring", "they", "have", "the", "same", "length", "and", "starting", "with", "the", "highest", "scored", "ones" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/awre/components/Address.py#L220-L232
train
jopohl/urh
src/urh/util/FileOperator.py
uncompress_archives
def uncompress_archives(file_names, temp_dir): """ 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 """ result = [] for filename in file_names: ...
python
def uncompress_archives(file_names, temp_dir): """ 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 """ result = [] for filename in file_names: ...
[ "def", "uncompress_archives", "(", "file_names", ",", "temp_dir", ")", ":", "result", "=", "[", "]", "for", "filename", "in", "file_names", ":", "if", "filename", ".", "endswith", "(", "\".tar\"", ")", "or", "filename", ".", "endswith", "(", "\".tar.gz\"", ...
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
[ "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_...
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/util/FileOperator.py#L63-L95
train
jopohl/urh
src/urh/util/ProjectManager.py
ProjectManager.write_modulators_to_project_file
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 = ET.parse(self.project_file) root = tree.getroo...
python
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 = ET.parse(self.project_file) root = tree.getroo...
[ "def", "write_modulators_to_project_file", "(", "self", ",", "tree", "=", "None", ")", ":", "if", "self", ".", "project_file", "is", "None", "or", "not", "self", ".", "modulators", ":", "return", "if", "tree", "is", "None", ":", "tree", "=", "ET", ".", ...
:type modulators: list of Modulator :return:
[ ":", "type", "modulators", ":", "list", "of", "Modulator", ":", "return", ":" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/util/ProjectManager.py#L331-L345
train
jopohl/urh
src/urh/ainterpretation/Wavelet.py
cwt_haar
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 Gilbert P Compo """ next_power_two = 2 ** int(np.log2(len(x))) x = x[0:next_power_two] num_data = len(x) # get FFT of x (...
python
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 Gilbert P Compo """ next_power_two = 2 ** int(np.log2(len(x))) x = x[0:next_power_two] num_data = len(x) # get FFT of x (...
[ "def", "cwt_haar", "(", "x", ":", "np", ".", "ndarray", ",", "scale", "=", "10", ")", ":", "next_power_two", "=", "2", "**", "int", "(", "np", ".", "log2", "(", "len", "(", "x", ")", ")", ")", "x", "=", "x", "[", "0", ":", "next_power_two", "...
continuous haar wavelet transform based on the paper "A practical guide to wavelet analysis" by Christopher Torrence and Gilbert P Compo
[ "continuous", "haar", "wavelet", "transform", "based", "on", "the", "paper", "A", "practical", "guide", "to", "wavelet", "analysis", "by", "Christopher", "Torrence", "and", "Gilbert", "P", "Compo" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/ainterpretation/Wavelet.py#L15-L39
train
jopohl/urh
src/urh/awre/components/Preamble.py
Preamble.__find_sync_range
def __find_sync_range(self, messages, preamble_end: int, search_end: int): """ 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 ...
python
def __find_sync_range(self, messages, preamble_end: int, search_end: int): """ 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 ...
[ "def", "__find_sync_range", "(", "self", ",", "messages", ",", "preamble_end", ":", "int", ",", "search_end", ":", "int", ")", ":", "possible_sync_pos", "=", "defaultdict", "(", "int", ")", "for", "i", ",", "msg", "in", "enumerate", "(", "messages", ")", ...
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...
[ "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" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/awre/components/Preamble.py#L95-L121
train
jopohl/urh
src/urh/models/TableModel.py
TableModel.__pad_until_index
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: """ try: new_bits = array.array("B", [0] * max(0, bit_pos - len(self.protocol.messages[row]))) ...
python
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: """ try: new_bits = array.array("B", [0] * max(0, bit_pos - len(self.protocol.messages[row]))) ...
[ "def", "__pad_until_index", "(", "self", ",", "row", ":", "int", ",", "bit_pos", ":", "int", ")", ":", "try", ":", "new_bits", "=", "array", ".", "array", "(", "\"B\"", ",", "[", "0", "]", "*", "max", "(", "0", ",", "bit_pos", "-", "len", "(", ...
Pad message in given row with zeros until given column so user can enter values behind end of message :return:
[ "Pad", "message", "in", "given", "row", "with", "zeros", "until", "given", "column", "so", "user", "can", "enter", "values", "behind", "end", "of", "message", ":", "return", ":" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/models/TableModel.py#L84-L101
train
jopohl/urh
src/urh/models/TableModel.py
TableModel.find_differences
def find_differences(self, refindex: int): """ Search all differences between protocol messages regarding a reference message :param refindex: index of reference message :rtype: dict[int, set[int]] """ differences = defaultdict(set) if refindex >= len(self.proto...
python
def find_differences(self, refindex: int): """ Search all differences between protocol messages regarding a reference message :param refindex: index of reference message :rtype: dict[int, set[int]] """ differences = defaultdict(set) if refindex >= len(self.proto...
[ "def", "find_differences", "(", "self", ",", "refindex", ":", "int", ")", ":", "differences", "=", "defaultdict", "(", "set", ")", "if", "refindex", ">=", "len", "(", "self", ".", "protocol", ".", "messages", ")", ":", "return", "differences", "if", "sel...
Search all differences between protocol messages regarding a reference message :param refindex: index of reference message :rtype: dict[int, set[int]]
[ "Search", "all", "differences", "between", "protocol", "messages", "regarding", "a", "reference", "message" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/models/TableModel.py#L337-L373
train
jopohl/urh
src/urh/signalprocessing/ProtocolSniffer.py
ProtocolSniffer.__demodulate_data
def __demodulate_data(self, data): """ Demodulates received IQ data and adds demodulated bits to messages :param data: :return: """ if len(data) == 0: return power_spectrum = data.real ** 2 + data.imag ** 2 is_above_noise = np.sqrt(np.mean(pow...
python
def __demodulate_data(self, data): """ Demodulates received IQ data and adds demodulated bits to messages :param data: :return: """ if len(data) == 0: return power_spectrum = data.real ** 2 + data.imag ** 2 is_above_noise = np.sqrt(np.mean(pow...
[ "def", "__demodulate_data", "(", "self", ",", "data", ")", ":", "if", "len", "(", "data", ")", "==", "0", ":", "return", "power_spectrum", "=", "data", ".", "real", "**", "2", "+", "data", ".", "imag", "**", "2", "is_above_noise", "=", "np", ".", "...
Demodulates received IQ data and adds demodulated bits to messages :param data: :return:
[ "Demodulates", "received", "IQ", "data", "and", "adds", "demodulated", "bits", "to", "messages", ":", "param", "data", ":", ":", "return", ":" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/ProtocolSniffer.py#L155-L203
train
jopohl/urh
src/urh/ui/painting/SceneManager.py
SceneManager.create_rectangle
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: for bit in msg: ...
python
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: for bit in msg: ...
[ "def", "create_rectangle", "(", "proto_bits", ",", "pulse_len", "=", "100", ")", ":", "ones", "=", "np", ".", "ones", "(", "pulse_len", ",", "dtype", "=", "np", ".", "float32", ")", "*", "1", "zeros", "=", "np", ".", "ones", "(", "pulse_len", ",", ...
:type proto_bits: list of str
[ ":", "type", "proto_bits", ":", "list", "of", "str" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/ui/painting/SceneManager.py#L107-L133
train
jopohl/urh
src/urh/ui/painting/SpectrogramSceneManager.py
SpectrogramSceneManager.set_parameters
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_needed = True self.samp...
python
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_needed = True self.samp...
[ "def", "set_parameters", "(", "self", ",", "samples", ":", "np", ".", "ndarray", ",", "window_size", ",", "data_min", ",", "data_max", ")", "->", "bool", ":", "redraw_needed", "=", "False", "if", "self", ".", "samples_need_update", ":", "self", ".", "spect...
Return true if redraw is needed
[ "Return", "true", "if", "redraw", "is", "needed" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/ui/painting/SpectrogramSceneManager.py#L24-L46
train
jopohl/urh
src/urh/plugins/MessageBreak/MessageBreakPlugin.py
MessageBreakPlugin.get_action
def get_action(self, parent, undo_stack: QUndoStack, sel_range, protocol: ProtocolAnalyzer, view: int): """ :type parent: QTableView :type undo_stack: QUndoStack :type protocol_analyzers: list of ProtocolAnalyzer """ min_row, max_row, start, end = sel_range if min...
python
def get_action(self, parent, undo_stack: QUndoStack, sel_range, protocol: ProtocolAnalyzer, view: int): """ :type parent: QTableView :type undo_stack: QUndoStack :type protocol_analyzers: list of ProtocolAnalyzer """ min_row, max_row, start, end = sel_range if min...
[ "def", "get_action", "(", "self", ",", "parent", ",", "undo_stack", ":", "QUndoStack", ",", "sel_range", ",", "protocol", ":", "ProtocolAnalyzer", ",", "view", ":", "int", ")", ":", "min_row", ",", "max_row", ",", "start", ",", "end", "=", "sel_range", "...
:type parent: QTableView :type undo_stack: QUndoStack :type protocol_analyzers: list of ProtocolAnalyzer
[ ":", "type", "parent", ":", "QTableView", ":", "type", "undo_stack", ":", "QUndoStack", ":", "type", "protocol_analyzers", ":", "list", "of", "ProtocolAnalyzer" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/plugins/MessageBreak/MessageBreakPlugin.py#L16-L36
train
jopohl/urh
src/urh/signalprocessing/Message.py
Message.get_byte_length
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] return int(end)
python
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] return int(end)
[ "def", "get_byte_length", "(", "self", ",", "decoded", "=", "True", ")", "->", "int", ":", "end", "=", "len", "(", "self", ".", "decoded_bits", ")", "if", "decoded", "else", "len", "(", "self", ".", "__plain_bits", ")", "end", "=", "self", ".", "conv...
Return the length of this message in byte.
[ "Return", "the", "length", "of", "this", "message", "in", "byte", "." ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/Message.py#L155-L162
train
jopohl/urh
src/urh/signalprocessing/Message.py
Message.get_src_address_from_data
def get_src_address_from_data(self, decoded=True): """ 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: """ src_address_label = next((lbl for lbl in self.message_type...
python
def get_src_address_from_data(self, decoded=True): """ 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: """ src_address_label = next((lbl for lbl in self.message_type...
[ "def", "get_src_address_from_data", "(", "self", ",", "decoded", "=", "True", ")", ":", "src_address_label", "=", "next", "(", "(", "lbl", "for", "lbl", "in", "self", ".", "message_type", "if", "lbl", ".", "field_type", "and", "lbl", ".", "field_type", "."...
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:
[ "Return", "the", "SRC", "address", "of", "a", "message", "if", "SRC_ADDRESS", "label", "is", "present", "in", "message", "type", "of", "the", "message", "Return", "None", "otherwise" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/Message.py#L360-L379
train
jopohl/urh
src/urh/signalprocessing/Message.py
Message.split
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.decoded_bits if decode else self.plain_bits bit_alignments = set() if self.align_labe...
python
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.decoded_bits if decode else self.plain_bits bit_alignments = set() if self.align_labe...
[ "def", "split", "(", "self", ",", "decode", "=", "True", ")", ":", "start", "=", "0", "result", "=", "[", "]", "message", "=", "self", ".", "decoded_bits", "if", "decode", "else", "self", ".", "plain_bits", "bit_alignments", "=", "set", "(", ")", "if...
Für das Bit-Alignment (neu Ausrichten von Hex, ASCII-View) :rtype: list of array.array
[ "Für", "das", "Bit", "-", "Alignment", "(", "neu", "Ausrichten", "von", "Hex", "ASCII", "-", "View", ")" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/Message.py#L409-L431
train
jopohl/urh
src/urh/controller/dialogs/DecoderDialog.py
DecoderDialog.set_e
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() self.chainoptions...
python
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() self.chainoptions...
[ "def", "set_e", "(", "self", ")", ":", "if", "self", ".", "ui", ".", "combobox_decodings", ".", "count", "(", ")", "<", "1", ":", "# Empty list", "return", "self", ".", "e", "=", "copy", ".", "deepcopy", "(", "self", ".", "decodings", "[", "self", ...
:type: encoding
[ ":", "type", ":", "encoding" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/controller/dialogs/DecoderDialog.py#L202-L230
train
jopohl/urh
src/urh/models/ProtocolTreeModel.py
ProtocolTreeModel.protocols
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
python
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
[ "def", "protocols", "(", "self", ")", ":", "result", "=", "{", "}", "for", "i", ",", "group", "in", "enumerate", "(", "self", ".", "rootItem", ".", "children", ")", ":", "result", "[", "i", "]", "=", "[", "child", ".", "protocol", "for", "child", ...
:rtype: dict[int, list of ProtocolAnalyzer]
[ ":", "rtype", ":", "dict", "[", "int", "list", "of", "ProtocolAnalyzer", "]" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/models/ProtocolTreeModel.py#L25-L33
train
jopohl/urh
src/urh/models/ProtocolTreeModel.py
ProtocolTreeModel.protocol_tree_items
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
python
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
[ "def", "protocol_tree_items", "(", "self", ")", ":", "result", "=", "{", "}", "for", "i", ",", "group", "in", "enumerate", "(", "self", ".", "rootItem", ".", "children", ")", ":", "result", "[", "i", "]", "=", "[", "child", "for", "child", "in", "g...
:rtype: dict[int, list of ProtocolTreeItem]
[ ":", "rtype", ":", "dict", "[", "int", "list", "of", "ProtocolTreeItem", "]" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/models/ProtocolTreeModel.py#L48-L56
train
jopohl/urh
src/urh/models/ProtocolTreeModel.py
ProtocolTreeModel.move_to_group
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()
python
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()
[ "def", "move_to_group", "(", "self", ",", "items", ",", "new_group_id", ":", "int", ")", ":", "group", "=", "self", ".", "rootItem", ".", "child", "(", "new_group_id", ")", "for", "item", "in", "items", ":", "group", ".", "appendChild", "(", "item", ")...
:type items: list of ProtocolTreeItem
[ ":", "type", "items", ":", "list", "of", "ProtocolTreeItem" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/models/ProtocolTreeModel.py#L326-L333
train
jopohl/urh
src/urh/models/ProtocolTreeModel.py
ProtocolTreeModel.set_copy_mode
def set_copy_mode(self, use_copy: bool): """ 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: """ for group in self.rootItem.children: for proto in group.childr...
python
def set_copy_mode(self, use_copy: bool): """ 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: """ for group in self.rootItem.children: for proto in group.childr...
[ "def", "set_copy_mode", "(", "self", ",", "use_copy", ":", "bool", ")", ":", "for", "group", "in", "self", ".", "rootItem", ".", "children", ":", "for", "proto", "in", "group", ".", "children", ":", "proto", ".", "copy_data", "=", "use_copy" ]
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:
[ "Set", "all", "protocols", "in", "copy", "mode", ".", "They", "will", "return", "a", "copy", "of", "their", "protocol", ".", "This", "is", "used", "for", "writable", "mode", "in", "CFC", "." ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/models/ProtocolTreeModel.py#L341-L351
train
jopohl/urh
src/urh/util/RingBuffer.py
RingBuffer.view_data
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: """ left, right = self.left_index, self.left_index + len(self) if left > right: left, right = right, left ...
python
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: """ left, right = self.left_index, self.left_index + len(self) if left > right: left, right = right, left ...
[ "def", "view_data", "(", "self", ")", ":", "left", ",", "right", "=", "self", ".", "left_index", ",", "self", ".", "left_index", "+", "len", "(", "self", ")", "if", "left", ">", "right", ":", "left", ",", "right", "=", "right", ",", "left", "data",...
Get a representation of the ring buffer for plotting. This is expensive, so it should only be used in frontend :return:
[ "Get", "a", "representation", "of", "the", "ring", "buffer", "for", "plotting", ".", "This", "is", "expensive", "so", "it", "should", "only", "be", "used", "in", "frontend", ":", "return", ":" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/util/RingBuffer.py#L48-L58
train
jopohl/urh
src/urh/util/RingBuffer.py
RingBuffer.push
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("Too much data to push to RingBuffer") slide_1 = np.s_[self.right_index:m...
python
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("Too much data to push to RingBuffer") slide_1 = np.s_[self.right_index:m...
[ "def", "push", "(", "self", ",", "values", ":", "np", ".", "ndarray", ")", ":", "n", "=", "len", "(", "values", ")", "if", "len", "(", "self", ")", "+", "n", ">", "self", ".", "size", ":", "raise", "ValueError", "(", "\"Too much data to push to RingB...
Push values to buffer. If buffer can't store all values a ValueError is raised
[ "Push", "values", "to", "buffer", ".", "If", "buffer", "can", "t", "store", "all", "values", "a", "ValueError", "is", "raised" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/util/RingBuffer.py#L67-L83
train
jopohl/urh
src/urh/util/RingBuffer.py
RingBuffer.pop
def pop(self, number: int, ensure_even_length=False): """ 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 z...
python
def pop(self, number: int, ensure_even_length=False): """ 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 z...
[ "def", "pop", "(", "self", ",", "number", ":", "int", ",", "ensure_even_length", "=", "False", ")", ":", "if", "ensure_even_length", ":", "number", "-=", "number", "%", "2", "if", "len", "(", "self", ")", "==", "0", "or", "number", "==", "0", ":", ...
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
[ "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", ...
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/util/RingBuffer.py#L85-L121
train
jopohl/urh
src/urh/signalprocessing/Encoding.py
Encoding.code_data_whitening
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_whitening(decoding, inpt_copy)
python
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_whitening(decoding, inpt_copy)
[ "def", "code_data_whitening", "(", "self", ",", "decoding", ",", "inpt", ")", ":", "inpt_copy", "=", "array", ".", "array", "(", "\"B\"", ",", "inpt", ")", "return", "self", ".", "apply_data_whitening", "(", "decoding", ",", "inpt_copy", ")" ]
XOR Data Whitening :param decoding: :param inpt: :return:
[ "XOR", "Data", "Whitening", ":", "param", "decoding", ":", ":", "param", "inpt", ":", ":", "return", ":" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/Encoding.py#L451-L459
train
jopohl/urh
src/urh/plugins/ZeroHide/ZeroHidePlugin.py
ZeroHidePlugin.get_action
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, self.zero_hide_offsets) action = QAction(self.command.te...
python
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, self.zero_hide_offsets) action = QAction(self.command.te...
[ "def", "get_action", "(", "self", ",", "parent", ",", "undo_stack", ":", "QUndoStack", ",", "sel_range", ",", "protocol", ",", "view", ":", "int", ")", ":", "self", ".", "command", "=", "ZeroHideAction", "(", "protocol", ",", "self", ".", "following_zeros"...
:type parent: QTableView :type undo_stack: QUndoStack
[ ":", "type", "parent", ":", "QTableView", ":", "type", "undo_stack", ":", "QUndoStack" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/plugins/ZeroHide/ZeroHidePlugin.py#L24-L33
train
jopohl/urh
src/urh/ui/views/SelectableGraphicView.py
SelectableGraphicView.scroll_mouse
def scroll_mouse(self, mouse_x: int): """ Scrolls the mouse if ROI Selection reaches corner of view :param mouse_x: :return: """ scrollbar = self.horizontalScrollBar() if mouse_x - self.view_rect().x() > self.view_rect().width(): scrollbar.setValue(s...
python
def scroll_mouse(self, mouse_x: int): """ Scrolls the mouse if ROI Selection reaches corner of view :param mouse_x: :return: """ scrollbar = self.horizontalScrollBar() if mouse_x - self.view_rect().x() > self.view_rect().width(): scrollbar.setValue(s...
[ "def", "scroll_mouse", "(", "self", ",", "mouse_x", ":", "int", ")", ":", "scrollbar", "=", "self", ".", "horizontalScrollBar", "(", ")", "if", "mouse_x", "-", "self", ".", "view_rect", "(", ")", ".", "x", "(", ")", ">", "self", ".", "view_rect", "("...
Scrolls the mouse if ROI Selection reaches corner of view :param mouse_x: :return:
[ "Scrolls", "the", "mouse", "if", "ROI", "Selection", "reaches", "corner", "of", "view" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/ui/views/SelectableGraphicView.py#L207-L220
train
jopohl/urh
src/urh/ui/views/SelectableGraphicView.py
SelectableGraphicView.refresh_selection_area
def refresh_selection_area(self): """ Refresh selection area in case scene was resized/scaled. This happens e.g. when switching from Signal View to Quad Demod view :return: """ self.__set_selection_area(x=self.selection_area.x, y=self.selection_area.y, ...
python
def refresh_selection_area(self): """ Refresh selection area in case scene was resized/scaled. This happens e.g. when switching from Signal View to Quad Demod view :return: """ self.__set_selection_area(x=self.selection_area.x, y=self.selection_area.y, ...
[ "def", "refresh_selection_area", "(", "self", ")", ":", "self", ".", "__set_selection_area", "(", "x", "=", "self", ".", "selection_area", ".", "x", ",", "y", "=", "self", ".", "selection_area", ".", "y", ",", "w", "=", "self", ".", "selection_area", "."...
Refresh selection area in case scene was resized/scaled. This happens e.g. when switching from Signal View to Quad Demod view :return:
[ "Refresh", "selection", "area", "in", "case", "scene", "was", "resized", "/", "scaled", ".", "This", "happens", "e", ".", "g", ".", "when", "switching", "from", "Signal", "View", "to", "Quad", "Demod", "view", ":", "return", ":" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/ui/views/SelectableGraphicView.py#L252-L259
train
jopohl/urh
src/urh/ui/views/SelectableGraphicView.py
SelectableGraphicView.view_rect
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) return QRectF(top_left, bottom_right)
python
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) return QRectF(top_left, bottom_right)
[ "def", "view_rect", "(", "self", ")", "->", "QRectF", ":", "top_left", "=", "self", ".", "mapToScene", "(", "0", ",", "0", ")", "bottom_right", "=", "self", ".", "mapToScene", "(", "self", ".", "viewport", "(", ")", ".", "width", "(", ")", "-", "1"...
Return the boundaries of the view in scene coordinates
[ "Return", "the", "boundaries", "of", "the", "view", "in", "scene", "coordinates" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/ui/views/SelectableGraphicView.py#L317-L323
train
jopohl/urh
src/urh/ui/SimulatorScene.py
SimulatorScene.dropEvent
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_dropped.emit(event.mimeData().urls()) ...
python
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_dropped.emit(event.mimeData().urls()) ...
[ "def", "dropEvent", "(", "self", ",", "event", ":", "QDropEvent", ")", ":", "items", "=", "[", "item", "for", "item", "in", "self", ".", "items", "(", "event", ".", "scenePos", "(", ")", ")", "if", "isinstance", "(", "item", ",", "GraphicsItem", ")",...
:type: list of ProtocolTreeItem
[ ":", "type", ":", "list", "of", "ProtocolTreeItem" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/ui/SimulatorScene.py#L376-L412
train
jopohl/urh
src/urh/util/util.py
convert_bits_to_string
def convert_bits_to_string(bits, output_view_type: int, pad_zeros=False, lsb=False, lsd=False, endianness="big"): """ 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 ...
python
def convert_bits_to_string(bits, output_view_type: int, pad_zeros=False, lsb=False, lsd=False, endianness="big"): """ 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 ...
[ "def", "convert_bits_to_string", "(", "bits", ",", "output_view_type", ":", "int", ",", "pad_zeros", "=", "False", ",", "lsb", "=", "False", ",", "lsd", "=", "False", ",", "endianness", "=", "\"big\"", ")", ":", "bits_str", "=", "\"\"", ".", "join", "(",...
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...
[ "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", "=...
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/util/util.py#L88-L142
train
jopohl/urh
src/urh/signalprocessing/ProtocolAnalyzer.py
ProtocolAnalyzer.__ensure_message_length_multiple
def __ensure_message_length_multiple(bit_data, bit_len: int, pauses, bit_sample_pos, divisor: int): """ 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 ...
python
def __ensure_message_length_multiple(bit_data, bit_len: int, pauses, bit_sample_pos, divisor: int): """ 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 ...
[ "def", "__ensure_message_length_multiple", "(", "bit_data", ",", "bit_len", ":", "int", ",", "pauses", ",", "bit_sample_pos", ",", "divisor", ":", "int", ")", ":", "for", "i", "in", "range", "(", "len", "(", "bit_data", ")", ")", ":", "missing_bits", "=", ...
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...
[ "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", ":...
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/ProtocolAnalyzer.py#L246-L269
train
jopohl/urh
src/urh/signalprocessing/ProtocolAnalyzer.py
ProtocolAnalyzer.get_samplepos_of_bitseq
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) a bit sequence is :rtype: tuple[int,int] """ try: if start_...
python
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) a bit sequence is :rtype: tuple[int,int] """ try: if start_...
[ "def", "get_samplepos_of_bitseq", "(", "self", ",", "start_message", ":", "int", ",", "start_index", ":", "int", ",", "end_message", ":", "int", ",", "end_index", ":", "int", ",", "include_pause", ":", "bool", ")", ":", "try", ":", "if", "start_message", "...
Determine on which place (regarding samples) a bit sequence is :rtype: tuple[int,int]
[ "Determine", "on", "which", "place", "(", "regarding", "samples", ")", "a", "bit", "sequence", "is", ":", "rtype", ":", "tuple", "[", "int", "int", "]" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/ProtocolAnalyzer.py#L349-L374
train
jopohl/urh
src/urh/signalprocessing/ProtocolAnalyzer.py
ProtocolAnalyzer.get_bitseq_from_selection
def get_bitseq_from_selection(self, selection_start: int, selection_width: int): """ 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 """ start_message, st...
python
def get_bitseq_from_selection(self, selection_start: int, selection_width: int): """ 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 """ start_message, st...
[ "def", "get_bitseq_from_selection", "(", "self", ",", "selection_start", ":", "int", ",", "selection_width", ":", "int", ")", ":", "start_message", ",", "start_index", ",", "end_message", ",", "end_index", "=", "-", "1", ",", "-", "1", ",", "-", "1", ",", ...
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
[ "get", "start", "and", "end", "index", "of", "bit", "sequence", "from", "selected", "samples" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/ProtocolAnalyzer.py#L376-L414
train
jopohl/urh
src/urh/signalprocessing/ProtocolAnalyzer.py
ProtocolAnalyzer.convert_index
def convert_index(self, index: int, from_view: int, to_view: int, decoded: bool, message_indx=-1) -> tuple: """ 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: """ ...
python
def convert_index(self, index: int, from_view: int, to_view: int, decoded: bool, message_indx=-1) -> tuple: """ 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", ":", "if", "len", "(", "self", ".", "messa...
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:
[ "Konvertiert", "einen", "Index", "aus", "der", "einen", "Sicht", "(", "z", ".", "B", ".", "Bit", ")", "in", "eine", "andere", "(", "z", ".", "B", ".", "Hex", ")" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/ProtocolAnalyzer.py#L439-L455
train
jopohl/urh
src/urh/signalprocessing/ProtocolAnalyzer.py
ProtocolAnalyzer.estimate_frequency_for_one
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 frequencies :param nbits: :return: """ return self.__estimate_frequency_for_bit(True, sample_rate, nbits)
python
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 frequencies :param nbits: :return: """ return self.__estimate_frequency_for_bit(True, sample_rate, nbits)
[ "def", "estimate_frequency_for_one", "(", "self", ",", "sample_rate", ":", "float", ",", "nbits", "=", "42", ")", "->", "float", ":", "return", "self", ".", "__estimate_frequency_for_bit", "(", "True", ",", "sample_rate", ",", "nbits", ")" ]
Calculates the frequency of at most nbits logical ones and returns the mean of these frequencies :param nbits: :return:
[ "Calculates", "the", "frequency", "of", "at", "most", "nbits", "logical", "ones", "and", "returns", "the", "mean", "of", "these", "frequencies" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/ProtocolAnalyzer.py#L470-L477
train
jopohl/urh
src/urh/signalprocessing/ProtocolAnalyzer.py
ProtocolAnalyzer.estimate_frequency_for_zero
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 these frequencies :param nbits: :return: """ return self.__estimate_frequency_for_bit(False, sample_rate, nbi...
python
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 these frequencies :param nbits: :return: """ return self.__estimate_frequency_for_bit(False, sample_rate, nbi...
[ "def", "estimate_frequency_for_zero", "(", "self", ",", "sample_rate", ":", "float", ",", "nbits", "=", "42", ")", "->", "float", ":", "return", "self", ".", "__estimate_frequency_for_bit", "(", "False", ",", "sample_rate", ",", "nbits", ")" ]
Calculates the frequency of at most nbits logical zeros and returns the mean of these frequencies :param nbits: :return:
[ "Calculates", "the", "frequency", "of", "at", "most", "nbits", "logical", "zeros", "and", "returns", "the", "mean", "of", "these", "frequencies" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/ProtocolAnalyzer.py#L496-L503
train
jopohl/urh
src/urh/signalprocessing/ProtocolAnalyzer.py
ProtocolAnalyzer.auto_assign_decodings
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 candidate_decodings = [decoding for dec...
python
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 candidate_decodings = [decoding for dec...
[ "def", "auto_assign_decodings", "(", "self", ",", "decodings", ")", ":", "nrz_decodings", "=", "[", "decoding", "for", "decoding", "in", "decodings", "if", "decoding", ".", "is_nrz", "or", "decoding", ".", "is_nrzi", "]", "fallback", "=", "nrz_decodings", "[",...
:type decodings: list of Encoding
[ ":", "type", "decodings", ":", "list", "of", "Encoding" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/ProtocolAnalyzer.py#L718-L737
train
jopohl/urh
src/urh/ui/views/MessageTypeTableView.py
MessageTypeTableView.selection_range
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(rng.bottom() for rng...
python
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(rng.bottom() for rng...
[ "def", "selection_range", "(", "self", ")", ":", "selected", "=", "self", ".", "selectionModel", "(", ")", ".", "selection", "(", ")", "\"\"\":type: QItemSelection \"\"\"", "if", "selected", ".", "isEmpty", "(", ")", ":", "return", "-", "1", ",", "-", "1",...
:rtype: int, int
[ ":", "rtype", ":", "int", "int" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/ui/views/MessageTypeTableView.py#L33-L46
train
jopohl/urh
data/release.py
cleanup
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.rmtree(os.path.join(script_dir, "dist"), ignore...
python
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.rmtree(os.path.join(script_dir, "dist"), ignore...
[ "def", "cleanup", "(", ")", ":", "script_dir", "=", "os", ".", "path", ".", "dirname", "(", "__file__", ")", "if", "not", "os", ".", "path", ".", "islink", "(", "__file__", ")", "else", "os", ".", "path", ".", "dirname", "(", "os", ".", "readlink",...
Remove all cache directories :return:
[ "Remove", "all", "cache", "directories", ":", "return", ":" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/data/release.py#L9-L20
train
jopohl/urh
src/urh/ui/views/TableView.py
TableView.selection_range
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.row(), rng.column() t...
python
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.row(), rng.column() t...
[ "def", "selection_range", "(", "self", ")", ":", "selected", "=", "self", ".", "selectionModel", "(", ")", ".", "selection", "(", ")", "# type: QItemSelection", "if", "self", ".", "selection_is_empty", ":", "return", "-", "1", ",", "-", "1", ",", "-", "1...
:rtype: int, int, int, int
[ ":", "rtype", ":", "int", "int", "int", "int" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/ui/views/TableView.py#L106-L120
train
jopohl/urh
src/urh/ainterpretation/AutoInterpretation.py
get_most_frequent_value
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 values :param values: :return: """ if len(values) == 0: return None most_common = Counter(values).most_common() result, ...
python
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 values :param values: :return: """ if len(values) == 0: return None most_common = Counter(values).most_common() result, ...
[ "def", "get_most_frequent_value", "(", "values", ":", "list", ")", ":", "if", "len", "(", "values", ")", "==", "0", ":", "return", "None", "most_common", "=", "Counter", "(", "values", ")", ".", "most_common", "(", ")", "result", ",", "max_count", "=", ...
Return the most frequent value in list. If there is no unique one, return the maximum of the most frequent values :param values: :return:
[ "Return", "the", "most", "frequent", "value", "in", "list", ".", "If", "there", "is", "no", "unique", "one", "return", "the", "maximum", "of", "the", "most", "frequent", "values" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/ainterpretation/AutoInterpretation.py#L28-L47
train
jopohl/urh
src/urh/ainterpretation/AutoInterpretation.py
segment_messages_from_magnitudes
def segment_messages_from_magnitudes(magnitudes: np.ndarray, noise_threshold: float): """ Get the list of start, end indices of messages :param magnitudes: Magnitudes of samples :param noise_threshold: Threshold for noise :return: """ return c_auto_interpretation.segment_messages_from_magni...
python
def segment_messages_from_magnitudes(magnitudes: np.ndarray, noise_threshold: float): """ Get the list of start, end indices of messages :param magnitudes: Magnitudes of samples :param noise_threshold: Threshold for noise :return: """ return c_auto_interpretation.segment_messages_from_magni...
[ "def", "segment_messages_from_magnitudes", "(", "magnitudes", ":", "np", ".", "ndarray", ",", "noise_threshold", ":", "float", ")", ":", "return", "c_auto_interpretation", ".", "segment_messages_from_magnitudes", "(", "magnitudes", ",", "noise_threshold", ")" ]
Get the list of start, end indices of messages :param magnitudes: Magnitudes of samples :param noise_threshold: Threshold for noise :return:
[ "Get", "the", "list", "of", "start", "end", "indices", "of", "messages" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/ainterpretation/AutoInterpretation.py#L78-L86
train
jopohl/urh
src/urh/ainterpretation/AutoInterpretation.py
round_plateau_lengths
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: :return: """ # round to n_digits of most common value digit_counts = [len(str(p)) for p in plateau_lengths] n_digits = m...
python
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: :return: """ # round to n_digits of most common value digit_counts = [len(str(p)) for p in plateau_lengths] n_digits = m...
[ "def", "round_plateau_lengths", "(", "plateau_lengths", ":", "list", ")", ":", "# round to n_digits of most common value", "digit_counts", "=", "[", "len", "(", "str", "(", "p", ")", ")", "for", "p", "in", "plateau_lengths", "]", "n_digits", "=", "min", "(", "...
Round plateau lengths to next divisible number of digit count e.g. 99 -> 100, 293 -> 300 :param plateau_lengths: :return:
[ "Round", "plateau", "lengths", "to", "next", "divisible", "number", "of", "digit", "count", "e", ".", "g", ".", "99", "-", ">", "100", "293", "-", ">", "300" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/ainterpretation/AutoInterpretation.py#L293-L306
train
jopohl/urh
src/urh/controller/MainController.py
MainController.on_files_dropped_on_group
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)
python
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)
[ "def", "on_files_dropped_on_group", "(", "self", ",", "files", ",", "group_id", ":", "int", ")", ":", "self", ".", "__add_urls_to_group", "(", "files", ",", "group_id", "=", "group_id", ")" ]
:param group_id: :type files: list of QtCore.QUrl
[ ":", "param", "group_id", ":", ":", "type", "files", ":", "list", "of", "QtCore", ".", "QUrl" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/controller/MainController.py#L799-L804
train
jopohl/urh
src/urh/plugins/PluginManager.py
PluginManager.load_installed_plugins
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 == "__pycache__": ...
python
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 == "__pycache__": ...
[ "def", "load_installed_plugins", "(", "self", ")", ":", "result", "=", "[", "]", "plugin_dirs", "=", "[", "d", "for", "d", "in", "os", ".", "listdir", "(", "self", ".", "plugin_path", ")", "if", "os", ".", "path", ".", "isdir", "(", "os", ".", "pat...
:rtype: list of Plugin
[ ":", "rtype", ":", "list", "of", "Plugin" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/plugins/PluginManager.py#L18-L38
train
jopohl/urh
src/urh/plugins/MessageBreak/MessageBreakAction.py
MessageBreakAction.__get_zero_seq_indexes
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)): if message[i] == "0": ...
python
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)): if message[i] == "0": ...
[ "def", "__get_zero_seq_indexes", "(", "self", ",", "message", ":", "str", ",", "following_zeros", ":", "int", ")", ":", "result", "=", "[", "]", "if", "following_zeros", ">", "len", "(", "message", ")", ":", "return", "result", "zero_counter", "=", "0", ...
:rtype: list[tuple of int]
[ ":", "rtype", ":", "list", "[", "tuple", "of", "int", "]" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/plugins/MessageBreak/MessageBreakAction.py#L33-L54
train
jopohl/urh
src/urh/dev/VirtualDevice.py
VirtualDevice.read_messages
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() if "FATAL: " in errors: self.fatal_error_occurred.emit(error...
python
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() if "FATAL: " in errors: self.fatal_error_occurred.emit(error...
[ "def", "read_messages", "(", "self", ")", "->", "str", ":", "if", "self", ".", "backend", "==", "Backends", ".", "grc", ":", "errors", "=", "self", ".", "__dev", ".", "read_errors", "(", ")", "if", "\"FATAL: \"", "in", "errors", ":", "self", ".", "fa...
returns a string of new device messages separated by newlines :return:
[ "returns", "a", "string", "of", "new", "device", "messages", "separated", "by", "newlines" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/dev/VirtualDevice.py#L648-L677
train
jopohl/urh
src/urh/plugins/Plugin.py
ProtocolPlugin.get_action
def get_action(self, parent, undo_stack: QUndoStack, sel_range, groups, view: int) -> QUndoCommand: """ :type parent: QTableView :type undo_stack: QUndoStack :type groups: list of ProtocolGroups """ raise NotImplementedError("Abstract Method.")
python
def get_action(self, parent, undo_stack: QUndoStack, sel_range, groups, view: int) -> QUndoCommand: """ :type parent: QTableView :type undo_stack: QUndoStack :type groups: list of ProtocolGroups """ raise NotImplementedError("Abstract Method.")
[ "def", "get_action", "(", "self", ",", "parent", ",", "undo_stack", ":", "QUndoStack", ",", "sel_range", ",", "groups", ",", "view", ":", "int", ")", "->", "QUndoCommand", ":", "raise", "NotImplementedError", "(", "\"Abstract Method.\"", ")" ]
:type parent: QTableView :type undo_stack: QUndoStack :type groups: list of ProtocolGroups
[ ":", "type", "parent", ":", "QTableView", ":", "type", "undo_stack", ":", "QUndoStack", ":", "type", "groups", ":", "list", "of", "ProtocolGroups" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/plugins/Plugin.py#L57-L64
train
jopohl/urh
src/urh/util/WSPChecksum.py
WSPChecksum.calculate
def calculate(self, msg: array.array) -> array.array: """ 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 ...
python
def calculate(self, msg: array.array) -> array.array: """ 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 ...
[ "def", "calculate", "(", "self", ",", "msg", ":", "array", ".", "array", ")", "->", "array", ".", "array", ":", "try", ":", "if", "self", ".", "mode", "==", "self", ".", "ChecksumMode", ".", "auto", ":", "if", "msg", "[", "0", ":", "4", "]", "=...
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...
[ "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",...
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/util/WSPChecksum.py#L27-L56
train
jopohl/urh
src/urh/models/ProtocolTreeItem.py
ProtocolTreeItem.child
def child(self, number): """ :type number: int :rtype: ProtocolTreeItem """ if number < self.childCount(): return self.__childItems[number] else: return False
python
def child(self, number): """ :type number: int :rtype: ProtocolTreeItem """ if number < self.childCount(): return self.__childItems[number] else: return False
[ "def", "child", "(", "self", ",", "number", ")", ":", "if", "number", "<", "self", ".", "childCount", "(", ")", ":", "return", "self", ".", "__childItems", "[", "number", "]", "else", ":", "return", "False" ]
:type number: int :rtype: ProtocolTreeItem
[ ":", "type", "number", ":", "int", ":", "rtype", ":", "ProtocolTreeItem" ]
2eb33b125c8407964cd1092843cde5010eb88aae
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/models/ProtocolTreeItem.py#L106-L114
train
Anorov/cloudflare-scrape
cfscrape/__init__.py
CloudflareScraper.create_scraper
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", "cookies", "headers", "hooks", "params", "proxies", "data"] for attr ...
python
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", "cookies", "headers", "hooks", "params", "proxies", "data"] for attr ...
[ "def", "create_scraper", "(", "cls", ",", "sess", "=", "None", ",", "*", "*", "kwargs", ")", ":", "scraper", "=", "cls", "(", "*", "*", "kwargs", ")", "if", "sess", ":", "attrs", "=", "[", "\"auth\"", ",", "\"cert\"", ",", "\"cookies\"", ",", "\"he...
Convenience function for creating a ready-to-go CloudflareScraper object.
[ "Convenience", "function", "for", "creating", "a", "ready", "-", "to", "-", "go", "CloudflareScraper", "object", "." ]
f35c463a60d175f0252b1e0c8e14a284e9d4daa5
https://github.com/Anorov/cloudflare-scrape/blob/f35c463a60d175f0252b1e0c8e14a284e9d4daa5/cfscrape/__init__.py#L156-L169
train
Anorov/cloudflare-scrape
cfscrape/__init__.py
CloudflareScraper.get_cookie_string
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 "; ".join("=".join(pair) for pair in tokens.items()), user_agent
python
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 "; ".join("=".join(pair) for pair in tokens.items()), user_agent
[ "def", "get_cookie_string", "(", "cls", ",", "url", ",", "user_agent", "=", "None", ",", "*", "*", "kwargs", ")", ":", "tokens", ",", "user_agent", "=", "cls", ".", "get_tokens", "(", "url", ",", "user_agent", "=", "user_agent", ",", "*", "*", "kwargs"...
Convenience function for building a Cookie HTTP header value.
[ "Convenience", "function", "for", "building", "a", "Cookie", "HTTP", "header", "value", "." ]
f35c463a60d175f0252b1e0c8e14a284e9d4daa5
https://github.com/Anorov/cloudflare-scrape/blob/f35c463a60d175f0252b1e0c8e14a284e9d4daa5/cfscrape/__init__.py#L205-L210
train
ktbyers/netmiko
netmiko/extreme/extreme_ers_ssh.py
ExtremeErsSSH.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 )
python
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 )
[ "def", "save_config", "(", "self", ",", "cmd", "=", "\"save config\"", ",", "confirm", "=", "False", ",", "confirm_response", "=", "\"\"", ")", ":", "return", "super", "(", "ExtremeErsSSH", ",", "self", ")", ".", "save_config", "(", "cmd", "=", "cmd", ",...
Save Config
[ "Save", "Config" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/extreme/extreme_ers_ssh.py#L41-L45
train
ktbyers/netmiko
netmiko/extreme/extreme_slx_ssh.py
ExtremeSlxSSH.special_login_handler
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)
python
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)
[ "def", "special_login_handler", "(", "self", ",", "delay_factor", "=", "1", ")", ":", "delay_factor", "=", "self", ".", "select_delay_factor", "(", "delay_factor", ")", "self", ".", "write_channel", "(", "self", ".", "RETURN", ")", "time", ".", "sleep", "(",...
Adding a delay after login.
[ "Adding", "a", "delay", "after", "login", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/extreme/extreme_slx_ssh.py#L18-L22
train
ktbyers/netmiko
netmiko/extreme/extreme_slx_ssh.py
ExtremeSlxSSH.save_config
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_response=confirm_response )
python
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_response=confirm_response )
[ "def", "save_config", "(", "self", ",", "cmd", "=", "\"copy running-config startup-config\"", ",", "confirm", "=", "True", ",", "confirm_response", "=", "\"y\"", ",", ")", ":", "return", "super", "(", "ExtremeSlxSSH", ",", "self", ")", ".", "save_config", "(",...
Save Config for Extreme SLX.
[ "Save", "Config", "for", "Extreme", "SLX", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/extreme/extreme_slx_ssh.py#L24-L33
train
ktbyers/netmiko
examples/use_cases/case16_concurrency/threads_netmiko.py
show_version
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()
python
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()
[ "def", "show_version", "(", "a_device", ")", ":", "remote_conn", "=", "ConnectHandler", "(", "*", "*", "a_device", ")", "print", "(", ")", "print", "(", "\"#\"", "*", "80", ")", "print", "(", "remote_conn", ".", "send_command_expect", "(", "\"show version\""...
Execute show version command using Netmiko.
[ "Execute", "show", "version", "command", "using", "Netmiko", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/examples/use_cases/case16_concurrency/threads_netmiko.py#L8-L15
train
ktbyers/netmiko
examples/use_cases/case16_concurrency/threads_netmiko.py
main
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 this. """ start_time = datetime.now() for a_device in devices: my_thread = threading.Thread(target=show_version, args=(a_device,)) ...
python
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 this. """ start_time = datetime.now() for a_device in devices: my_thread = threading.Thread(target=show_version, args=(a_device,)) ...
[ "def", "main", "(", ")", ":", "start_time", "=", "datetime", ".", "now", "(", ")", "for", "a_device", "in", "devices", ":", "my_thread", "=", "threading", ".", "Thread", "(", "target", "=", "show_version", ",", "args", "=", "(", "a_device", ",", ")", ...
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.
[ "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", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/examples/use_cases/case16_concurrency/threads_netmiko.py#L18-L35
train
ktbyers/netmiko
netmiko/dell/dell_force10_ssh.py
DellForce10SSH.save_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_response )
python
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_response )
[ "def", "save_config", "(", "self", ",", "cmd", "=", "\"copy running-configuration startup-configuration\"", ",", "confirm", "=", "False", ",", "confirm_response", "=", "\"\"", ",", ")", ":", "return", "super", "(", "DellForce10SSH", ",", "self", ")", ".", "save_...
Saves Config
[ "Saves", "Config" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/dell/dell_force10_ssh.py#L9-L18
train
ktbyers/netmiko
netmiko/citrix/netscaler_ssh.py
NetscalerSSH.session_preparation
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() self.set_base_prompt() cmd = "{}set cli mode -pa...
python
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() self.set_base_prompt() cmd = "{}set cli mode -pa...
[ "def", "session_preparation", "(", "self", ")", ":", "# 0 will defer to the global delay factor", "delay_factor", "=", "self", ".", "select_delay_factor", "(", "delay_factor", "=", "0", ")", "self", ".", "_test_channel_read", "(", ")", "self", ".", "set_base_prompt", ...
Prepare the session after the connection has been established.
[ "Prepare", "the", "session", "after", "the", "connection", "has", "been", "established", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/citrix/netscaler_ssh.py#L9-L20
train
ktbyers/netmiko
netmiko/citrix/netscaler_ssh.py
NetscalerSSH.strip_prompt
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]) else: retur...
python
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]) else: retur...
[ "def", "strip_prompt", "(", "self", ",", "a_string", ")", ":", "output", "=", "super", "(", "NetscalerSSH", ",", "self", ")", ".", "strip_prompt", "(", "a_string", ")", "lines", "=", "output", ".", "split", "(", "self", ".", "RESPONSE_RETURN", ")", "if",...
Strip 'Done' from command output
[ "Strip", "Done", "from", "command", "output" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/citrix/netscaler_ssh.py#L53-L60
train
ktbyers/netmiko
netmiko/ubiquiti/edge_ssh.py
UbiquitiEdgeSSH.save_config
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 )
python
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 )
[ "def", "save_config", "(", "self", ",", "cmd", "=", "\"write memory\"", ",", "confirm", "=", "False", ",", "confirm_response", "=", "\"\"", ")", ":", "return", "super", "(", "UbiquitiEdgeSSH", ",", "self", ")", ".", "save_config", "(", "cmd", "=", "cmd", ...
Saves configuration.
[ "Saves", "configuration", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/ubiquiti/edge_ssh.py#L43-L47
train
ktbyers/netmiko
netmiko/scp_handler.py
SCPConn.establish_scp_conn
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.scp_client = scp.SCPClient(self.scp_conn....
python
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.scp_client = scp.SCPClient(self.scp_conn....
[ "def", "establish_scp_conn", "(", "self", ")", ":", "ssh_connect_params", "=", "self", ".", "ssh_ctl_chan", ".", "_connect_params_dict", "(", ")", "self", ".", "scp_conn", "=", "self", ".", "ssh_ctl_chan", ".", "_build_ssh_client", "(", ")", "self", ".", "scp_...
Establish the secure copy connection.
[ "Establish", "the", "secure", "copy", "connection", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/scp_handler.py#L31-L36
train
ktbyers/netmiko
netmiko/scp_handler.py
BaseFileTransfer.remote_space_available
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(search_pattern, remote_output) if ...
python
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(search_pattern, remote_output) if ...
[ "def", "remote_space_available", "(", "self", ",", "search_pattern", "=", "r\"(\\d+) \\w+ free\"", ")", ":", "remote_cmd", "=", "\"dir {}\"", ".", "format", "(", "self", ".", "file_system", ")", "remote_output", "=", "self", ".", "ssh_ctl_chan", ".", "send_command...
Return space available on remote device.
[ "Return", "space", "available", "on", "remote", "device", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/scp_handler.py#L106-L113
train
ktbyers/netmiko
netmiko/scp_handler.py
BaseFileTransfer._remote_space_available_unix
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.send_command( remote_cmd, expect_string...
python
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.send_command( remote_cmd, expect_string...
[ "def", "_remote_space_available_unix", "(", "self", ",", "search_pattern", "=", "\"\"", ")", ":", "self", ".", "ssh_ctl_chan", ".", "_enter_shell", "(", ")", "remote_cmd", "=", "\"/bin/df -k {}\"", ".", "format", "(", "self", ".", "file_system", ")", "remote_out...
Return space available on *nix system (BSD/Linux).
[ "Return", "space", "available", "on", "*", "nix", "system", "(", "BSD", "/", "Linux", ")", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/scp_handler.py#L115-L148
train
ktbyers/netmiko
netmiko/scp_handler.py
BaseFileTransfer.verify_space_available
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_space_available(search_pattern=search_pattern) elif self.direction == "get...
python
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_space_available(search_pattern=search_pattern) elif self.direction == "get...
[ "def", "verify_space_available", "(", "self", ",", "search_pattern", "=", "r\"(\\d+) \\w+ free\"", ")", ":", "if", "self", ".", "direction", "==", "\"put\"", ":", "space_avail", "=", "self", ".", "remote_space_available", "(", "search_pattern", "=", "search_pattern"...
Verify sufficient space is available on destination file system (return boolean).
[ "Verify", "sufficient", "space", "is", "available", "on", "destination", "file", "system", "(", "return", "boolean", ")", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/scp_handler.py#L155-L163
train
ktbyers/netmiko
netmiko/scp_handler.py
BaseFileTransfer._check_file_exists_unix
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 = "ls {}".format(self.file_system) remote_out = self.ssh_ctl_chan...
python
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 = "ls {}".format(self.file_system) remote_out = self.ssh_ctl_chan...
[ "def", "_check_file_exists_unix", "(", "self", ",", "remote_cmd", "=", "\"\"", ")", ":", "if", "self", ".", "direction", "==", "\"put\"", ":", "self", ".", "ssh_ctl_chan", ".", "_enter_shell", "(", ")", "remote_cmd", "=", "\"ls {}\"", ".", "format", "(", "...
Check if the dest_file already exists on the file system (return boolean).
[ "Check", "if", "the", "dest_file", "already", "exists", "on", "the", "file", "system", "(", "return", "boolean", ")", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/scp_handler.py#L185-L196
train
ktbyers/netmiko
netmiko/scp_handler.py
BaseFileTransfer.remote_file_size
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": remote_file = self.source_file ...
python
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": remote_file = self.source_file ...
[ "def", "remote_file_size", "(", "self", ",", "remote_cmd", "=", "\"\"", ",", "remote_file", "=", "None", ")", ":", "if", "remote_file", "is", "None", ":", "if", "self", ".", "direction", "==", "\"put\"", ":", "remote_file", "=", "self", ".", "dest_file", ...
Get the file size of the remote file.
[ "Get", "the", "file", "size", "of", "the", "remote", "file", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/scp_handler.py#L198-L222
train
ktbyers/netmiko
netmiko/scp_handler.py
BaseFileTransfer._remote_file_size_unix
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": remote_file = self.source_...
python
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": remote_file = self.source_...
[ "def", "_remote_file_size_unix", "(", "self", ",", "remote_cmd", "=", "\"\"", ",", "remote_file", "=", "None", ")", ":", "if", "remote_file", "is", "None", ":", "if", "self", ".", "direction", "==", "\"put\"", ":", "remote_file", "=", "self", ".", "dest_fi...
Get the file size of the remote file.
[ "Get", "the", "file", "size", "of", "the", "remote", "file", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/scp_handler.py#L224-L253
train
ktbyers/netmiko
netmiko/scp_handler.py
BaseFileTransfer.file_md5
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
python
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
[ "def", "file_md5", "(", "self", ",", "file_name", ")", ":", "with", "open", "(", "file_name", ",", "\"rb\"", ")", "as", "f", ":", "file_contents", "=", "f", ".", "read", "(", ")", "file_hash", "=", "hashlib", ".", "md5", "(", "file_contents", ")", "....
Compute MD5 hash of file.
[ "Compute", "MD5", "hash", "of", "file", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/scp_handler.py#L255-L260
train
ktbyers/netmiko
netmiko/scp_handler.py
BaseFileTransfer.process_md5
def process_md5(md5_output, pattern=r"=\s+(\S+)"): """ 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 """ match = re.search(pattern,...
python
def process_md5(md5_output, pattern=r"=\s+(\S+)"): """ 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 """ match = re.search(pattern,...
[ "def", "process_md5", "(", "md5_output", ",", "pattern", "=", "r\"=\\s+(\\S+)\"", ")", ":", "match", "=", "re", ".", "search", "(", "pattern", ",", "md5_output", ")", "if", "match", ":", "return", "match", ".", "group", "(", "1", ")", "else", ":", "rai...
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
[ "Process", "the", "string", "to", "retrieve", "the", "MD5", "hash" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/scp_handler.py#L263-L275
train
ktbyers/netmiko
netmiko/scp_handler.py
BaseFileTransfer.compare_md5
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 == "get": local_md5 = self.file_md5(self.dest_file) ...
python
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 == "get": local_md5 = self.file_md5(self.dest_file) ...
[ "def", "compare_md5", "(", "self", ")", ":", "if", "self", ".", "direction", "==", "\"put\"", ":", "remote_md5", "=", "self", ".", "remote_md5", "(", ")", "return", "self", ".", "source_md5", "==", "remote_md5", "elif", "self", ".", "direction", "==", "\...
Compare md5 of file on network device to md5 of local file.
[ "Compare", "md5", "of", "file", "on", "network", "device", "to", "md5", "of", "local", "file", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/scp_handler.py#L277-L284
train
ktbyers/netmiko
netmiko/scp_handler.py
BaseFileTransfer.transfer_file
def transfer_file(self): """SCP transfer file.""" if self.direction == "put": self.put_file() elif self.direction == "get": self.get_file()
python
def transfer_file(self): """SCP transfer file.""" if self.direction == "put": self.put_file() elif self.direction == "get": self.get_file()
[ "def", "transfer_file", "(", "self", ")", ":", "if", "self", ".", "direction", "==", "\"put\"", ":", "self", ".", "put_file", "(", ")", "elif", "self", ".", "direction", "==", "\"get\"", ":", "self", ".", "get_file", "(", ")" ]
SCP transfer file.
[ "SCP", "transfer", "file", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/scp_handler.py#L301-L306
train
ktbyers/netmiko
netmiko/scp_handler.py
BaseFileTransfer.put_file
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 close the SCP connection to get the file written (flush) se...
python
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 close the SCP connection to get the file written (flush) se...
[ "def", "put_file", "(", "self", ")", ":", "destination", "=", "\"{}/{}\"", ".", "format", "(", "self", ".", "file_system", ",", "self", ".", "dest_file", ")", "self", ".", "scp_conn", ".", "scp_transfer_file", "(", "self", ".", "source_file", ",", "destina...
SCP copy the file from the local system to the remote device.
[ "SCP", "copy", "the", "file", "from", "the", "local", "system", "to", "the", "remote", "device", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/scp_handler.py#L314-L319
train
ktbyers/netmiko
netmiko/scp_handler.py
BaseFileTransfer.enable_scp
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__"): cmd = [cmd] self.ssh_ctl_chan.send_config_set(cmd)
python
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__"): cmd = [cmd] self.ssh_ctl_chan.send_config_set(cmd)
[ "def", "enable_scp", "(", "self", ",", "cmd", "=", "None", ")", ":", "if", "cmd", "is", "None", ":", "cmd", "=", "[", "\"ip scp server enable\"", "]", "elif", "not", "hasattr", "(", "cmd", ",", "\"__iter__\"", ")", ":", "cmd", "=", "[", "cmd", "]", ...
Enable SCP on remote device. Defaults to Cisco IOS command
[ "Enable", "SCP", "on", "remote", "device", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/scp_handler.py#L325-L335
train
ktbyers/netmiko
netmiko/scp_handler.py
BaseFileTransfer.disable_scp
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__"): cmd = [cmd] self.ssh_ctl_chan.send_config_set(cmd)
python
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__"): cmd = [cmd] self.ssh_ctl_chan.send_config_set(cmd)
[ "def", "disable_scp", "(", "self", ",", "cmd", "=", "None", ")", ":", "if", "cmd", "is", "None", ":", "cmd", "=", "[", "\"no ip scp server enable\"", "]", "elif", "not", "hasattr", "(", "cmd", ",", "\"__iter__\"", ")", ":", "cmd", "=", "[", "cmd", "]...
Disable SCP on remote device. Defaults to Cisco IOS command
[ "Disable", "SCP", "on", "remote", "device", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/scp_handler.py#L337-L347
train
ktbyers/netmiko
netmiko/paloalto/paloalto_panos.py
PaloAltoPanosBase.exit_config_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 )
python
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 )
[ "def", "exit_config_mode", "(", "self", ",", "exit_config", "=", "\"exit\"", ",", "pattern", "=", "r\">\"", ")", ":", "return", "super", "(", "PaloAltoPanosBase", ",", "self", ")", ".", "exit_config_mode", "(", "exit_config", "=", "exit_config", ",", "pattern"...
Exit configuration mode.
[ "Exit", "configuration", "mode", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/paloalto/paloalto_panos.py#L51-L55
train
ktbyers/netmiko
netmiko/paloalto/paloalto_panos.py
PaloAltoPanosBase.commit
def commit( self, force=False, partial=False, device_and_network=False, policy_and_objects=False, vsys="", no_vsys=False, delay_factor=0.1, ): """ Commit the candidate configuration. Commit the entered configuration. Raise an e...
python
def commit( self, force=False, partial=False, device_and_network=False, policy_and_objects=False, vsys="", no_vsys=False, delay_factor=0.1, ): """ Commit the candidate configuration. Commit the entered configuration. Raise an e...
[ "def", "commit", "(", "self", ",", "force", "=", "False", ",", "partial", "=", "False", ",", "device_and_network", "=", "False", ",", "policy_and_objects", "=", "False", ",", "vsys", "=", "\"\"", ",", "no_vsys", "=", "False", ",", "delay_factor", "=", "0...
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 ...
[ "Commit", "the", "candidate", "configuration", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/paloalto/paloalto_panos.py#L57-L123
train
ktbyers/netmiko
netmiko/paloalto/paloalto_panos.py
PaloAltoPanosBase.strip_command
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)
python
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)
[ "def", "strip_command", "(", "self", ",", "command_string", ",", "output", ")", ":", "output_list", "=", "output", ".", "split", "(", "command_string", ")", "return", "self", ".", "RESPONSE_RETURN", ".", "join", "(", "output_list", ")" ]
Strip command_string from output string.
[ "Strip", "command_string", "from", "output", "string", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/paloalto/paloalto_panos.py#L125-L128
train
ktbyers/netmiko
netmiko/paloalto/paloalto_panos.py
PaloAltoPanosBase.strip_prompt
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: new_response_list.append(line) ...
python
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: new_response_list.append(line) ...
[ "def", "strip_prompt", "(", "self", ",", "a_string", ")", ":", "response_list", "=", "a_string", ".", "split", "(", "self", ".", "RESPONSE_RETURN", ")", "new_response_list", "=", "[", "]", "for", "line", "in", "response_list", ":", "if", "self", ".", "base...
Strip the trailing router prompt from the output.
[ "Strip", "the", "trailing", "router", "prompt", "from", "the", "output", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/paloalto/paloalto_panos.py#L130-L139
train
ktbyers/netmiko
netmiko/paloalto/paloalto_panos.py
PaloAltoPanosBase.strip_context_items
def strip_context_items(self, a_string): """Strip PaloAlto-specific output. PaloAlto will also put a configuration context: [edit] This method removes those lines. """ strings_to_strip = [r"\[edit.*\]"] response_list = a_string.split(self.RESPONSE_RETURN) ...
python
def strip_context_items(self, a_string): """Strip PaloAlto-specific output. PaloAlto will also put a configuration context: [edit] This method removes those lines. """ strings_to_strip = [r"\[edit.*\]"] response_list = a_string.split(self.RESPONSE_RETURN) ...
[ "def", "strip_context_items", "(", "self", ",", "a_string", ")", ":", "strings_to_strip", "=", "[", "r\"\\[edit.*\\]\"", "]", "response_list", "=", "a_string", ".", "split", "(", "self", ".", "RESPONSE_RETURN", ")", "last_line", "=", "response_list", "[", "-", ...
Strip PaloAlto-specific output. PaloAlto will also put a configuration context: [edit] This method removes those lines.
[ "Strip", "PaloAlto", "-", "specific", "output", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/paloalto/paloalto_panos.py#L141-L158
train
ktbyers/netmiko
netmiko/paloalto/paloalto_panos.py
PaloAltoPanosBase.send_command
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)
python
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)
[ "def", "send_command", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "\"delay_factor\"", "]", "=", "kwargs", ".", "get", "(", "\"delay_factor\"", ",", "2.5", ")", "return", "super", "(", "PaloAltoPanosBase", ",", "self"...
Palo Alto requires an extra delay
[ "Palo", "Alto", "requires", "an", "extra", "delay" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/paloalto/paloalto_panos.py#L164-L167
train
ktbyers/netmiko
netmiko/paloalto/paloalto_panos.py
PaloAltoPanosBase.cleanup
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 = True self.write_channel("exit...
python
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 = True self.write_channel("exit...
[ "def", "cleanup", "(", "self", ")", ":", "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", "=", "True", "self", ...
Gracefully exit the SSH session.
[ "Gracefully", "exit", "the", "SSH", "session", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/paloalto/paloalto_panos.py#L169-L177
train
ktbyers/netmiko
netmiko/coriant/coriant_ssh.py
CoriantSSH.set_base_prompt
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, self).set_base_prompt( pri_prompt_terminator=pri_prompt_terminator, ...
python
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, self).set_base_prompt( pri_prompt_terminator=pri_prompt_terminator, ...
[ "def", "set_base_prompt", "(", "self", ",", "pri_prompt_terminator", "=", "\":\"", ",", "alt_prompt_terminator", "=", "\">\"", ",", "delay_factor", "=", "2", ")", ":", "super", "(", "CoriantSSH", ",", "self", ")", ".", "set_base_prompt", "(", "pri_prompt_termina...
Sets self.base_prompt: used as delimiter for stripping of trailing prompt in output.
[ "Sets", "self", ".", "base_prompt", ":", "used", "as", "delimiter", "for", "stripping", "of", "trailing", "prompt", "in", "output", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/coriant/coriant_ssh.py#L31-L40
train
ktbyers/netmiko
netmiko/cisco/cisco_ios.py
CiscoIosBase.check_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 chars in config mode """ return super(CiscoIosBase, self).check_config_mode( check_string=check_string...
python
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 chars in config mode """ return super(CiscoIosBase, self).check_config_mode( check_string=check_string...
[ "def", "check_config_mode", "(", "self", ",", "check_string", "=", "\")#\"", ",", "pattern", "=", "\"#\"", ")", ":", "return", "super", "(", "CiscoIosBase", ",", "self", ")", ".", "check_config_mode", "(", "check_string", "=", "check_string", ",", "pattern", ...
Checks if the device is in configuration mode or not. Cisco IOS devices abbreviate the prompt at 20 chars in config mode
[ "Checks", "if", "the", "device", "is", "in", "configuration", "mode", "or", "not", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_ios.py#L25-L33
train
ktbyers/netmiko
netmiko/cisco/cisco_ios.py
CiscoIosBase.save_config
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 )
python
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 )
[ "def", "save_config", "(", "self", ",", "cmd", "=", "\"write mem\"", ",", "confirm", "=", "False", ",", "confirm_response", "=", "\"\"", ")", ":", "return", "super", "(", "CiscoIosBase", ",", "self", ")", ".", "save_config", "(", "cmd", "=", "cmd", ",", ...
Saves Config Using Copy Run Start
[ "Saves", "Config", "Using", "Copy", "Run", "Start" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_ios.py#L35-L39
train
ktbyers/netmiko
netmiko/cisco/cisco_ios.py
InLineTransfer._tcl_newline_rationalize
def _tcl_newline_rationalize(tcl_string): """ 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 C...
python
def _tcl_newline_rationalize(tcl_string): """ 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 C...
[ "def", "_tcl_newline_rationalize", "(", "tcl_string", ")", ":", "NEWLINE", "=", "r\"\\n\"", "CARRIAGE_RETURN", "=", "r\"\\r\"", "tmp_string", "=", "re", ".", "sub", "(", "NEWLINE", ",", "CARRIAGE_RETURN", ",", "tcl_string", ")", "if", "re", ".", "search", "(",...
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.
[ "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", ".", "TC...
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_ios.py#L109-L122
train
ktbyers/netmiko
netmiko/cisco/cisco_ios.py
InLineTransfer.file_md5
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_contents).hexdigest()
python
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_contents).hexdigest()
[ "def", "file_md5", "(", "self", ",", "file_name", ")", ":", "file_contents", "=", "self", ".", "_read_file", "(", "file_name", ")", "file_contents", "=", "file_contents", "+", "\"\\n\"", "# Cisco IOS automatically adds this", "file_contents", "=", "file_contents", "...
Compute MD5 hash of file.
[ "Compute", "MD5", "hash", "of", "file", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_ios.py#L167-L172
train
ktbyers/netmiko
netmiko/cisco/cisco_ios.py
InLineTransfer.config_md5
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()
python
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()
[ "def", "config_md5", "(", "self", ",", "source_config", ")", ":", "file_contents", "=", "source_config", "+", "\"\\n\"", "# Cisco IOS automatically adds this", "file_contents", "=", "file_contents", ".", "encode", "(", "\"UTF-8\"", ")", "return", "hashlib", ".", "md...
Compute MD5 hash of file.
[ "Compute", "MD5", "hash", "of", "file", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_ios.py#L174-L178
train
ktbyers/netmiko
netmiko/hp/hp_comware.py
HPComwareBase.session_preparation
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(delay_factor=0) i = 1 while i <= 4: # Comware can have a banner that prompts yo...
python
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(delay_factor=0) i = 1 while i <= 4: # Comware can have a banner that prompts yo...
[ "def", "session_preparation", "(", "self", ")", ":", "delay_factor", "=", "self", ".", "select_delay_factor", "(", "delay_factor", "=", "0", ")", "i", "=", "1", "while", "i", "<=", "4", ":", "# Comware can have a banner that prompts you to continue", "# 'Press Y or ...
Prepare the session after the connection has been established. Extra time to read HP banners.
[ "Prepare", "the", "session", "after", "the", "connection", "has", "been", "established", ".", "Extra", "time", "to", "read", "HP", "banners", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/hp/hp_comware.py#L8-L30
train
ktbyers/netmiko
netmiko/hp/hp_comware.py
HPComwareBase.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 )
python
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 )
[ "def", "exit_config_mode", "(", "self", ",", "exit_config", "=", "\"return\"", ",", "pattern", "=", "r\">\"", ")", ":", "return", "super", "(", "HPComwareBase", ",", "self", ")", ".", "exit_config_mode", "(", "exit_config", "=", "exit_config", ",", "pattern", ...
Exit config mode.
[ "Exit", "config", "mode", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/hp/hp_comware.py#L36-L40
train
ktbyers/netmiko
netmiko/hp/hp_comware.py
HPComwareBase.set_base_prompt
def set_base_prompt( self, pri_prompt_terminator=">", alt_prompt_terminator="]", delay_factor=1 ): """ 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 Comwar...
python
def set_base_prompt( self, pri_prompt_terminator=">", alt_prompt_terminator="]", delay_factor=1 ): """ 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 Comwar...
[ "def", "set_base_prompt", "(", "self", ",", "pri_prompt_terminator", "=", "\">\"", ",", "alt_prompt_terminator", "=", "\"]\"", ",", "delay_factor", "=", "1", ")", ":", "prompt", "=", "super", "(", "HPComwareBase", ",", "self", ")", ".", "set_base_prompt", "(",...
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...
[ "Sets", "self", ".", "base_prompt" ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/hp/hp_comware.py#L46-L69
train
ktbyers/netmiko
netmiko/hp/hp_comware.py
HPComwareBase.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 )
python
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 )
[ "def", "save_config", "(", "self", ",", "cmd", "=", "\"save force\"", ",", "confirm", "=", "False", ",", "confirm_response", "=", "\"\"", ")", ":", "return", "super", "(", "HPComwareBase", ",", "self", ")", ".", "save_config", "(", "cmd", "=", "cmd", ","...
Save Config.
[ "Save", "Config", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/hp/hp_comware.py#L83-L87
train
ktbyers/netmiko
netmiko/snmp_autodetect.py
SNMPDetect._get_snmpv3
def _get_snmpv3(self, oid): """ 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 ...
python
def _get_snmpv3(self, oid): """ 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 ...
[ "def", "_get_snmpv3", "(", "self", ",", "oid", ")", ":", "snmp_target", "=", "(", "self", ".", "hostname", ",", "self", ".", "snmp_port", ")", "cmd_gen", "=", "cmdgen", ".", "CommandGenerator", "(", ")", "(", "error_detected", ",", "error_status", ",", "...
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.
[ "Try", "to", "send", "an", "SNMP", "GET", "operation", "using", "SNMPv3", "for", "the", "specified", "OID", "." ]
54e6116c0b4664de2123081937e0a9a27bdfdfea
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/snmp_autodetect.py#L233-L266
train