rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
self.groupsFolder.manage_delFolder(groupId)
|
self.groupsFolder.manage_delObjects([groupId,])
|
def delete_group_folder(self, groupId): # Create the group folder self.groupsFolder.manage_delFolder(groupId) assert not(hasattr(self.groupsFolder, groupId)) return group
|
return group
|
def delete_group_folder(self, groupId): # Create the group folder self.groupsFolder.manage_delFolder(groupId) assert not(hasattr(self.groupsFolder, groupId)) return group
|
|
def del_user_group(self, group): memberGroup = '%s_member' % group.id
|
def delete_user_group(self, groupId): memberGroup = '%s_member' % groupId
|
def del_user_group(self, group): memberGroup = '%s_member' % group.id self.site_root.acl_users.userFolderDelGroups([memberGroup])
|
listManager.manage_delFolder(listManager.aq_explicit, groupId)
|
listManager.manage_delObjects([groupId,])
|
def delete_list(self, groupId): listManager = self.site_root.ListManager listManager.manage_delFolder(listManager.aq_explicit, groupId)
|
s.br_x = 300. s.br_y = 300.
|
def run(self): s = sane.open(self.selectedScanner)
|
|
event.modifiers() & QtCore.Qt.ControlModifier and \
|
self._control_down(event.modifiers()) and \
|
def event(self, event): """ Reimplemented to override shortcuts, if necessary. """ if self.override_shortcuts and \ event.type() == QtCore.QEvent.ShortcutOverride and \ event.modifiers() & QtCore.Qt.ControlModifier and \ event.key() in self._ctrl_down_remap: event.accept() return True else: return QtGui.QPlainTextEdit.event(self, event)
|
ctrl_down = event.modifiers() & QtCore.Qt.ControlModifier
|
ctrl_down = self._control_down(event.modifiers())
|
def keyPressEvent(self, event): """ Reimplemented to create a console-like interface. """ intercepted = False cursor = self.textCursor() position = cursor.position() key = event.key() ctrl_down = event.modifiers() & QtCore.Qt.ControlModifier alt_down = event.modifiers() & QtCore.Qt.AltModifier shift_down = event.modifiers() & QtCore.Qt.ShiftModifier
|
text = str(QtGui.QApplication.clipboard().text(mode))
|
text = str(QtGui.QApplication.clipboard().text(mode)).rstrip()
|
def paste(self, mode=QtGui.QClipboard.Clipboard): """ Paste the contents of the clipboard into the input region.
|
def paste(self):
|
def paste(self, mode=QtGui.QClipboard.Clipboard):
|
def paste(self): """ Paste the contents of the clipboard into the input region. """ if self._control.textInteractionFlags() & QtCore.Qt.TextEditable: try: text = str(QtGui.QApplication.clipboard().text()) except UnicodeEncodeError: pass else: self._insert_plain_text_into_buffer(dedent(text))
|
text = str(QtGui.QApplication.clipboard().text())
|
text = str(QtGui.QApplication.clipboard().text(mode))
|
def paste(self): """ Paste the contents of the clipboard into the input region. """ if self._control.textInteractionFlags() & QtCore.Qt.TextEditable: try: text = str(QtGui.QApplication.clipboard().text()) except UnicodeEncodeError: pass else: self._insert_plain_text_into_buffer(dedent(text))
|
control.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
|
control.viewport().installEventFilter(self)
|
def _create_control(self): """ Creates and connects the underlying text widget. """ if self.kind == 'plain': control = ConsolePlainTextEdit() elif self.kind == 'rich': control = ConsoleTextEdit() control.setAcceptRichText(False) control.installEventFilter(self) control.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) control.cursorPositionChanged.connect(self._cursor_position_changed) control.customContextMenuRequested.connect(self._show_context_menu) control.copyAvailable.connect(self.copy_available) control.redoAvailable.connect(self.redo_available) control.undoAvailable.connect(self.undo_available) control.setReadOnly(True) control.setUndoRedoEnabled(False) control.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) return control
|
layout = QtGui.QVBoxLayout(self) layout.setMargin(0)
|
def __init__(self, kind='plain', parent=None): """ Create a ConsoleWidget. Parameters ---------- kind : str, optional [default 'plain'] The type of text widget to use. Valid values are 'plain', which specifies a QPlainTextEdit, and 'rich', which specifies a QTextEdit.
|
|
if obj == self._control: etype = event.type()
|
etype = event.type() if etype == QtCore.QEvent.KeyPress and \ self._control_key_down(event.modifiers()) and \ event.key() in self._ctrl_down_remap: new_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress, self._ctrl_down_remap[event.key()], QtCore.Qt.NoModifier) QtGui.qApp.sendEvent(obj, new_event) return True elif etype == QtCore.QEvent.ShortcutOverride and \ sys.platform != 'darwin' and \ self._control_key_down(event.modifiers()) and \ event.key() in self._shortcuts: event.accept() return False elif obj == self._control:
|
def eventFilter(self, obj, event): """ Reimplemented to ensure a console-like behavior in the underlying text widget. """ if obj == self._control: etype = event.type()
|
elif etype == QtCore.QEvent.ShortcutOverride: if sys.platform != 'darwin' and \ self._control_key_down(event.modifiers()) and \ event.key() in self._shortcuts: event.accept() return False
|
def eventFilter(self, obj, event): """ Reimplemented to ensure a console-like behavior in the underlying text widget. """ if obj == self._control: etype = event.type()
|
|
layout = QtGui.QVBoxLayout(self) layout.setMargin(0)
|
def _create_control(self, kind): """ Creates and sets the underlying text widget. """ layout = QtGui.QVBoxLayout(self) layout.setMargin(0) if kind == 'plain': control = QtGui.QPlainTextEdit() elif kind == 'rich': control = QtGui.QTextEdit() control.setAcceptRichText(False) else: raise ValueError("Kind %s unknown." % repr(kind)) layout.addWidget(control)
|
|
layout.addWidget(control)
|
def _create_control(self, kind): """ Creates and sets the underlying text widget. """ layout = QtGui.QVBoxLayout(self) layout.setMargin(0) if kind == 'plain': control = QtGui.QPlainTextEdit() elif kind == 'rich': control = QtGui.QTextEdit() control.setAcceptRichText(False) else: raise ValueError("Kind %s unknown." % repr(kind)) layout.addWidget(control)
|
|
control.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
|
def _create_control(self, kind): """ Creates and sets the underlying text widget. """ layout = QtGui.QVBoxLayout(self) layout.setMargin(0) if kind == 'plain': control = QtGui.QPlainTextEdit() elif kind == 'rich': control = QtGui.QTextEdit() control.setAcceptRichText(False) else: raise ValueError("Kind %s unknown." % repr(kind)) layout.addWidget(control)
|
|
key = event.key() ctrl_down = self._control_key_down(event.modifiers()) if ctrl_down and key in self._ctrl_down_remap: new_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress, self._ctrl_down_remap[key], QtCore.Qt.NoModifier) QtGui.qApp.sendEvent(self._control, new_event) return True
|
def _event_filter_keypress(self, event): """ Filter key events for the underlying text widget to create a console-like interface. """ key = event.key() ctrl_down = self._control_key_down(event.modifiers()) # If the key is remapped, return immediately. if ctrl_down and key in self._ctrl_down_remap: new_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress, self._ctrl_down_remap[key], QtCore.Qt.NoModifier) QtGui.qApp.sendEvent(self._control, new_event) return True
|
|
font_metrics = QtGui.QFontMetrics(self.font) displaywidth = max(5, (self.width() / font_metrics.width(' ')) - 1)
|
width = self._control.viewport().width() char_width = QtGui.QFontMetrics(self.font).width(' ') displaywidth = max(5, width / char_width)
|
def _format_as_columns(self, items, separator=' '): """ Transform a list of strings into a single string with columns.
|
self._set_top_cursor(self._get_prompt_cursor())
|
prompt_cursor = self._get_prompt_cursor() if self._get_cursor().blockNumber() < prompt_cursor.blockNumber(): self._set_cursor(prompt_cursor) self._set_top_cursor(prompt_cursor)
|
def prompt_to_top(self): """ Moves the prompt to the top of the viewport. """ if not self._executing: self._set_top_cursor(self._get_prompt_cursor())
|
if self.paging != 'none' and re.match("(?:[^\n]*\n){%i}" % minlines, text):
|
if self.paging != 'none' and \ re.match("(?:[^\n]*\n){%i}" % minlines, text):
|
def _page(self, text, html=False): """ Displays text using the pager if it exceeds the height of the viewport.
|
if diff < 0:
|
if diff < 0 and document.blockCount() == document.maximumBlockCount():
|
def _adjust_scrollbars(self): """ Expands the vertical scrollbar beyond the range set by Qt. """ # This code is adapted from _q_adjustScrollbars in qplaintextedit.cpp # and qtextedit.cpp. document = self._control.document() scrollbar = self._control.verticalScrollBar() viewport_height = self._control.viewport().height() if isinstance(self._control, QtGui.QPlainTextEdit): maximum = max(0, document.lineCount() - 1) step = viewport_height / self._control.fontMetrics().lineSpacing() else: # QTextEdit does not do line-based layout and blocks will not in # general have the same height. Therefore it does not make sense to # attempt to scroll in line height increments. maximum = document.size().height() step = viewport_height diff = maximum - scrollbar.maximum() scrollbar.setRange(0, maximum) scrollbar.setPageStep(step) # Compensate for undesirable scrolling that occurs automatically due to # maximumBlockCount() text truncation. if diff < 0: scrollbar.setValue(scrollbar.value() + diff)
|
_input_splitter_class = IPythonInputSplitter
|
def __init__(self, block, length, number): self.block = block self.length = length self.number = number
|
|
high = max(0, document.lineCount() - 1)
|
maximum = max(0, document.lineCount() - 1)
|
def _adjust_scrollbars(self): """ Expands the vertical scrollbar beyond the range set by Qt. """ # This code is adapted from _q_adjustScrollbars in qplaintextedit.cpp # and qtextedit.cpp. document = self._control.document() scrollbar = self._control.verticalScrollBar() viewport_height = self._control.viewport().height() if isinstance(self._control, QtGui.QPlainTextEdit): high = max(0, document.lineCount() - 1) step = viewport_height / self._control.fontMetrics().lineSpacing() else: high = document.size().height() step = viewport_height scrollbar.setRange(0, high) scrollbar.setPageStep(step)
|
high = document.size().height()
|
maximum = document.size().height()
|
def _adjust_scrollbars(self): """ Expands the vertical scrollbar beyond the range set by Qt. """ # This code is adapted from _q_adjustScrollbars in qplaintextedit.cpp # and qtextedit.cpp. document = self._control.document() scrollbar = self._control.verticalScrollBar() viewport_height = self._control.viewport().height() if isinstance(self._control, QtGui.QPlainTextEdit): high = max(0, document.lineCount() - 1) step = viewport_height / self._control.fontMetrics().lineSpacing() else: high = document.size().height() step = viewport_height scrollbar.setRange(0, high) scrollbar.setPageStep(step)
|
scrollbar.setRange(0, high)
|
diff = maximum - scrollbar.maximum() scrollbar.setRange(0, maximum)
|
def _adjust_scrollbars(self): """ Expands the vertical scrollbar beyond the range set by Qt. """ # This code is adapted from _q_adjustScrollbars in qplaintextedit.cpp # and qtextedit.cpp. document = self._control.document() scrollbar = self._control.verticalScrollBar() viewport_height = self._control.viewport().height() if isinstance(self._control, QtGui.QPlainTextEdit): high = max(0, document.lineCount() - 1) step = viewport_height / self._control.fontMetrics().lineSpacing() else: high = document.size().height() step = viewport_height scrollbar.setRange(0, high) scrollbar.setPageStep(step)
|
len_prompt = len(self._continuation_prompt)
|
line, col = cursor.blockNumber(), cursor.columnNumber()
|
def _event_filter_console_keypress(self, event): """ Filter key events for the underlying text widget to create a console-like interface. """ intercepted = False cursor = self._control.textCursor() position = cursor.position() key = event.key() ctrl_down = self._control_key_down(event.modifiers()) alt_down = event.modifiers() & QtCore.Qt.AltModifier shift_down = event.modifiers() & QtCore.Qt.ShiftModifier
|
cursor.columnNumber() == len_prompt and \ position != self._prompt_pos:
|
col == len(self._continuation_prompt) and \ line > self._get_prompt_cursor().blockNumber():
|
def _event_filter_console_keypress(self, event): """ Filter key events for the underlying text widget to create a console-like interface. """ intercepted = False cursor = self._control.textCursor() position = cursor.position() key = event.key() ctrl_down = self._control_key_down(event.modifiers()) alt_down = event.modifiers() & QtCore.Qt.AltModifier shift_down = event.modifiers() & QtCore.Qt.ShiftModifier
|
if not self._reading and cursor.atBlockEnd() and not \ cursor.hasSelection():
|
if not self._reading and self._in_buffer(position) and \ cursor.atBlockEnd() and not cursor.hasSelection():
|
def _event_filter_console_keypress(self, event): """ Filter key events for the underlying text widget to create a console-like interface. """ intercepted = False cursor = self._control.textCursor() position = cursor.position() key = event.key() ctrl_down = self._control_key_down(event.modifiers()) alt_down = event.modifiers() & QtCore.Qt.AltModifier shift_down = event.modifiers() & QtCore.Qt.ShiftModifier
|
self.setLineWrapMode(QtGui.QPlainTextEdit.WidgetWidth) self.setMaximumBlockCount(500) self.setUndoRedoEnabled(False)
|
def __init__(self, parent=None): QtGui.QPlainTextEdit.__init__(self, parent)
|
|
if ctrl_down:
|
if event.matches(QtGui.QKeySequence.Paste): self.paste() intercepted = True elif ctrl_down:
|
def keyPressEvent(self, event): """ Reimplemented to create a console-like interface. """ intercepted = False cursor = self.textCursor() position = cursor.position() key = event.key() ctrl_down = event.modifiers() & QtCore.Qt.ControlModifier alt_down = event.modifiers() & QtCore.Qt.AltModifier shift_down = event.modifiers() & QtCore.Qt.ShiftModifier
|
self._executing = True
|
def keyPressEvent(self, event): """ Reimplemented to create a console-like interface. """ intercepted = False cursor = self.textCursor() position = cursor.position() key = event.key() ctrl_down = event.modifiers() & QtCore.Qt.ControlModifier alt_down = event.modifiers() & QtCore.Qt.AltModifier shift_down = event.modifiers() & QtCore.Qt.ShiftModifier
|
|
self.setReadOnly(False)
|
def _prompt_started(self): """ Called immediately after a new prompt is displayed. """ self.moveCursor(QtGui.QTextCursor.End) self.centerCursor() self.setReadOnly(False) self._executing = False self._prompt_started_hook()
|
|
QtGui.QListWidget.hideEvent(self, event)
|
QtGui.QLabel.hideEvent(self, event)
|
def hideEvent(self, event): """ Reimplemented to disconnect the cursor movement handler. """ QtGui.QListWidget.hideEvent(self, event) self.parent().cursorPositionChanged.disconnect(self._update_tip)
|
QtGui.QListWidget.showEvent(self, event)
|
QtGui.QLabel.showEvent(self, event)
|
def showEvent(self, event): """ Reimplemented to connect the cursor movement handler. """ QtGui.QListWidget.showEvent(self, event) self.parent().cursorPositionChanged.connect(self._update_tip)
|
if (etype == QtCore.QEvent.KeyPress and event.key() in (QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return, QtCore.Qt.Key_Escape)): self.hide()
|
if etype == QtCore.QEvent.KeyPress: key = event.key() if key in (QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return): self.hide() elif key == QtCore.Qt.Key_Escape: self.hide() return True
|
def eventFilter(self, obj, event): """ Reimplemented to hide on certain key presses and on parent focus changes. """ if obj == self.parent(): etype = event.type() if (etype == QtCore.QEvent.KeyPress and event.key() in (QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return, QtCore.Qt.Key_Escape)): self.hide() elif etype == QtCore.QEvent.FocusOut: self.hide()
|
width = font_metrics.maxWidth() * 81 + margin
|
width = font_metrics.width(' ') * 81 + margin
|
def sizeHint(self): """ Reimplemented to suggest a size that is 80 characters wide and 25 lines high. """ font_metrics = QtGui.QFontMetrics(self.font) margin = (self._control.frameWidth() + self._control.document().documentMargin()) * 2 style = self.style() splitwidth = style.pixelMetric(QtGui.QStyle.PM_SplitterWidth)
|
char_width = QtGui.QFontMetrics(self.font).maxWidth()
|
char_width = QtGui.QFontMetrics(self.font).width(' ')
|
def _format_as_columns(self, items, separator=' '): """ Transform a list of strings into a single string with columns.
|
self._control.moveCursor(QtGui.QTextCursor.PreviousBlock) self._control.moveCursor(QtGui.QTextCursor.EndOfBlock)
|
self._control.moveCursor(QtGui.QTextCursor.PreviousBlock, mode=anchormode) self._control.moveCursor(QtGui.QTextCursor.EndOfBlock, mode=anchormode)
|
def _event_filter_console_keypress(self, event): """ Filter key events for the underlying text widget to create a console-like interface. """ intercepted = False cursor = self._control.textCursor() position = cursor.position() key = event.key() ctrl_down = self._control_key_down(event.modifiers()) alt_down = event.modifiers() & QtCore.Qt.AltModifier shift_down = event.modifiers() & QtCore.Qt.ShiftModifier
|
cursor.movePosition(QtGui.QTextCursor.Right)
|
cursor.movePosition(QtGui.QTextCursor.Right, mode=anchormode)
|
def _event_filter_console_keypress(self, event): """ Filter key events for the underlying text widget to create a console-like interface. """ intercepted = False cursor = self._control.textCursor() position = cursor.position() key = event.key() ctrl_down = self._control_key_down(event.modifiers()) alt_down = event.modifiers() & QtCore.Qt.AltModifier shift_down = event.modifiers() & QtCore.Qt.ShiftModifier
|
n=len(self._continuation_prompt))
|
n=len(self._continuation_prompt), mode=anchormode)
|
def _event_filter_console_keypress(self, event): """ Filter key events for the underlying text widget to create a console-like interface. """ intercepted = False cursor = self._control.textCursor() position = cursor.position() key = event.key() ctrl_down = self._control_key_down(event.modifiers()) alt_down = event.modifiers() & QtCore.Qt.AltModifier shift_down = event.modifiers() & QtCore.Qt.ShiftModifier
|
self._context_menu = self._create_context_menu()
|
def __init__(self, kind='plain', parent=None): """ Create a ConsoleWidget. Parameters ---------- kind : str, optional [default 'plain'] The type of text widget to use. Valid values are 'plain', which specifies a QPlainTextEdit, and 'rich', which specifies an QTextEdit.
|
|
if etype == QtCore.QEvent.ContextMenu: self._context_menu.exec_(event.globalPos()) return True
|
def eventFilter(self, obj, event): """ Reimplemented to ensure a console-like behavior in the underlying text widget. """ if obj == self._control: etype = event.type()
|
|
elif etype == QtCore.QEvent.DragMove:
|
if etype == QtCore.QEvent.DragMove:
|
def eventFilter(self, obj, event): """ Reimplemented to ensure a console-like behavior in the underlying text widget. """ if obj == self._control: etype = event.type()
|
def _create_context_menu(self): """ Creates a context menu for the underlying text widget. """ menu = QtGui.QMenu(self) clipboard = QtGui.QApplication.clipboard() copy_action = QtGui.QAction('Copy', self) copy_action.triggered.connect(self.copy) self.copy_available.connect(copy_action.setEnabled) menu.addAction(copy_action) paste_action = QtGui.QAction('Paste', self) paste_action.triggered.connect(self.paste) clipboard.dataChanged.connect( lambda: paste_action.setEnabled(not clipboard.text().isEmpty())) menu.addAction(paste_action) menu.addSeparator() select_all_action = QtGui.QAction('Select All', self) select_all_action.triggered.connect(self.select_all) menu.addAction(select_all_action) return menu
|
def _create_context_menu(self): """ Creates a context menu for the underlying text widget. """ menu = QtGui.QMenu(self) clipboard = QtGui.QApplication.clipboard()
|
|
replaced_event = None
|
def _event_filter_keypress(self, event): """ Filter key events for the underlying text widget to create a console-like interface. """ intercepted = False replaced_event = None cursor = self._control.textCursor() position = cursor.position() key = event.key() ctrl_down = self._control_key_down(event.modifiers()) alt_down = event.modifiers() & QtCore.Qt.AltModifier shift_down = event.modifiers() & QtCore.Qt.ShiftModifier
|
|
key = event.key() ctrl_down = self._control_key_down(event.modifiers())
|
def _event_filter_keypress(self, event): """ Filter key events for the underlying text widget to create a console-like interface. """ intercepted = False replaced_event = None cursor = self._control.textCursor() position = cursor.position() key = event.key() ctrl_down = self._control_key_down(event.modifiers()) alt_down = event.modifiers() & QtCore.Qt.AltModifier shift_down = event.modifiers() & QtCore.Qt.ShiftModifier
|
|
if key in self._ctrl_down_remap: ctrl_down = False key = self._ctrl_down_remap[key] replaced_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress, key, QtCore.Qt.NoModifier) elif key == QtCore.Qt.Key_K:
|
if key == QtCore.Qt.Key_K:
|
def _event_filter_keypress(self, event): """ Filter key events for the underlying text widget to create a console-like interface. """ intercepted = False replaced_event = None cursor = self._control.textCursor() position = cursor.position() key = event.key() ctrl_down = self._control_key_down(event.modifiers()) alt_down = event.modifiers() & QtCore.Qt.AltModifier shift_down = event.modifiers() & QtCore.Qt.ShiftModifier
|
if self._completion_widget.isVisible(): self._completion_widget.keyPressEvent(event) intercepted = event.isAccepted()
|
def _event_filter_keypress(self, event): """ Filter key events for the underlying text widget to create a console-like interface. """ intercepted = False replaced_event = None cursor = self._control.textCursor() position = cursor.position() key = event.key() ctrl_down = self._control_key_down(event.modifiers()) alt_down = event.modifiers() & QtCore.Qt.AltModifier shift_down = event.modifiers() & QtCore.Qt.ShiftModifier
|
|
if not intercepted and replaced_event: QtGui.qApp.sendEvent(self._control, replaced_event)
|
def _event_filter_keypress(self, event): """ Filter key events for the underlying text widget to create a console-like interface. """ intercepted = False replaced_event = None cursor = self._control.textCursor() position = cursor.position() key = event.key() ctrl_down = self._control_key_down(event.modifiers()) alt_down = event.modifiers() & QtCore.Qt.AltModifier shift_down = event.modifiers() & QtCore.Qt.ShiftModifier
|
|
custom_edit_requested = QtCore.pyqtSignal(object, int)
|
custom_edit_requested = QtCore.pyqtSignal(object, object)
|
def __init__(self, block, length, number): self.block = block self.length = length self.number = number
|
self._highlighter.highlighting_on = True if self._get_prompt_cursor().blockNumber() != \ self._get_end_cursor().blockNumber(): self.appendPlainText(' ' * self._input_splitter.indent_spaces)
|
if not self._reading: self._highlighter.highlighting_on = True if self._get_prompt_cursor().blockNumber() != \ self._get_end_cursor().blockNumber(): self.appendPlainText(' ' * self._input_splitter.indent_spaces)
|
def _prompt_started_hook(self): """ Called immediately after a new prompt is displayed. """ self._highlighter.highlighting_on = True
|
self._highlighter.highlighting_on = False
|
if not self._reading: self._highlighter.highlighting_on = False
|
def _prompt_finished_hook(self): """ Called immediately after a prompt is finished, i.e. when some input will be processed and a new prompt displayed. """ self._highlighter.highlighting_on = False
|
if block.isValid():
|
if block.isValid() and not block.text().isEmpty():
|
def _show_interpreter_prompt_for_reply(self, msg): """ Reimplemented for IPython-style prompts. """ # Update the old prompt number if necessary. content = msg['content'] previous_prompt_number = content['prompt_number'] if self._previous_prompt_obj and \ self._previous_prompt_obj.number != previous_prompt_number: block = self._previous_prompt_obj.block if block.isValid():
|
intercept = True
|
intercepted = True
|
def _event_filter_console_keypress(self, event): """ Filter key events for the underlying text widget to create a console-like interface. """ intercepted = False cursor = self._control.textCursor() position = cursor.position() key = event.key() ctrl_down = self._control_key_down(event.modifiers()) alt_down = event.modifiers() & QtCore.Qt.AltModifier shift_down = event.modifiers() & QtCore.Qt.ShiftModifier
|
self.parent().cursorPositionChanged.disconnect(self._update_current)
|
try: self.parent().cursorPositionChanged.disconnect(self._update_current) except TypeError: pass
|
def hideEvent(self, event): """ Reimplemented to disconnect the cursor movement handler. """ QtGui.QListWidget.hideEvent(self, event) self.parent().cursorPositionChanged.disconnect(self._update_current)
|
if not existing:
|
if existing:
|
def __init__(self, app, frontend, existing=False, may_close=True): """ Create a MainWindow for the specified FrontendWidget. The app is passed as an argument to allow for different closing behavior depending on whether we are the Kernel's parent. If existing is True, then this Console does not own the Kernel. If may_close is True, then this Console is permitted to close the kernel """ super(MainWindow, self).__init__() self._app = app self._frontend = frontend self._existing = existing if not existing: self._may_close = may_close else: self._may_close = True self._frontend.exit_requested.connect(self.close) self.setCentralWidget(frontend)
|
kernel_manager.start_kernel(ipython=False)
|
kwargs['ipython']=False
|
def main(): """ Entry point for application. """ # Parse command line arguments. parser = ArgumentParser() kgroup = parser.add_argument_group('kernel options') kgroup.add_argument('-e', '--existing', action='store_true', help='connect to an existing kernel') kgroup.add_argument('--ip', type=str, default=LOCALHOST, help='set the kernel\'s IP address [default localhost]') kgroup.add_argument('--xreq', type=int, metavar='PORT', default=0, help='set the XREQ channel port [default random]') kgroup.add_argument('--sub', type=int, metavar='PORT', default=0, help='set the SUB channel port [default random]') kgroup.add_argument('--rep', type=int, metavar='PORT', default=0, help='set the REP channel port [default random]') kgroup.add_argument('--hb', type=int, metavar='PORT', default=0, help='set the heartbeat port [default: random]') egroup = kgroup.add_mutually_exclusive_group() egroup.add_argument('--pure', action='store_true', help = \ 'use a pure Python kernel instead of an IPython kernel') egroup.add_argument('--pylab', type=str, metavar='GUI', nargs='?', const='auto', help = \ "Pre-load matplotlib and numpy for interactive use. If GUI is not \ given, the GUI backend is matplotlib's, otherwise use one of: \ ['tk', 'gtk', 'qt', 'wx', 'inline'].") wgroup = parser.add_argument_group('widget options') wgroup.add_argument('--paging', type=str, default='inside', choices = ['inside', 'hsplit', 'vsplit', 'none'], help='set the paging style [default inside]') wgroup.add_argument('--rich', action='store_true', help='enable rich text support') wgroup.add_argument('--gui-completion', action='store_true', help='use a GUI widget for tab completion') args = parser.parse_args() # Don't let Qt or ZMQ swallow KeyboardInterupts. import signal signal.signal(signal.SIGINT, signal.SIG_DFL) # Create a KernelManager and start a kernel. kernel_manager = QtKernelManager(xreq_address=(args.ip, args.xreq), sub_address=(args.ip, args.sub), rep_address=(args.ip, args.rep), hb_address=(args.ip, args.hb)) if not args.existing: if args.pure: kernel_manager.start_kernel(ipython=False) elif args.pylab: kernel_manager.start_kernel(pylab=args.pylab) else: kernel_manager.start_kernel() kernel_manager.start_channels() local_kernel = (not args.existing) or args.ip == LOCALHOST # Create the widget. app = QtGui.QApplication([]) if args.pure: kind = 'rich' if args.rich else 'plain' widget = FrontendWidget(kind=kind, paging=args.paging, local_kernel=local_kernel) elif args.rich or args.pylab: widget = RichIPythonWidget(paging=args.paging, local_kernel=local_kernel) else: widget = IPythonWidget(paging=args.paging, local_kernel=local_kernel) widget.gui_completion = args.gui_completion widget.kernel_manager = kernel_manager # Create the main window. window = MainWindow(app, widget, args.existing, may_close=local_kernel) window.setWindowTitle('Python' if args.pure else 'IPython') window.show() # Start the application main loop. app.exec_()
|
kernel_manager.start_kernel(pylab=args.pylab) else: kernel_manager.start_kernel()
|
kwargs['pylab']=args.pylab kernel_manager.start_kernel(**kwargs)
|
def main(): """ Entry point for application. """ # Parse command line arguments. parser = ArgumentParser() kgroup = parser.add_argument_group('kernel options') kgroup.add_argument('-e', '--existing', action='store_true', help='connect to an existing kernel') kgroup.add_argument('--ip', type=str, default=LOCALHOST, help='set the kernel\'s IP address [default localhost]') kgroup.add_argument('--xreq', type=int, metavar='PORT', default=0, help='set the XREQ channel port [default random]') kgroup.add_argument('--sub', type=int, metavar='PORT', default=0, help='set the SUB channel port [default random]') kgroup.add_argument('--rep', type=int, metavar='PORT', default=0, help='set the REP channel port [default random]') kgroup.add_argument('--hb', type=int, metavar='PORT', default=0, help='set the heartbeat port [default: random]') egroup = kgroup.add_mutually_exclusive_group() egroup.add_argument('--pure', action='store_true', help = \ 'use a pure Python kernel instead of an IPython kernel') egroup.add_argument('--pylab', type=str, metavar='GUI', nargs='?', const='auto', help = \ "Pre-load matplotlib and numpy for interactive use. If GUI is not \ given, the GUI backend is matplotlib's, otherwise use one of: \ ['tk', 'gtk', 'qt', 'wx', 'inline'].") wgroup = parser.add_argument_group('widget options') wgroup.add_argument('--paging', type=str, default='inside', choices = ['inside', 'hsplit', 'vsplit', 'none'], help='set the paging style [default inside]') wgroup.add_argument('--rich', action='store_true', help='enable rich text support') wgroup.add_argument('--gui-completion', action='store_true', help='use a GUI widget for tab completion') args = parser.parse_args() # Don't let Qt or ZMQ swallow KeyboardInterupts. import signal signal.signal(signal.SIGINT, signal.SIG_DFL) # Create a KernelManager and start a kernel. kernel_manager = QtKernelManager(xreq_address=(args.ip, args.xreq), sub_address=(args.ip, args.sub), rep_address=(args.ip, args.rep), hb_address=(args.ip, args.hb)) if not args.existing: if args.pure: kernel_manager.start_kernel(ipython=False) elif args.pylab: kernel_manager.start_kernel(pylab=args.pylab) else: kernel_manager.start_kernel() kernel_manager.start_channels() local_kernel = (not args.existing) or args.ip == LOCALHOST # Create the widget. app = QtGui.QApplication([]) if args.pure: kind = 'rich' if args.rich else 'plain' widget = FrontendWidget(kind=kind, paging=args.paging, local_kernel=local_kernel) elif args.rich or args.pylab: widget = RichIPythonWidget(paging=args.paging, local_kernel=local_kernel) else: widget = IPythonWidget(paging=args.paging, local_kernel=local_kernel) widget.gui_completion = args.gui_completion widget.kernel_manager = kernel_manager # Create the main window. window = MainWindow(app, widget, args.existing, may_close=local_kernel) window.setWindowTitle('Python' if args.pure else 'IPython') window.show() # Start the application main loop. app.exec_()
|
str(self._control.toHtml().toUtf8())))
|
html))
|
def export_html(self, parent = None, inline = False): """ Export the contents of the ConsoleWidget as HTML.
|
if self._reading: intercepted = False elif not self._tab_pressed():
|
if self._tab_pressed(): intercepted = not self._in_buffer() else:
|
def _event_filter_console_keypress(self, event): """ Filter key events for the underlying text widget to create a console-like interface. """ intercepted = False cursor = self._control.textCursor() position = cursor.position() key = event.key() ctrl_down = self._control_key_down(event.modifiers()) alt_down = event.modifiers() & QtCore.Qt.AltModifier shift_down = event.modifiers() & QtCore.Qt.ShiftModifier
|
else: intercepted = not self._in_buffer()
|
def _event_filter_console_keypress(self, event): """ Filter key events for the underlying text widget to create a console-like interface. """ intercepted = False cursor = self._control.textCursor() position = cursor.position() key = event.key() ctrl_down = self._control_key_down(event.modifiers()) alt_down = event.modifiers() & QtCore.Qt.AltModifier shift_down = event.modifiers() & QtCore.Qt.ShiftModifier
|
|
elif obj == self._control: if etype == QtCore.QEvent.DragMove: return True elif etype == QtCore.QEvent.KeyPress:
|
elif etype == QtCore.QEvent.KeyPress: if obj == self._control:
|
def eventFilter(self, obj, event): """ Reimplemented to ensure a console-like behavior in the underlying text widget. """ # Re-map keys for all filtered widgets. etype = event.type() if etype == QtCore.QEvent.KeyPress and \ self._control_key_down(event.modifiers()) and \ event.key() in self._ctrl_down_remap: new_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress, self._ctrl_down_remap[event.key()], QtCore.Qt.NoModifier) QtGui.qApp.sendEvent(obj, new_event) return True
|
elif obj == self._page_control: if etype == QtCore.QEvent.KeyPress:
|
elif obj == self._page_control:
|
def eventFilter(self, obj, event): """ Reimplemented to ensure a console-like behavior in the underlying text widget. """ # Re-map keys for all filtered widgets. etype = event.type() if etype == QtCore.QEvent.KeyPress and \ self._control_key_down(event.modifiers()) and \ event.key() in self._ctrl_down_remap: new_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress, self._ctrl_down_remap[event.key()], QtCore.Qt.NoModifier) QtGui.qApp.sendEvent(obj, new_event) return True
|
control = QtGui.QPlainTextEdit()
|
control = ConsolePlainTextEdit()
|
def _create_control(self, kind): """ Creates and connects the underlying text widget. """ if kind == 'plain': control = QtGui.QPlainTextEdit() elif kind == 'rich': control = QtGui.QTextEdit() control.setAcceptRichText(False) else: raise ValueError("Kind %s unknown." % repr(kind)) control.installEventFilter(self) control.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) control.customContextMenuRequested.connect(self._show_context_menu) control.copyAvailable.connect(self.copy_available) control.redoAvailable.connect(self.redo_available) control.undoAvailable.connect(self.undo_available) control.setReadOnly(True) control.setUndoRedoEnabled(False) control.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) return control
|
control = QtGui.QTextEdit()
|
control = ConsoleTextEdit()
|
def _create_control(self, kind): """ Creates and connects the underlying text widget. """ if kind == 'plain': control = QtGui.QPlainTextEdit() elif kind == 'rich': control = QtGui.QTextEdit() control.setAcceptRichText(False) else: raise ValueError("Kind %s unknown." % repr(kind)) control.installEventFilter(self) control.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) control.customContextMenuRequested.connect(self._show_context_menu) control.copyAvailable.connect(self.copy_available) control.redoAvailable.connect(self.redo_available) control.undoAvailable.connect(self.undo_available) control.setReadOnly(True) control.setUndoRedoEnabled(False) control.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) return control
|
control = QtGui.QPlainTextEdit()
|
control = ConsolePlainTextEdit()
|
def _create_page_control(self): """ Creates and connects the underlying paging widget. """ control = QtGui.QPlainTextEdit() control.installEventFilter(self) control.setReadOnly(True) control.setUndoRedoEnabled(False) control.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) return control
|
self._append_plain_text(msg['content']['data'])
|
text = msg['content']['data'].expandtabs(8) self._append_plain_text(text)
|
def _handle_stream(self, msg): """ Handle stdout, stderr, and stdin. """ if not self._hidden and self._is_from_this_session(msg): self._append_plain_text(msg['content']['data']) self._control.moveCursor(QtGui.QTextCursor.End)
|
elif etype == QtCore.QEvent.Resize: QtCore.QTimer.singleShot(0, self._adjust_scrollbars)
|
elif etype == QtCore.QEvent.Resize and not self._filter_resize: self._filter_resize = True QtGui.qApp.sendEvent(obj, event) self._adjust_scrollbars() self._filter_resize = False return True
|
def eventFilter(self, obj, event): """ Reimplemented to ensure a console-like behavior in the underlying text widgets. """ etype = event.type() if etype == QtCore.QEvent.KeyPress:
|
self._control.setTextCursor(cursor)
|
def eventFilter(self, obj, event): """ Reimplemented to ensure a console-like behavior in the underlying text widgets. """ etype = event.type() if etype == QtCore.QEvent.KeyPress:
|
|
self._insert_plain_text_into_buffer(text)
|
self._insert_plain_text_into_buffer(cursor, text)
|
def eventFilter(self, obj, event): """ Reimplemented to ensure a console-like behavior in the underlying text widgets. """ etype = event.type() if etype == QtCore.QEvent.KeyPress:
|
lines = string.splitlines(True) if lines: self._append_plain_text(lines[0]) for i in xrange(1, len(lines)): if self._continuation_prompt_html is None: self._append_plain_text(self._continuation_prompt) else: self._append_html(self._continuation_prompt_html) self._append_plain_text(lines[i])
|
self._insert_plain_text_into_buffer(self._get_prompt_cursor(), string)
|
def _set_input_buffer(self, string): """ Replaces the text in the input buffer with 'string'. """ # For now, it is an error to modify the input buffer during execution. if self._executing: raise RuntimeError("Cannot change input buffer during execution.")
|
self._insert_plain_text_into_buffer(dedent(text))
|
self._insert_plain_text_into_buffer(cursor, dedent(text))
|
def paste(self, mode=QtGui.QClipboard.Clipboard): """ Paste the contents of the clipboard into the input region.
|
def _insert_plain_text_into_buffer(self, text): """ Inserts text into the input buffer at the current cursor position, ensuring that continuation prompts are inserted as necessary.
|
def _insert_plain_text_into_buffer(self, cursor, text): """ Inserts text into the input buffer using the specified cursor (which must be in the input buffer), ensuring that continuation prompts are inserted as necessary.
|
def _insert_plain_text_into_buffer(self, text): """ Inserts text into the input buffer at the current cursor position, ensuring that continuation prompts are inserted as necessary. """ lines = unicode(text).splitlines(True) if lines: self._keep_cursor_in_buffer() cursor = self._control.textCursor() cursor.beginEditBlock() cursor.insertText(lines[0]) for line in lines[1:]: if self._continuation_prompt_html is None: cursor.insertText(self._continuation_prompt) else: self._continuation_prompt = \ self._insert_html_fetching_plain_text( cursor, self._continuation_prompt_html) cursor.insertText(line) cursor.endEditBlock() self._control.setTextCursor(cursor)
|
self._keep_cursor_in_buffer() cursor = self._control.textCursor()
|
def _insert_plain_text_into_buffer(self, text): """ Inserts text into the input buffer at the current cursor position, ensuring that continuation prompts are inserted as necessary. """ lines = unicode(text).splitlines(True) if lines: self._keep_cursor_in_buffer() cursor = self._control.textCursor() cursor.beginEditBlock() cursor.insertText(lines[0]) for line in lines[1:]: if self._continuation_prompt_html is None: cursor.insertText(self._continuation_prompt) else: self._continuation_prompt = \ self._insert_html_fetching_plain_text( cursor, self._continuation_prompt_html) cursor.insertText(line) cursor.endEditBlock() self._control.setTextCursor(cursor)
|
|
self._control.setTextCursor(cursor)
|
def _insert_plain_text_into_buffer(self, text): """ Inserts text into the input buffer at the current cursor position, ensuring that continuation prompts are inserted as necessary. """ lines = unicode(text).splitlines(True) if lines: self._keep_cursor_in_buffer() cursor = self._control.textCursor() cursor.beginEditBlock() cursor.insertText(lines[0]) for line in lines[1:]: if self._continuation_prompt_html is None: cursor.insertText(self._continuation_prompt) else: self._continuation_prompt = \ self._insert_html_fetching_plain_text( cursor, self._continuation_prompt_html) cursor.insertText(line) cursor.endEditBlock() self._control.setTextCursor(cursor)
|
|
def resizeEvent(self, event): """ Adjust the scrollbars manually after a resize event. """ super(ConsoleWidget, self).resizeEvent(event) self._adjust_scrollbars()
|
def eventFilter(self, obj, event): """ Reimplemented to ensure a console-like behavior in the underlying text widgets. """ etype = event.type() if etype == QtCore.QEvent.KeyPress:
|
|
while (time<final_time):
|
while time < final_time:
|
def Maxwell2D(d, Hx, Hy, Ez, final_time): """Integrate TM-mode Maxwell's until final_time starting with initial conditions Hx, Hy, Ez. """ l = d.ldis time = 0 # Runge-Kutta residual storage resHx = np.zeros_like(Hx) resHy = np.zeros_like(Hx) resEz = np.zeros_like(Hx) # compute time step size rLGL = JacobiGQ(0,0, l.N)[0] rmin = abs(rLGL[0]-rLGL[1]) dt_scale = d.dt_scale() dt = dt_scale.min()*rmin*2/3 if do_vis: vis_mesh = mv.triangular_mesh(d.x.T.flatten(), d.y.T.flatten(), Ez.T.flatten(), d.gen_vis_triangles()) # outer time step loop while (time<final_time): if time+dt>final_time: dt = final_time-time for a, b in zip(rk4a, rk4b): # compute right hand side of TM-mode Maxwell's equations rhsHx, rhsHy, rhsEz = MaxwellRHS2D(d, Hx, Hy, Ez) # initiate and increment Runge-Kutta residuals resHx = a*resHx + dt*rhsHx resHy = a*resHy + dt*rhsHy resEz = a*resEz + dt*rhsEz # update fields Hx = Hx+b*resHx Hy = Hy+b*resHy Ez = Ez+b*resEz # Increment time time = time+dt if do_vis: vis_mesh.mlab_source.z = Ez.T.flatten() return Hx, Hy, Ez, time
|
print lift_dev.strides
|
def prepare_dev_data(self): ldis = self.ldis
|
|
tagSet = univ.Integer.tagSet.tagImplicitly(
|
tagSet = univ.OctetString.tagSet.tagImplicitly(
|
def prettyOut(self, value): return ipAddressPrettyOut(value)
|
continue
|
break
|
def loadModules(self, *modNames): # Build a list of available modules if not modNames: modNames = {} for mibSource in self.__mibSources: for modName in mibSource.listdir(): modNames[modName] = None modNames = modNames.keys() if not modNames: raise error.SmiError( 'No MIB module to load at %s' % (self,) ) for modName in modNames: for mibSource in self.__mibSources: debug.logger & debug.flagBld and debug.logger('loadModules: trying %s at %s' % (modName, mibSource)) try: modData, sfx = mibSource.read(modName) except IOError, why: debug.logger & debug.flagBld and debug.logger('loadModules: read %s from %s failed: %s' % (modName, mibSource, why)) continue
|
if not cbFun(sendRequestHandle, None,
|
if not cbFun(sendRequestHandle, errorIndication,
|
def _handleResponse( self, snmpEngine, transportDomain, transportAddress, messageProcessingModel, securityModel, securityName, securityLevel, contextEngineId, contextName, pduVersion, PDU, timeout, retryCount, pMod, rspPDU, sendRequestHandle, (cbFun, cbCtx) ): varBindTable = pMod.apiBulkPDU.getVarBindTable(PDU, rspPDU)
|
debug.logger & debug.flagDsp and debug.logger('sendPdu: new sendPduHandle %s' % sendPduHandle)
|
debug.logger & debug.flagDsp and debug.logger('sendPdu: new sendPduHandle %s, context %s' % (sendPduHandle, expectResponse))
|
def sendPdu( self, snmpEngine, transportDomain, transportAddress, messageProcessingModel, securityModel, securityName, securityLevel, contextEngineId, contextName, pduVersion, PDU, expectResponse ): """PDU dispatcher -- prepare and serialize a request or notification""" # 4.1.1.2 mpHandler = snmpEngine.messageProcessingSubsystems.get( int(messageProcessingModel) ) if mpHandler is None: raise error.StatusInformation( errorIndication='unsupportedMsgProcessingModel' )
|
if contextName is not None:
|
if contextName is None:
|
def addV1System(snmpEngine, securityName, communityName, contextEngineId=None, contextName=None, transportTag=None): snmpCommunityEntry, tblIdx, snmpEngineID = __cookV1SystemInfo( snmpEngine, securityName ) if contextEngineId is None: contextEngineId = snmpEngineID.syntax if contextName is not None: contextName = communityName snmpEngine.msgAndPduDsp.mibInstrumController.writeVars( ((snmpCommunityEntry.name + (8,) + tblIdx, 'destroy'),) ) snmpEngine.msgAndPduDsp.mibInstrumController.writeVars( ((snmpCommunityEntry.name + (8,) + tblIdx, 'createAndGo'), (snmpCommunityEntry.name + (2,) + tblIdx, communityName), (snmpCommunityEntry.name + (3,) + tblIdx, securityName), (snmpCommunityEntry.name + (4,) + tblIdx, contextEngineId), (snmpCommunityEntry.name + (5,) + tblIdx, contextName), (snmpCommunityEntry.name + (6,) + tblIdx, transportTag), (snmpCommunityEntry.name + (7,) + tblIdx, 'nonVolatile')) )
|
readSubTree=(), writeSubTree=(), notifySubTree=()):
|
readSubTree=(), writeSubTree=(), notifySubTree=(), contextName=''):
|
def addVacmUser(snmpEngine, securityModel, securityName, securityLevel, readSubTree=(), writeSubTree=(), notifySubTree=()): ( groupName, securityLevel, readView, writeView, notifyView ) = __cookVacmUserInfo( snmpEngine, securityModel, securityName, securityLevel, ) addVacmGroup( snmpEngine, groupName, securityModel, securityName ) addVacmAccess( snmpEngine, groupName, '', securityModel, securityLevel, 1, readView, writeView, notifyView ) if readSubTree: addVacmView( snmpEngine, readView, "included", readSubTree, '', ) if writeSubTree: addVacmView( snmpEngine, writeView, "included", writeSubTree, '', ) if notifySubTree: addVacmView( snmpEngine, notifyView, "included", notifySubTree, '', )
|
snmpEngine, groupName, '', securityModel, securityLevel, 1,
|
snmpEngine, groupName, contextName, securityModel, securityLevel, 1,
|
def addVacmUser(snmpEngine, securityModel, securityName, securityLevel, readSubTree=(), writeSubTree=(), notifySubTree=()): ( groupName, securityLevel, readView, writeView, notifyView ) = __cookVacmUserInfo( snmpEngine, securityModel, securityName, securityLevel, ) addVacmGroup( snmpEngine, groupName, securityModel, securityName ) addVacmAccess( snmpEngine, groupName, '', securityModel, securityLevel, 1, readView, writeView, notifyView ) if readSubTree: addVacmView( snmpEngine, readView, "included", readSubTree, '', ) if writeSubTree: addVacmView( snmpEngine, writeView, "included", writeSubTree, '', ) if notifySubTree: addVacmView( snmpEngine, notifyView, "included", notifySubTree, '', )
|
nonRepeaters = int(self.getNonRepeaters(reqPDU)) N = min(nonRepeaters, len(self.getVarBindList(reqPDU))) R = max(len(self.getVarBindList(reqPDU))-N, 0) if R == 0: M = 0 else: M = int(min(self.getMaxRepetitions(reqPDU), (len(apiPDU.getVarBindList(rspPDU))-N))/R) varBindList = apiPDU.getVarBindList(rspPDU) varBindRows = []; varBindTable = [ varBindRows ] for idx in range(N): oid, val = apiVarBind.getOIDVal(varBindList[idx]) if exval.endOfMib.isSameTypeWith(val): val = None varBindRows.append((oid, val)) for rowIdx in range(M): if len(varBindTable) < rowIdx+1: varBindTable.append([]) varBindRow = varBindTable[-1] for colIdx in range(R): while rowIdx and len(varBindRow) < N: varBindRow.append(varBindTable[-2][colIdx]) idx = N + rowIdx*R + colIdx oid, val = apiVarBind.getOIDVal(varBindList[idx])
|
nonRepeaters = self.getNonRepeaters(reqPDU) maxRepetitions = self.getMaxRepetitions(reqPDU) reqVarBinds = self.getVarBinds(reqPDU) N = min(int(nonRepeaters), len(reqVarBinds)) M = int(maxRepetitions) R = max(len(reqVarBinds)-N, 0) rspVarBinds = self.getVarBinds(rspPDU) varBindTable = [] if R: for i in range(0, len(rspVarBinds)-N, R): varBindRow = rspVarBinds[:N] + rspVarBinds[N+i:N+R+i] varBindTable.append(varBindRow) elif N: varBindTable.append(rspVarBinds[:N]) for varBindRow in varBindTable: for idx in range(len(varBindRow)): oid, val = varBindRow[idx]
|
def getVarBindTable(self, reqPDU, rspPDU): nonRepeaters = int(self.getNonRepeaters(reqPDU)) N = min(nonRepeaters, len(self.getVarBindList(reqPDU))) R = max(len(self.getVarBindList(reqPDU))-N, 0) if R == 0: M = 0 else: M = int(min(self.getMaxRepetitions(reqPDU), (len(apiPDU.getVarBindList(rspPDU))-N))/R) varBindList = apiPDU.getVarBindList(rspPDU) varBindRows = []; varBindTable = [ varBindRows ]
|
val = None if len(varBindRow) < colIdx+N+1: varBindRow.append((oid, val)) else: varBindRow[colIdx] = (oid, val)
|
varBindRow[idx] = (oid, None)
|
def getVarBindTable(self, reqPDU, rspPDU): nonRepeaters = int(self.getNonRepeaters(reqPDU)) N = min(nonRepeaters, len(self.getVarBindList(reqPDU))) R = max(len(self.getVarBindList(reqPDU))-N, 0) if R == 0: M = 0 else: M = int(min(self.getMaxRepetitions(reqPDU), (len(apiPDU.getVarBindList(rspPDU))-N))/R) varBindList = apiPDU.getVarBindList(rspPDU) varBindRows = []; varBindTable = [ varBindRows ]
|
del self.__timeline[engineIdKey] debug.logger & debug.flagSM and debug.logger('__expireEnginesInfo: expiring %s' % (engineIdKey,))
|
if self.__timeline.has_key(engineIdKey): del self.__timeline[engineIdKey] debug.logger & debug.flagSM and debug.logger('__expireEnginesInfo: expiring %s' % (engineIdKey,))
|
def __expireTimelineInfo(self): if self.__timelineExpQueue.has_key(self.__expirationTimer): for engineIdKey in self.__timelineExpQueue[self.__expirationTimer]: del self.__timeline[engineIdKey] debug.logger & debug.flagSM and debug.logger('__expireEnginesInfo: expiring %s' % (engineIdKey,)) del self.__timelineExpQueue[self.__expirationTimer] self.__expirationTimer = self.__expirationTimer + 1
|
maxSizeResponseScopedPDU = maxMessageSize - 512 if maxSizeResponseScopedPDU < 0:
|
try: maxSizeResponseScopedPDU = maxMessageSize - len(securityParameters) - 48 except PyAsn1Error:
|
def processIncomingMsg( self, snmpEngine, messageProcessingModel, maxMessageSize, securityParameters, securityModel, securityLevel, wholeMsg, msg # XXX ): # 3.2.1 try: securityParameters, rest = decoder.decode( securityParameters, asn1Spec=self._securityParametersSpec ) except PyAsn1Error: snmpInASNParseErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInASNParseErrs') snmpInASNParseErrs.syntax = snmpInASNParseErrs.syntax + 1 raise error.StatusInformation( errorIndication='parseError' )
|
if tag in string.split(str(mibNode.syntax), ' '):
|
if tag in string.split(str(mibNode.syntax)):
|
def getTargetNames(snmpEngine, tag): mibInstrumController = snmpEngine.msgAndPduDsp.mibInstrumController # Transport endpoint ( snmpTargetAddrEntry, snmpTargetAddrTagList ) = mibInstrumController.mibBuilder.importSymbols( 'SNMP-TARGET-MIB', 'snmpTargetAddrEntry', 'snmpTargetAddrTagList' ) targetNames = [] nextName = snmpTargetAddrTagList.name while 1: try: mibNode = snmpTargetAddrTagList.getNextNode(nextName) except NoSuchObjectError: break # XXX stop on eot if tag in string.split(str(mibNode.syntax), ' '): # XXX add __split__() idx = mibNode.name[len(snmpTargetAddrTagList.name):] targetNames.append( snmpTargetAddrEntry.getIndicesFromInstId(idx)[0] ) nextName = mibNode.name return targetNames
|
'PySNMP example command responder at %s' % __file__
|
'PySNMP example command responder'
|
def __call__(self, protoVer): return api.protoModules[protoVer].OctetString( 'PySNMP example command responder at %s' % __file__ )
|
'provides': [ 'pysnmp' ],
|
def howto_install_setuptools(): print """Error: You need setuptools Python package!
|
|
'requires': [ 'pyasn1', 'pycrypto' ], 'provides': [ 'pysnmp' ]
|
'requires': [ 'pyasn1', 'pycrypto' ]
|
def howto_install_setuptools(): print """Error: You need setuptools Python package!
|
errorIndication = 'dataMispatch'
|
errorIndication = 'dataMismatch'
|
def prepareDataElements( self, snmpEngine, transportDomain, transportAddress, wholeMsg ): # 7.2.2 try: msg, restOfwholeMsg = decoder.decode( wholeMsg, asn1Spec=self._snmpMsgSpec ) except PyAsn1Error: snmpInASNParseErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInASNParseErrs') snmpInASNParseErrs.syntax = snmpInASNParseErrs.syntax + 1 raise error.StatusInformation( errorIndication = 'parseError' )
|
errorIndication = 'engineIDMispatch'
|
errorIndication = 'engineIDMismatch'
|
def prepareDataElements( self, snmpEngine, transportDomain, transportAddress, wholeMsg ): # 7.2.2 try: msg, restOfwholeMsg = decoder.decode( wholeMsg, asn1Spec=self._snmpMsgSpec ) except PyAsn1Error: snmpInASNParseErrs, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMPv2-MIB', 'snmpInASNParseErrs') snmpInASNParseErrs.syntax = snmpInASNParseErrs.syntax + 1 raise error.StatusInformation( errorIndication = 'parseError' )
|
appReturn['errorStatus'] = errorStatus appReturn['errorIndex'] = errorIndex appReturn['varBindTable'] = varBindTable
|
if errorStatus == 2: appReturn['errorStatus'] = errorStatus.clone(0) appReturn['errorIndex'] = errorIndex.clone(0) else: appReturn['errorStatus'] = errorStatus appReturn['errorIndex'] = errorIndex appReturn['varBindTable'] = varBindTotalTable
|
def __cbFun( sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, (varBindHead, varBindTotalTable, appReturn) ): if errorIndication or errorStatus: appReturn['errorIndication'] = errorIndication appReturn['errorStatus'] = errorStatus appReturn['errorIndex'] = errorIndex appReturn['varBindTable'] = varBindTable return else: varBindTableRow = varBindTable[-1] for idx in range(len(varBindTableRow)): name, val = varBindTableRow[idx] # XXX extra rows if val is not None and varBindHead[idx].isPrefixOf(name): break else: appReturn['errorIndication'] = errorIndication appReturn['errorStatus'] = errorStatus appReturn['errorIndex'] = errorIndex appReturn['varBindTable'] = varBindTotalTable return varBindTotalTable.extend(varBindTable)
|
self.writeCleanup(name, val, idx, (acFun, acCtx))
|
self.writeUndo(name, val, idx, (acFun, acCtx))
|
def createUndo(self, name, val, idx, (acFun, acCtx)): if val is not None: self.writeCleanup(name, val, idx, (acFun, acCtx))
|
self._vars[name].createUndo(name, val, idx, (acFun, acCtx))
|
try: self._vars[name] == 0 except PyAsn1Error: del self._vars[name] else: self._vars[name].createUndo(name, val, idx, (acFun, acCtx))
|
def createUndo(self, name, val, idx, (acFun, acCtx)): # Set back previous column instance, drop the new one if self.__createdInstances.has_key(name): self._vars[name] = self.__createdInstances[name] del self.__createdInstances[name] # Remove new instance on rollback if self._vars[name] is None: del self._vars[name] else: self._vars[name].createUndo(name, val, idx, (acFun, acCtx))
|
self.__timerCbFuns = [] self.__timeToGo = 0
|
self.__timerCallables = []
|
def __init__(self): self.__transports = {} self.__jobs = {} self.__recvCbFun = None self.__timerCbFuns = [] self.__timeToGo = 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.