Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _exportSortedStats(sortby):
assert not yappi.is_running()
filename = 'ilastik_profile_sortedby_{}.txt'.format(sortby)
recentPath = PreferencesManager().get('shell', 'recent sorted profile stats')
if recentPath is None:
defaultPath = os.path.join(os.path.expanduser('~'), filename)
else:
defaultPath = os.path.join(os.path.split(recentPath)[0], filename)
stats_path, _filter = QFileDialog.getSaveFileName(
self, "Export sorted stats text", defaultPath, "Text files (*.txt)",
options=QFileDialog.Options(QFileDialog.DontUseNativeDialog))
if stats_path:
pstats_path = os.path.splitext(stats_path)[0] + '.pstats'
PreferencesManager().set('shell', 'recent sorted profile stats', stats_path)
# Export the yappi stats to builtin pstats format,
def _exportSortedThreadStats(sortby):
assert not yappi.is_running()
filename = 'ilastik_threadstats_sortedby_{}.txt'.format(sortby)
recentPath = PreferencesManager().get('shell', 'recent sorted profile stats')
if recentPath is None:
defaultPath = os.path.join(os.path.expanduser('~'), filename)
else:
defaultPath = os.path.join(os.path.split(recentPath)[0], filename)
stats_path, _filter = QFileDialog.getSaveFileName(
self, "Export sorted stats text", defaultPath, "Text files (*.txt)",
options=QFileDialog.Options(QFileDialog.DontUseNativeDialog))
if stats_path:
PreferencesManager().set('shell', 'recent sorted profile stats', stats_path)
# Export the yappi stats to builtin pstats format,
def _exportSortedStats(sortby):
assert not yappi.is_running()
filename = "ilastik_profile_sortedby_{}.txt".format(sortby)
recentPath = preferences.get("shell", "recent sorted profile stats")
if recentPath is None:
defaultPath = os.path.join(os.path.expanduser("~"), filename)
else:
defaultPath = os.path.join(os.path.split(recentPath)[0], filename)
stats_path, _filter = QFileDialog.getSaveFileName(
self,
"Export sorted stats text",
defaultPath,
"Text files (*.txt)",
options=QFileDialog.Options(QFileDialog.DontUseNativeDialog),
)
if stats_path:
def _updateMenuStatus():
startAction.setEnabled(not yappi.is_running())
stopAction.setEnabled(yappi.is_running())
for action in sortedExportSubmenu.actions():
action.setEnabled(not yappi.is_running() and not yappi.get_func_stats().empty())
for action in sortedThreadExportSubmenu.actions():
action.setEnabled(not yappi.is_running() and not yappi.get_func_stats().empty())
def _handle_sigusr2(sig, stack):
'''
Signal handler for SIGUSR2, only available on Unix-like systems
'''
try:
import yappi
except ImportError:
return
if yappi.is_running():
yappi.stop()
filename = 'callgrind.salt-{0}-{1}'.format(int(time.time()), os.getpid())
destfile = os.path.join(tempfile.gettempdir(), filename)
yappi.get_func_stats().save(destfile, type='CALLGRIND')
if sys.stderr.isatty():
sys.stderr.write('Saved profiling data to: {0}\n'.format(destfile))
yappi.clear_stats()
else:
if sys.stderr.isatty():
sys.stderr.write('Profiling started\n')
yappi.start()
def _updateMenuStatus():
startAction.setEnabled(not yappi.is_running())
stopAction.setEnabled(yappi.is_running())
for action in sortedExportSubmenu.actions():
action.setEnabled(not yappi.is_running() and not yappi.get_func_stats().empty())
for action in sortedThreadExportSubmenu.actions():
action.setEnabled(not yappi.is_running() and not yappi.get_func_stats().empty())
def injection_load(**kwargs):
import threading
try:
import yappi
if not yappi.is_running():
yappi.start()
except:
pass
def _updateMenuStatus():
startAction.setEnabled(not yappi.is_running())
stopAction.setEnabled(yappi.is_running())
for action in sortedExportSubmenu.actions():
action.setEnabled(not yappi.is_running() and not yappi.get_func_stats().empty())
for action in sortedThreadExportSubmenu.actions():
action.setEnabled(not yappi.is_running() and not yappi.get_func_stats().empty())