本文整理汇总了Python中utool.printex函数的典型用法代码示例。如果您正苦于以下问题:Python printex函数的具体用法?Python printex怎么用?Python printex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了printex函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: set_process_title
def set_process_title(title):
try:
import setproctitle
setproctitle.setproctitle(title)
except ImportError as ex:
import utool
utool.printex(ex, iswarning=True)
开发者ID:Erotemic,项目名称:utool,代码行数:7,代码来源:util_cplat.py
示例2: paint
def paint(dgt, painter, option, qtindex):
"""
TODO: prevent recursive paint
"""
view = dgt.parent()
offset = view.verticalOffset() + option.rect.y()
# Check if still in viewport
if view_would_not_be_visible(view, offset):
return None
try:
thumb_path = dgt.get_thumb_path_if_exists(view, offset, qtindex)
if thumb_path is not None:
# Check if still in viewport
if view_would_not_be_visible(view, offset):
return None
# Read the precomputed thumbnail
qimg = read_thumb_as_qimg(thumb_path)
width, height = qimg.width(), qimg.height()
# Adjust the cell size to fit the image
dgt.adjust_thumb_cell_size(qtindex, width, height)
# Check if still in viewport
if view_would_not_be_visible(view, offset):
return None
# Paint image on an item in some view
painter.save()
painter.setClipRect(option.rect)
painter.translate(option.rect.x(), option.rect.y())
painter.drawImage(QtCore.QRectF(0, 0, width, height), qimg)
painter.restore()
except Exception as ex:
# PSA: Always report errors on Exceptions!
print('Error in APIThumbDelegate')
ut.printex(ex, 'Error in APIThumbDelegate')
painter.save()
painter.restore()
开发者ID:Erotemic,项目名称:guitool,代码行数:35,代码来源:api_thumb_delegate.py
示例3: show_matches
def show_matches(qres, ibs, aid, qreq_=None, *args, **kwargs):
from ibeis.viz import viz_matches
try:
return viz_matches.show_matches(ibs, qres, aid, *args, qreq_=qreq_, **kwargs)
except Exception as ex:
ut.printex(ex, 'failed in qres.show_matches', keys=['aid', 'qreq_'])
raise
开发者ID:heroinlin,项目名称:ibeis,代码行数:7,代码来源:hots_query_result.py
示例4: update_query_cfg
def update_query_cfg(query_cfg, **cfgdict):
# Each config paramater should be unique
# So updating them all should not cause conflicts
# FIXME: Should be able to infer all the children that need updates
#
# apply codename before updating subconfigs
query_cfg.apply_codename(cfgdict.get('codename', None))
# update subconfigs
query_cfg.nn_cfg.update(**cfgdict)
query_cfg.nnweight_cfg.update(**cfgdict)
query_cfg.sv_cfg.update(**cfgdict)
query_cfg.agg_cfg.update(**cfgdict)
query_cfg.flann_cfg.update(**cfgdict)
query_cfg.smk_cfg.update(**cfgdict)
query_cfg.smk_cfg.vocabassign_cfg.update(**cfgdict)
query_cfg.smk_cfg.vocabtrain_cfg.update(**cfgdict)
query_cfg.rrvsone_cfg.update(**cfgdict)
query_cfg._featweight_cfg.update(**cfgdict)
query_cfg._featweight_cfg._feat_cfg.update(**cfgdict)
query_cfg._featweight_cfg._feat_cfg._chip_cfg.update(**cfgdict)
query_cfg.update(**cfgdict)
# Ensure feasibility of the configuration
try:
query_cfg.make_feasible()
except AssertionError as ex:
print(ut.dict_str(cfgdict, sorted_=True))
ut.printex(ex)
raise
开发者ID:Erotemic,项目名称:ibeis,代码行数:28,代码来源:Config.py
示例5: _get_data
def _get_data(model, qtindex, **kwargs):
#row = qtindex.row()
col = qtindex.column()
row_id = model._get_row_id(qtindex) # row_id w.r.t. to sorting
getter = model.col_getter_list[col] # getter for this column
# Using this getter may not be thread safe
try:
# Should this work around decorators?
#data = getter((row_id,), **kwargs)[0]
data = getter(row_id, **kwargs)
except Exception as ex:
ut.printex(
ex,
'[api_item_model] problem getting in column %r' % (col,),
keys=['model.name', 'getter', 'row_id', 'col', 'qtindex'])
#getting from: %r' % ut.util_str.get_callable_name(getter))
raise
# <HACK: MODEL_CACHE>
#cachekey = (row_id, col)
#try:
# if True: # Cache is disabled
# raise KeyError('')
# #data = model.cache[cachekey]
#except KeyError:
# data = getter(row_id)
# #model.cache[cachekey] = data
# </HACK: MODEL_CACHE>
return data
开发者ID:Erotemic,项目名称:guitool,代码行数:28,代码来源:api_item_model.py
示例6: package_installer
def package_installer():
"""
system dependent post pyinstaller step
"""
print('[installer] +--- PACKAGE_INSTALLER ---')
#build_win32_inno_installer()
cwd = get_setup_dpath()
# Build the os-appropriate package
if sys.platform.startswith('win32'):
installer_src = build_win32_inno_installer()
installer_fname_fmt = 'ibeis-win32-install-{timestamp}.exe'
elif sys.platform.startswith('darwin'):
installer_src = build_osx_dmg_installer()
installer_fname_fmt = 'ibeis-osx-install-{timestamp}.dmg'
elif sys.platform.startswith('linux'):
installer_src = build_linux_zip_binaries()
installer_fname_fmt = 'ibeis-linux-binary-{timestamp}.zip'
#try:
# raise NotImplementedError('no linux packager (rpm or deb) supported. try running with --build')
#except Exception as ex:
# ut.printex(ex)
#pass
# timestamp the installer name
installer_fname = installer_fname_fmt.format(timestamp=ut.get_timestamp())
installer_dst = join(cwd, 'dist', installer_fname)
try:
ut.move(installer_src, installer_dst)
except Exception as ex:
ut.printex(ex, 'error moving setups', iswarning=True)
print('[installer] L___ FINISH PACKAGE_INSTALLER ___')
开发者ID:Erotemic,项目名称:ibeis,代码行数:30,代码来源:installers.py
示例7: test_ignore_exec_traceback
def test_ignore_exec_traceback():
r"""
CommandLine:
python -m utool.util_decor --test-test_ignore_exec_traceback
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_decor import * # NOQA
>>> result = test_ignore_exec_traceback()
>>> print(result)
"""
import utool as ut
@ut.indent_func
def foobar():
print('foobar')
raise Exception('foobar')
try:
print('printing foobar')
foobar()
except Exception as ex:
#import sys
#exc_type, exc_value, exc_traceback = sys.exc_info()
#print(exc_traceback)
# TODO: ensure decorators are not printed in stack trace
ut.printex(ex, tb=True)
开发者ID:animalus,项目名称:utool,代码行数:27,代码来源:util_decor.py
示例8: aggregate_descriptors
def aggregate_descriptors(ibs, aid_list):
""" Aggregates descriptors with inverted information
Return agg_index to(2) -> desc (descriptor)
aid (annotation rowid)
fx (feature index w.r.t. aid)
</CYTH> """
print('[agg_desc] stacking descriptors from %d annotations' % len(aid_list))
desc_list = ibs.get_annot_desc(aid_list)
# Build inverted index of (aid, fx) pairs
aid_nFeat_iter = izip(aid_list, imap(len, desc_list))
nFeat_iter = imap(len, desc_list)
# generate aid inverted index for each feature in each annotation
_ax2_aid = ([aid] * nFeat for (aid, nFeat) in aid_nFeat_iter)
# generate featx inverted index for each feature in each annotation
_ax2_fx = (xrange(nFeat) for nFeat in nFeat_iter)
# Flatten generators into the inverted index
dx2_aid = np.array(list(chain.from_iterable(_ax2_aid)))
dx2_fx = np.array(list(chain.from_iterable(_ax2_fx)))
try:
# Stack descriptors into numpy array corresponding to inverted inexed
dx2_desc = np.vstack(desc_list)
print('[agg_desc] stacked %d descriptors from %d annotations' % (len(dx2_desc), len(aid_list)))
except MemoryError as ex:
utool.printex(ex, 'cannot build inverted index', '[!memerror]')
raise
return dx2_desc, dx2_aid, dx2_fx
开发者ID:byteyoo,项目名称:ibeis,代码行数:26,代码来源:hots_nn_index.py
示例9: build_flann_inverted_index
def build_flann_inverted_index(ibs, aid_list):
"""
Build a inverted index (using FLANN)
</CYTH> """
try:
if len(aid_list) == 0:
msg = ('len(aid_list) == 0\n'
'Cannot build inverted index without features!')
raise AssertionError(msg)
dx2_desc, dx2_aid, dx2_fx = aggregate_descriptors(ibs, aid_list)
except Exception as ex:
intostr = ibs.get_infostr() # NOQA
dbname = ibs.get_dbname() # NOQA
num_images = ibs.get_num_images() # NOQA
num_annotations = ibs.get_num_annotations() # NOQA
num_names = ibs.get_num_names() # NOQA
utool.printex(ex, '', 'cannot build inverted index', locals().keys())
raise
# Build/Load the flann index
flann_cfgstr = get_flann_cfgstr(ibs, aid_list)
flann_params = {'algorithm': 'kdtree', 'trees': 4}
precomp_kwargs = {'cache_dir': ibs.get_flann_cachedir(),
'cfgstr': flann_cfgstr,
'flann_params': flann_params,
'force_recompute': NOCACHE_FLANN}
flann = nntool.flann_cache(dx2_desc, **precomp_kwargs)
return dx2_desc, dx2_aid, dx2_fx, flann
开发者ID:byteyoo,项目名称:ibeis,代码行数:27,代码来源:hots_nn_index.py
示例10: add_annot_chips
def add_annot_chips(ibs, aid_list, qreq_=None):
"""
FIXME: This is a dirty dirty function
Adds chip data to the ANNOTATION. (does not create ANNOTATIONs. first use add_annots
and then pass them here to ensure chips are computed) """
# Ensure must be false, otherwise an infinite loop occurs
from ibeis.model.preproc import preproc_chip
cid_list = ibs.get_annot_chip_rowids(aid_list, ensure=False)
dirty_aids = ut.get_dirty_items(aid_list, cid_list)
if len(dirty_aids) > 0:
if ut.VERBOSE:
print('[ibs] adding chips')
try:
# FIXME: Cant be lazy until chip config / delete issue is fixed
preproc_chip.compute_and_write_chips(ibs, aid_list)
#preproc_chip.compute_and_write_chips_lazy(ibs, aid_list)
params_iter = preproc_chip.add_annot_chips_params_gen(ibs, dirty_aids)
except AssertionError as ex:
ut.printex(ex, '[!ibs.add_annot_chips]')
print('[!ibs.add_annot_chips] ' + ut.list_dbgstr('aid_list'))
raise
colnames = (ANNOT_ROWID, 'config_rowid', 'chip_uri', 'chip_width', 'chip_height',)
get_rowid_from_superkey = functools.partial(ibs.get_annot_chip_rowids, ensure=False, qreq_=qreq_)
cid_list = ibs.dbcache.add_cleanly(const.CHIP_TABLE, colnames, params_iter, get_rowid_from_superkey)
return cid_list
开发者ID:Erotemic,项目名称:ibeis,代码行数:26,代码来源:manual_dependant_funcs.py
示例11: all_figures_bring_to_front
def all_figures_bring_to_front():
try:
all_figures = get_all_figures()
for fig in iter(all_figures):
bring_to_front(fig)
except Exception as ex:
ut.printex(ex)
开发者ID:Erotemic,项目名称:plottool,代码行数:7,代码来源:fig_presenter.py
示例12: _new_image_hesaff
def _new_image_hesaff(img, **kwargs):
""" Creates new detector object which reads the image """
hesaff_params = _make_hesaff_cpp_params(kwargs)
if __DEBUG__:
print('[hes] New Hesaff')
print('[hes] hesaff_params=%r' % (hesaff_params,))
hesaff_args = hesaff_params.values() # pass all parameters to HESAFF_CLIB
rows, cols = img.shape[0:2]
if len(img.shape) == 2:
channels = 1
else:
channels = img.shape[2]
try:
hesaff_ptr = HESAFF_CLIB.new_hesaff_image(
img, rows, cols, channels, *hesaff_args)
except Exception as ex:
msg = ('hesaff_ptr = '
'HESAFF_CLIB.new_hesaff_image(img_realpath, *hesaff_args)')
print(msg)
print('hesaff_args = ')
print(hesaff_args)
import utool
utool.printex(ex, msg, keys=['hesaff_args'])
raise
return hesaff_ptr
开发者ID:Erotemic,项目名称:hesaff,代码行数:25,代码来源:_pyhesaff.py
示例13: _get_qx2_besrank_iterative
def _get_qx2_besrank_iterative(ibs, qreq, nTotalQueries, nPrevQueries, cfglbl=''):
# TODO: INCORPORATE MINIBATCH SIZE TO MATCH_CHIPS3 AND DEPRICATE THIS
print('[harn] querying one query at a time')
# Make progress message
msg = textwrap.dedent('''
---------------------
[harn] TEST %d/%d ''' + cfglbl + '''
---------------------''')
qx2_bestranks = []
qaids = qreq.qaids # Query one ANNOTATION at a time
mark_prog = utool.simple_progres_func(TESTRES_VERBOSITY, msg, '.')
# Query Chip / Row Loop
for qx, qaid in enumerate(qaids):
mark_prog(qx + nPrevQueries, nTotalQueries)
try:
qreq.qaids = [qaid] # hacky
qaid2_qres = mc3.process_query_request(ibs, qreq, safe=False)
except mf.QueryException as ex:
utool.printex(ex, 'Harness caught Query Exception')
qx2_bestranks.append([-1])
if not STRICT:
continue
raise
try:
assert len(qaid2_qres) == 1, ''
except AssertionError as ex:
utool.printex(ex, key_list=['qaid2_qres'])
raise
# record the best rank from this groundtruth
best_rank = qaid2_qres[qaid].get_best_gt_rank(ibs)
qx2_bestranks.append([best_rank])
qreq.qaids = qaids # fix previous hack
return qx2_bestranks
开发者ID:byteyoo,项目名称:ibeis,代码行数:33,代码来源:experiment_harness.py
示例14: cached_wraper
def cached_wraper(*args, **kwargs):
try:
if True:
print('[utool] computing cached function fname_=%s' % (fname_,))
# Implicitly adds use_cache to kwargs
cfgstr = get_cfgstr_from_args(func, args, kwargs, key_argx,
key_kwds, kwdefaults, argnames)
assert cfgstr is not None, 'cfgstr=%r cannot be None' % (cfgstr,)
if kwargs.get('use_cache', use_cache_):
# Make cfgstr from specified input
data = cacher.tryload(cfgstr)
if data is not None:
return data
# Cached missed compute function
data = func(*args, **kwargs)
# Cache save
cacher.save(data, cfgstr)
return data
except Exception as ex:
import utool
_dbgdict2 = dict(key_argx=key_argx, lenargs=len(args), lenkw=len(kwargs),)
msg = '\n'.join([
'+--- UTOOL --- ERROR IN CACHED FUNCTION',
#'dbgdict = ' + utool.dict_str(_dbgdict),
'dbgdict2 = ' + utool.dict_str(_dbgdict2),
])
utool.printex(ex, msg)
raise
开发者ID:animalus,项目名称:utool,代码行数:28,代码来源:util_cache.py
示例15: translated_call
def translated_call(**kwargs):
try:
resp_tup = translate_ibeis_webcall(func, **kwargs)
rawreturn, success, code, message, jQuery_callback = resp_tup
except WebException as webex:
ut.printex(webex)
rawreturn = ''
if DEBUG_PYTHON_STACK_TRACE_JSON_RESPONSE:
rawreturn = str(traceback.format_exc())
success = False
code = webex.code
message = webex.message
jQuery_callback = None
except Exception as ex:
ut.printex(ex)
rawreturn = ''
if DEBUG_PYTHON_STACK_TRACE_JSON_RESPONSE:
rawreturn = str(traceback.format_exc())
success = False
code = 500
message = 'API error, Python Exception thrown: %r' % (str(ex))
if "'int' object is not iterable" in message:
rawreturn = (
'HINT: the input for this call is most likely '
'expected to be a list. Try adding a comma at '
'the end of the input (to cast the conversion '
'into a list) or encapsualte the input with '
'[].')
jQuery_callback = None
webreturn = translate_ibeis_webreturn(rawreturn, success,
code, message,
jQuery_callback)
return flask.make_response(webreturn, code)
开发者ID:heroinlin,项目名称:ibeis,代码行数:33,代码来源:controller_inject.py
示例16: debug_depcache
def debug_depcache(ibs):
r"""
CommandLine:
python -m ibeis_flukematch.plugin --exec-debug_depcache
python -m ibeis_flukematch.plugin --exec-debug_depcache --show --no-cnn
python -m ibeis_flukematch.plugin --exec-debug_depcache --clear-all-depcache --db humbpacks
python -m ibeis_flukematch.plugin --exec-debug_depcache --show --no-cnn --db humpbacks
python -m ibeis_flukematch.plugin --exec-preproc_notch_tips --db humpbacks --no-cnn --show
Example:
>>> # SCRIPT
>>> from ibeis_flukematch.plugin import * # NOQA
>>> ibs = ibeis.opendb(defaultdb='PZ_MTEST')
>>> debug_depcache(ibs)
>>> ut.show_if_requested()
"""
print(ibs.depc)
nas_notch_deps = ibs.depc.get_dependencies('Has_Notch')
print('nas_notch_deps = %r' % (nas_notch_deps,))
te_deps = ibs.depc.get_dependencies('Trailing_Edge')
print('te_deps = %r' % (te_deps,))
notch_tip_deps = ibs.depc.get_dependencies('Notch_Tips')
print('notch_tip_deps = %r' % (notch_tip_deps,))
ibs.depc.print_schemas()
try:
ibs.depc.show_graph()
except Exception as ex:
ut.printex(ex, iswarning=True)
all_aids = ibs.get_valid_aids()
isvalid = ibs.depc.get('Has_Notch', all_aids, 'flag')
aid_list = ut.compress(all_aids, isvalid)
aid_list = aid_list[0:10]
ibs.depc.print_config_tables()
开发者ID:zmjjmz,项目名称:ibeis-flukematch-module,代码行数:35,代码来源:plugin.py
示例17: compute_or_read_annotation_chips
def compute_or_read_annotation_chips(ibs, aid_list, ensure=True):
""" Reads chips and tries to compute them if they do not exist """
#print('[preproc_chip] compute_or_read_chips')
if ensure:
try:
utool.assert_all_not_None(aid_list, 'aid_list')
except AssertionError as ex:
utool.printex(ex, key_list=['aid_list'])
raise
cfpath_list = get_annot_cfpath_list(ibs, aid_list)
try:
if ensure:
chip_list = [gtool.imread(cfpath) for cfpath in cfpath_list]
else:
chip_list = [None if cfpath is None else gtool.imread(cfpath) for cfpath in cfpath_list]
except IOError as ex:
if not utool.QUIET:
utool.printex(ex, '[preproc_chip] Handing Exception: ')
ibs.add_chips(aid_list)
try:
chip_list = [gtool.imread(cfpath) for cfpath in cfpath_list]
except IOError:
print('[preproc_chip] cache must have been deleted from disk')
compute_and_write_chips_lazy(ibs, aid_list)
# Try just one more time
chip_list = [gtool.imread(cfpath) for cfpath in cfpath_list]
return chip_list
开发者ID:byteyoo,项目名称:ibeis,代码行数:28,代码来源:preproc_chip.py
示例18: get_obj
def get_obj(depc, tablename, root_rowids, config=None, ensure=True):
""" Convinience function. Gets data in `tablename` as a list of objects. """
try:
if tablename == depc.root:
obj_list = [depc._root_asobject(rowid) for rowid in root_rowids]
else:
def make_property_getter(rowid, colname):
def wrapper():
return depc.get_property(
tablename, rowid, colnames=colname, config=config,
ensure=ensure)
return wrapper
colnames = depc[tablename].data_colnames
obj_list = [
ut.LazyDict({colname: make_property_getter(rowid, colname)
for colname in colnames})
for rowid in root_rowids
]
return obj_list
# data_list = depc.get_property(tablename, root_rowids, config)
# # TODO: lazy dict
# return [dict(zip(colnames, data)) for data in data_list]
except Exception as ex:
ut.printex(ex, 'error in getobj', keys=['tablename', 'root_rowids', 'colnames'])
raise
开发者ID:Erotemic,项目名称:ibeis,代码行数:25,代码来源:depends_cache.py
示例19: get_annot_texts
def get_annot_texts(ibs, aid_list, **kwargs):
""" Add each type of text_list to the strings list """
try:
ibsfuncs.assert_valid_aids(ibs, aid_list)
assert utool.isiterable(aid_list), 'input must be iterable'
assert all([isinstance(aid, int) for aid in aid_list]), 'invalid input'
except AssertionError as ex:
utool.printex(ex, 'invalid input', 'viz', key_list=['aid_list'])
raise
texts_list = [] # list of lists of texts
if kwargs.get('show_aidstr', True):
aidstr_list = get_aidstrs(aid_list)
texts_list.append(aidstr_list)
if kwargs.get('show_gname', False):
gname_list = ibs.get_annot_gnames(aid_list)
texts_list.append(['gname=%s' % gname for gname in gname_list])
if kwargs.get('show_name', True):
name_list = ibs.get_annot_names(aid_list)
texts_list.append(['name=%s' % name for name in name_list])
if kwargs.get('show_exemplar', True):
flag_list = ibs.get_annot_exemplar_flag(aid_list)
texts_list.append(['EX' if flag else '' for flag in flag_list])
# zip them up to get a tuple for each chip and join the fields
if len(texts_list) > 0:
annotation_text_list = [', '.join(tup) for tup in izip(*texts_list)]
else:
# no texts were specified return empty string for each input
annotation_text_list = [''] * len(aid_list)
return annotation_text_list
开发者ID:byteyoo,项目名称:ibeis,代码行数:29,代码来源:viz_helpers.py
示例20: _image_view
def _image_view(sel_aids=sel_aids, **_kwargs):
try:
viz.show_image(ibs, gid, sel_aids=sel_aids, fnum=self.fnum, **_kwargs)
df2.set_figtitle('Image View')
except TypeError as ex:
ut.printex(ex, ut.dict_str(_kwargs))
raise
开发者ID:Erotemic,项目名称:ibeis,代码行数:7,代码来源:interact_image.py
注:本文中的utool.printex函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论