本文整理汇总了Python中util.dbg函数的典型用法代码示例。如果您正苦于以下问题:Python dbg函数的具体用法?Python dbg怎么用?Python dbg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_layout
def create_layout(self, layout):
"""Apply any config items from our layout"""
if not layout.has_key('children'):
err('layout describes no children: %s' % layout)
return
children = layout['children']
if len(children) != 1:
# We're a Window, we can only have one child
err('incorrect number of children for Window: %s' % layout)
return
child = children[children.keys()[0]]
terminal = self.get_children()[0]
dbg('Making a child of type: %s' % child['type'])
if child['type'] == 'VPaned':
self.split_axis(terminal, True)
elif child['type'] == 'HPaned':
self.split_axis(terminal, False)
elif child['type'] == 'Notebook':
self.tab_new()
i = 2
while i < len(child['children']):
self.tab_new()
i = i + 1
elif child['type'] == 'Terminal':
pass
else:
err('unknown child type: %s' % child['type'])
return
self.get_children()[0].create_layout(child)
示例2: move_tab
def move_tab(self, widget, direction):
"""Handle a keyboard shortcut for moving tab positions"""
maker = Factory()
notebook = self.get_child()
if not maker.isinstance(notebook, 'Notebook'):
dbg('not in a notebook, refusing to move tab %s' % direction)
return
dbg('moving tab %s' % direction)
numpages = notebook.get_n_pages()
page = notebook.get_current_page()
child = notebook.get_nth_page(page)
if direction == 'left':
if page == 0:
page = numpages
else:
page = page - 1
elif direction == 'right':
if page == numpages - 1:
page = 0
else:
page = page + 1
else:
err('unknown direction: %s' % direction)
return
notebook.reorder_child(child, page)
示例3: on_window_state_changed
def on_window_state_changed(self, window, event):
"""Handle the state of the window changing"""
self.isfullscreen = bool(event.new_window_state & gtk.gdk.WINDOW_STATE_FULLSCREEN)
self.ismaximised = bool(event.new_window_state & gtk.gdk.WINDOW_STATE_MAXIMIZED)
dbg("Window::on_window_state_changed: fullscreen=%s, maximised=%s" % (self.isfullscreen, self.ismaximised))
return False
示例4: save
def save(self):
"""Save the config to a file"""
dbg("ConfigBase::save: saving config")
parser = ConfigObj()
parser.indent_type = " "
for section_name in ["global_config", "keybindings"]:
dbg("ConfigBase::save: Processing section: %s" % section_name)
section = getattr(self, section_name)
parser[section_name] = dict_diff(DEFAULTS[section_name], section)
parser["profiles"] = {}
for profile in self.profiles:
dbg("ConfigBase::save: Processing profile: %s" % profile)
parser["profiles"][profile] = dict_diff(DEFAULTS["profiles"]["default"], self.profiles[profile])
parser["layouts"] = {}
for layout in self.layouts:
dbg("ConfigBase::save: Processing layout: %s" % layout)
parser["layouts"][layout] = self.layouts[layout]
parser["plugins"] = {}
for plugin in self.plugins:
dbg("ConfigBase::save: Processing plugin: %s" % plugin)
parser["plugins"][plugin] = self.plugins[plugin]
config_dir = get_config_dir()
if not os.path.isdir(config_dir):
os.makedirs(config_dir)
try:
parser.write(open(self.command_line_options.config, "w"))
except Exception, ex:
err("ConfigBase::save: Unable to save config: %s" % ex)
示例5: input
def input(self, data):
if "type" in data:
function_name = "process_" + data["type"]
dbg("got {}".format(function_name))
for plugin in self.bot_plugins:
plugin.register_jobs()
plugin.do(function_name, data)
示例6: save
def save(self):
"""Save the config to a file"""
dbg('ConfigBase::save: saving config')
parser = ConfigObj()
parser.indent_type = ' '
for section_name in ['global_config', 'keybindings']:
dbg('ConfigBase::save: Processing section: %s' % section_name)
section = getattr(self, section_name)
parser[section_name] = dict_diff(DEFAULTS[section_name], section)
parser['profiles'] = {}
for profile in self.profiles:
dbg('ConfigBase::save: Processing profile: %s' % profile)
parser['profiles'][profile] = dict_diff(
DEFAULTS['profiles']['default'], self.profiles[profile])
parser['layouts'] = {}
for layout in self.layouts:
dbg('ConfigBase::save: Processing layout: %s' % layout)
parser['layouts'][layout] = self.layouts[layout]
parser['plugins'] = {}
for plugin in self.plugins:
dbg('ConfigBase::save: Processing plugin: %s' % plugin)
parser['plugins'][plugin] = self.plugins[plugin]
config_dir = get_config_dir()
if not os.path.isdir(config_dir):
os.makedirs(config_dir)
try:
parser.write(open(self.command_line_options.config, 'w'))
except Exception, ex:
err('ConfigBase::save: Unable to save config: %s' % ex)
示例7: tab_change
def tab_change(self, widget, num=None):
"""Change to a specific tab"""
if num is None:
err('must specify a tab to change to')
maker = Factory()
child = self.get_child()
if not maker.isinstance(child, 'Notebook'):
dbg('child is not a notebook, nothing to change to')
return
if num == -1:
# Go to the next tab
cur = child.get_current_page()
pages = child.get_n_pages()
if cur == pages - 1:
num = 0
else:
num = cur + 1
elif num == -2:
# Go to the previous tab
cur = child.get_current_page()
if cur > 0:
num = cur - 1
else:
num = child.get_n_pages() - 1
child.set_current_page(num)
# Work around strange bug in gtk-2.12.11 and pygtk-2.12.1
# Without it, the selection changes, but the displayed page doesn't
# change
child.set_current_page(child.get_current_page())
示例8: group_emit
def group_emit(self, terminal, group, type, event):
"""Emit to each terminal in a group"""
dbg('Terminator::group_emit: emitting a keystroke for group %s' %
group)
for term in self.terminals:
if term != terminal and term.group == group:
term.vte.emit(type, event)
示例9: input
def input(self, data):
data = Message(data)
function_name = "process_" + data.type.lower()
dbg("got {}".format(function_name))
for plugin in self.bot_plugins:
plugin.register_jobs()
plugin.do(function_name, data)
示例10: register_terminal
def register_terminal(self, terminal):
"""Register a new terminal widget"""
if terminal not in self.terminals:
dbg('Terminator::register_terminal: registering %s:%s' %
(id(terminal), type(terminal)))
self.terminals.append(terminal)
terminal.connect('ungroup-all', self.ungroup_all)
示例11: get_pid_cwd
def get_pid_cwd():
"""Determine an appropriate cwd function for the OS we are running on"""
func = lambda pid: None
system = platform.system()
if system == 'Linux':
dbg('Using Linux get_pid_cwd')
func = linux_get_pid_cwd
elif system == 'FreeBSD':
try:
import freebsd
func = freebsd.get_process_cwd
dbg('Using FreeBSD get_pid_cwd')
except (OSError, NotImplementedError, ImportError):
dbg('FreeBSD version too old for get_pid_cwd')
elif system == 'SunOS':
dbg('Using SunOS get_pid_cwd')
func = sunos_get_pid_cwd
elif psutil_avail:
func = psutil_cwd
else:
dbg('Unable to determine a get_pid_cwd for OS: %s' % system)
return(func)
示例12: create_layout
def create_layout(self, layout):
"""Apply layout configuration"""
if not layout.has_key('children'):
err('layout specifies no children: %s' % layout)
return
children = layout['children']
if len(children) != 2:
# Paned widgets can only have two children
err('incorrect number of children for Paned: %s' % layout)
return
keys = []
# FIXME: This seems kinda ugly. All we want here is to know the order
# of children based on child['order']
try:
child_order_map = {}
for child in children:
key = children[child]['order']
child_order_map[key] = child
map_keys = child_order_map.keys()
map_keys.sort()
for map_key in map_keys:
keys.append(child_order_map[map_key])
except KeyError:
# We've failed to figure out the order. At least give the terminals
# in the wrong order
keys = children.keys()
num = 0
for child_key in keys:
child = children[child_key]
dbg('Making a child of type: %s' % child['type'])
if child['type'] == 'Terminal':
pass
elif child['type'] == 'VPaned':
if num == 0:
terminal = self.get_child1()
else:
terminal = self.get_child2()
self.split_axis(terminal, True)
elif child['type'] == 'HPaned':
if num == 0:
terminal = self.get_child1()
else:
terminal = self.get_child2()
self.split_axis(terminal, False)
else:
err('unknown child type: %s' % child['type'])
num = num + 1
self.get_child1().create_layout(children[keys[0]])
self.get_child2().create_layout(children[keys[1]])
# Set the position with ratio. For some reason more reliable than by pos.
if layout.has_key('ratio'):
self.ratio = float(layout['ratio'])
self.set_position_by_ratio()
示例13: create_layout
def create_layout(self, layout):
"""Apply layout configuration"""
def child_compare(a, b):
order_a = children[a]['order']
order_b = children[b]['order']
if (order_a == order_b):
return 0
if (order_a < order_b):
return -1
if (order_a > order_b):
return 1
if not layout.has_key('children'):
err('layout specifies no children: %s' % layout)
return
children = layout['children']
if len(children) <= 1:
#Notebooks should have two or more children
err('incorrect number of children for Notebook: %s' % layout)
return
num = 0
keys = children.keys()
keys.sort(child_compare)
for child_key in keys:
child = children[child_key]
dbg('Making a child of type: %s' % child['type'])
if child['type'] == 'Terminal':
pass
elif child['type'] == 'VPaned':
page = self.get_nth_page(num)
self.split_axis(page, True)
elif child['type'] == 'HPaned':
page = self.get_nth_page(num)
self.split_axis(page, False)
num = num + 1
num = 0
for child_key in keys:
page = self.get_nth_page(num)
if not page:
# This page does not yet exist, so make it
self.newtab(children[child_key])
page = self.get_nth_page(num)
if layout.has_key('labels'):
labeltext = layout['labels'][num]
if labeltext and labeltext != "None":
label = self.get_tab_label(page)
label.set_custom_label(labeltext)
page.create_layout(children[child_key])
num = num + 1
if layout.has_key('active_page'):
self.set_current_page(int(layout['active_page']))
else:
self.set_current_page(0)
示例14: new_tab
def new_tab(self, options=dbus.Dictionary()):
"""Create a new tab"""
dbg('dbus method called: new_tab with parameters %s'%(options))
oldopts = self.terminator.config.options_get()
oldopts.__dict__ = options
self.terminator.config.options_set(oldopts)
window = self.terminator.get_windows()[0]
window.tab_new()
示例15: with_proxy
def with_proxy(func):
"""Decorator function to connect to the session dbus bus"""
dbg('dbus client call: %s' % func.func_name)
def _exec(*args, **argd):
bus = dbus.SessionBus()
proxy = bus.get_object(BUS_NAME, BUS_PATH)
func(proxy, *args, **argd)
return _exec