本文整理汇总了Python中util.err函数的典型用法代码示例。如果您正苦于以下问题:Python err函数的具体用法?Python err怎么用?Python err使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了err函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: reload
def reload(self):
"""Parse bindings and mangle into an appropriate form"""
self._lookup = {}
self._masks = 0
for action, bindings in self.keys.items():
if not isinstance(bindings, tuple):
bindings = (bindings,)
for binding in bindings:
if not binding or binding == "None":
continue
try:
keyval, mask = self._parsebinding(binding)
# Does much the same, but with poorer error handling.
#keyval, mask = Gtk.accelerator_parse(binding)
except KeymapError as e:
err ("keybindings.reload failed to parse binding '%s': %s" % (binding, e))
else:
if mask & Gdk.ModifierType.SHIFT_MASK:
if keyval == Gdk.KEY_Tab:
keyval = Gdk.KEY_ISO_Left_Tab
mask &= ~Gdk.ModifierType.SHIFT_MASK
else:
keyvals = Gdk.keyval_convert_case(keyval)
if keyvals[0] != keyvals[1]:
keyval = keyvals[1]
mask &= ~Gdk.ModifierType.SHIFT_MASK
else:
keyval = Gdk.keyval_to_lower(keyval)
self._lookup.setdefault(mask, {})
self._lookup[mask][keyval] = action
self._masks |= mask
开发者ID:albfan,项目名称:terminator,代码行数:33,代码来源:keybindings.py
示例2: 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)
开发者ID:swegener,项目名称:terminator,代码行数:33,代码来源:config.py
示例3: split_axis
def split_axis(self, widget, vertical=True, cwd=None, sibling=None, widgetfirst=True):
"""Split the window"""
if self.get_property("term_zoomed") == True:
err("You can't split while a terminal is maximised/zoomed")
return
order = None
maker = Factory()
self.remove(widget)
if vertical:
container = maker.make("VPaned")
else:
container = maker.make("HPaned")
if not sibling:
sibling = maker.make("Terminal")
sibling.set_cwd(cwd)
sibling.spawn_child()
self.add(container)
container.show_all()
order = [widget, sibling]
if widgetfirst is False:
order.reverse()
for term in order:
container.add(term)
container.show_all()
开发者ID:AmosZ,项目名称:terminal,代码行数:29,代码来源:window.py
示例4: register_callbacks
def register_callbacks(self):
"""Connect the GTK+ signals we care about"""
self.connect('key-press-event', self.on_key_press)
self.connect('button-press-event', self.on_button_press)
self.connect('delete_event', self.on_delete_event)
self.connect('destroy', self.on_destroy_event)
self.connect('window-state-event', self.on_window_state_changed)
self.connect('focus-out-event', self.on_focus_out)
self.connect('focus-in-event', self.on_focus_in)
# Attempt to grab a global hotkey for hiding the window.
# If we fail, we'll never hide the window, iconifying instead.
if self.config['keybindings']['hide_window'] != None:
try:
self.hidebound = keybinder.bind(
self.config['keybindings']['hide_window'],
self.on_hide_window)
except (KeyError, NameError):
pass
if not self.hidebound:
err('Unable to bind hide_window key, another instance/window has it.')
self.hidefunc = self.iconify
else:
self.hidefunc = self.hide
开发者ID:adiabuk,项目名称:arch-tf701t,代码行数:25,代码来源:window.py
示例5: isinstance
def isinstance(self, product, classtype):
"""Check if a given product is a particular type of object"""
if classtype in self.types_keys:
# This is now very ugly, but now it's fast :-)
# Someone with real Python skills should fix this to be less insane.
# Optimisations:
# - swap order of imports, otherwise we throw ImportError
# almost every time
# - cache everything we can
try:
type_key = 'terminatorlib.%s' % self.types[classtype]
if type_key not in self.instance_types_keys:
self.instance_types[type_key] = __import__(type_key, None, None, [''])
self.instance_types_keys.append(type_key)
module = self.instance_types[type_key]
except ImportError:
type_key = self.types[classtype]
if type_key not in self.instance_types_keys:
self.instance_types[type_key] = __import__(type_key, None, None, [''])
self.instance_types_keys.append(type_key)
module = self.instance_types[type_key]
return(isinstance(product, getattr(module, classtype)))
else:
err('Factory::isinstance: unknown class type: %s' % classtype)
return(False)
开发者ID:albfan,项目名称:terminator,代码行数:25,代码来源:factory.py
示例6: run_benchmarks
def run_benchmarks(debug=False, overwrite=False, refine=None, synonly=False, service=False, apps=None):
results = RunResults('benchmarks', overwrite)
if refine is None:
refine = 0
cases = load_app_sources(BENCHMARK_DIR, defwarn=True, apps=apps)
apps = list(cases.keys())
apps.sort()
for appname in apps:
inps = cases[appname]
srcfls = inps[0]
poldict = inps[1]
seeds = inps[2]
apppath = inps[3]
opts = inps[4]
opts.append('-N')
opts.append(appname)
if synonly:
opts.append('-z')
if appname in LARGE_BENCHMARKS:
# Forgo interprocedural analysis for these benchmarks.
opts.append('-P')
# Run with each policy file separately.
if MAJOR >= 3: politems = poldict.items()
else: politems = poldict.iteritems()
for poldesc, polfiles in politems:
result = RunResult(False, False)
results.add(result)
out('Analyzing %s' % appname)
if service:
outp, errp = query_jam_service(srcfls, polfiles, refine=refine, seeds=seeds, moreopts=opts)
else:
outp, errp = run_jam(srcfls, polfiles, refine=refine, debug=debug, seeds=seeds, moreopts=opts)
# Error case, message printed in |run_jam|.
if outp is None: continue
refsuf = get_suffix(synonly, refine, poldesc)
expfile = '%s.%s.out.js' % (appname, refsuf)
exppath = os.path.join(apppath, expfile)
result.js_ok = process_result(outp, exppath, overwrite)
infopath = get_info_path(errp)
if infopath is None:
err('Could not determine info path: %s\n' % appname)
err('ERRP: %s' % errp)
continue
infoexpfile = '%s.%s.info.txt' % (appname, refsuf)
infoexppath = os.path.join(apppath, infoexpfile)
result.info_ok = process_info(infopath, infoexppath, overwrite)
sys.stderr.write('\n')
results.printSummary()
开发者ID:blackoutjack,项目名称:jamweaver,代码行数:60,代码来源:run.py
示例7: 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)
开发者ID:adiabuk,项目名称:arch-tf701t,代码行数:29,代码来源:window.py
示例8: __init__
def __init__(self, window):
"""Class initialiser"""
if isinstance(window.get_child(), gtk.Notebook):
err('There is already a Notebook at the top of this window')
raise(ValueError)
Container.__init__(self)
gtk.Notebook.__init__(self)
self.terminator = Terminator()
self.window = window
gobject.type_register(Notebook)
self.register_signals(Notebook)
self.connect('switch-page', self.deferred_on_tab_switch)
self.configure()
child = window.get_child()
window.remove(child)
window.add(self)
window_last_active_term = window.last_active_term
self.newtab(widget=child)
if window_last_active_term:
self.set_last_active_term(window_last_active_term)
window.last_active_term = None
self.show_all()
开发者ID:dannywillems,项目名称:terminator,代码行数:25,代码来源:notebook.py
示例9: save_tweets
def save_tweets(filename, tweets):
"""Save tweets from dict to file.
Save tweets from dict to UTF-8 encoded file, one per line:
<tweet id (number)> <tweet text>
Tweet text is:
<date> <<user>> [RT @<user>: ]<text>
Args:
filename: A string representing the file name to save tweets to.
tweets: A dict mapping tweet-ids (int) to tweet text (str).
"""
if len(tweets) == 0:
return
try:
archive = open(filename,"w")
except IOError as e:
err("Cannot save tweets: %s" % str(e))
return
for k in sorted(tweets.keys()):
archive.write("%i %s\n" % (k, tweets[k].encode('utf-8')))
archive.close()
开发者ID:yy221,项目名称:rpush,代码行数:25,代码来源:archiver.py
示例10: get_visible_terminals
def get_visible_terminals(self):
"""Walk down the widget tree to find all of the visible terminals.
Mostly using Container::get_visible_terminals()"""
terminals = {}
if not hasattr(self, 'cached_maker'):
self.cached_maker = Factory()
maker = self.cached_maker
child = self.get_child()
if not child:
return([])
# If our child is a Notebook, reset to work from its visible child
if maker.isinstance(child, 'Notebook'):
pagenum = child.get_current_page()
child = child.get_nth_page(pagenum)
if maker.isinstance(child, 'Container'):
terminals.update(child.get_visible_terminals())
elif maker.isinstance(child, 'Terminal'):
terminals[child] = child.get_allocation()
else:
err('Unknown child type %s' % type(child))
return(terminals)
开发者ID:adiabuk,项目名称:arch-tf701t,代码行数:25,代码来源:window.py
示例11: load_plugins
def load_plugins(self, testing=False):
"""Load all plugins present in the plugins/ directory in our module"""
if self.done:
dbg('PluginRegistry::load_plugins: Already loaded')
return
config = Config()
for plugindir in self.path:
sys.path.insert(0, plugindir)
try:
files = os.listdir(plugindir)
except OSError:
sys.path.remove(plugindir)
continue
for plugin in files:
pluginpath = os.path.join(plugindir, plugin)
if os.path.isfile(pluginpath) and plugin[-3:] == '.py':
dbg('PluginRegistry::load_plugins: Importing plugin %s' %
plugin)
try:
module = __import__(plugin[:-3], None, None, [''])
for item in getattr(module, 'AVAILABLE'):
if item not in self.available_plugins.keys():
func = getattr(module, item)
self.available_plugins[item] = func
if not testing and item not in config['enabled_plugins']:
dbg('plugin %s not enabled, skipping' % item)
continue
if item not in self.instances:
self.instances[item] = func()
except Exception, ex:
err('PluginRegistry::load_plugins: Importing plugin %s \
failed: %s' % (plugin, ex))
开发者ID:AmosZ,项目名称:terminal,代码行数:35,代码来源:plugin.py
示例12: __init__
def __init__(self):
"""Class initialiser"""
self.terminator = Terminator()
self.terminator.register_window(self)
Container.__init__(self)
gtk.Window.__init__(self)
gobject.type_register(Window)
self.register_signals(Window)
self.set_property("allow-shrink", True)
self.apply_icon()
self.register_callbacks()
self.apply_config()
self.title = WindowTitle(self)
self.title.update()
options = self.config.options_get()
if options:
if options.forcedtitle is not None:
self.title.force_title(options.forcedtitle)
if options.role is not None:
self.set_role(options.role)
if options.geometry is not None:
if not self.parse_geometry(options.geometry):
err("Window::__init__: Unable to parse geometry: %s" % options.geometry)
self.pending_set_rough_geometry_hint = False
开发者ID:AmosZ,项目名称:terminal,代码行数:32,代码来源:window.py
示例13: 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)
开发者ID:FreedomBen,项目名称:terminator,代码行数:34,代码来源:config.py
示例14: 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())
开发者ID:adiabuk,项目名称:arch-tf701t,代码行数:33,代码来源:window.py
示例15: 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)
开发者ID:janisozaur,项目名称:terminator,代码行数:59,代码来源:notebook.py
示例16: on_css_parsing_error
def on_css_parsing_error(self, provider, section, error, user_data=None):
"""Report CSS parsing issues"""
file_path = section.get_file().get_path()
line_no = section.get_end_line() +1
col_no = section.get_end_position() + 1
err('%s, at line %d, column %d, of file %s' % (error.message,
line_no, col_no,
file_path))
开发者ID:albfan,项目名称:terminator,代码行数:8,代码来源:terminator.py
示例17: unload
def unload(self):
"""Handle being removed"""
if not self.match:
err('unload called without self.handler_name being set')
return
terminator = Terminator()
for terminal in terminator.terminals:
terminal.match_remove(self.handler_name)
开发者ID:dannywillems,项目名称:terminator,代码行数:8,代码来源:plugin.py
示例18: proc_get_pid_cwd
def proc_get_pid_cwd(pid, path):
"""Extract the cwd of a PID from proc, given the PID and the /proc path to
insert it into, e.g. /proc/%s/cwd"""
try:
cwd = os.path.realpath(path % pid)
except Exception, ex:
err('Unable to get cwd for PID %s: %s' % (pid, ex))
cwd = '/'
开发者ID:dannywillems,项目名称:terminator,代码行数:8,代码来源:cwd.py
示例19: update_tab_label_text
def update_tab_label_text(self, widget, text):
"""Update the text of a tab label"""
notebook = self.find_tab_root(widget)
label = self.get_tab_label(notebook)
if not label:
err('Notebook::update_tab_label_text: %s not found' % widget)
return
label.set_label(text)
开发者ID:dannywillems,项目名称:terminator,代码行数:9,代码来源:notebook.py
示例20: replace
def replace(self, oldwidget, newwidget):
"""Replace the child oldwidget with newwidget. This is the bare minimum
required for this operation. Containers should override it if they have
more complex requirements"""
if not oldwidget in self.get_children():
err('%s is not a child of %s' % (oldwidget, self))
return
self.remove(oldwidget)
self.add(newwidget)
开发者ID:albfan,项目名称:terminator,代码行数:9,代码来源:container.py
注:本文中的util.err函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论