Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Unified Diff: tools/telemetry/telemetry/util/global_hooks.py

Issue 489693002: [telemetry] Move stale .pyc check from Python import to gclient hook. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase! Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/remove_stale_pyc_files.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/util/global_hooks.py
diff --git a/tools/telemetry/telemetry/util/global_hooks.py b/tools/telemetry/telemetry/util/global_hooks.py
index c7d559922cfdf5d4c9be15f97fc45c4937fa06b6..4ca3aaf801e5da0a6396d2a0a86b2d8fe77a94fb 100644
--- a/tools/telemetry/telemetry/util/global_hooks.py
+++ b/tools/telemetry/telemetry/util/global_hooks.py
@@ -4,49 +4,18 @@
"""Hooks that apply globally to all scripts that import or use Telemetry."""
-import os
import signal
import sys
-from telemetry.core import util
from telemetry.util import exception_formatter
def InstallHooks():
- RemoveAllStalePycFiles(util.GetTelemetryDir())
- RemoveAllStalePycFiles(util.GetBaseDir())
InstallUnhandledExceptionFormatter()
InstallStackDumpOnSigusr1()
InstallTerminationHook()
-def RemoveAllStalePycFiles(base_dir):
- """Scan directories for old .pyc files without a .py file and delete them."""
- for dirname, _, filenames in os.walk(base_dir):
- if '.svn' in dirname or '.git' in dirname:
- continue
- for filename in filenames:
- root, ext = os.path.splitext(filename)
- if ext != '.pyc':
- continue
-
- pyc_path = os.path.join(dirname, filename)
- py_path = os.path.join(dirname, root + '.py')
-
- try:
- if not os.path.exists(py_path):
- os.remove(pyc_path)
- except OSError:
- # Wrap OS calls in try/except in case another process touched this file.
- pass
-
- try:
- os.removedirs(dirname)
- except OSError:
- # Wrap OS calls in try/except in case another process touched this dir.
- pass
-
-
def InstallUnhandledExceptionFormatter():
"""Print prettier exceptions that also contain the stack frame's locals."""
sys.excepthook = exception_formatter.PrintFormattedException
« no previous file with comments | « tools/remove_stale_pyc_files.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698