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

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

Issue 12278015: [Telemetry] Reorganize everything. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-add shebangs. Created 7 years, 10 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/telemetry/telemetry/user_agent_unittest.py ('k') | tools/telemetry/telemetry/util_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/util.py
diff --git a/tools/telemetry/telemetry/util.py b/tools/telemetry/telemetry/util.py
deleted file mode 100644
index db93bcf79cb22d8c54be83016febb60dae8fd84d..0000000000000000000000000000000000000000
--- a/tools/telemetry/telemetry/util.py
+++ /dev/null
@@ -1,68 +0,0 @@
-# Copyright (c) 2012 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-import inspect
-import socket
-import time
-
-class TimeoutException(Exception):
- pass
-
-def WaitFor(condition,
- timeout, poll_interval=0.1,
- pass_time_left_to_func=False):
- assert isinstance(condition, type(lambda: None)) # is function
- start_time = time.time()
- while True:
- if pass_time_left_to_func:
- res = condition(max((start_time + timeout) - time.time(), 0.0))
- else:
- res = condition()
- if res:
- break
- if time.time() - start_time > timeout:
- if condition.__name__ == '<lambda>':
- try:
- condition_string = inspect.getsource(condition).strip()
- except IOError:
- condition_string = condition.__name__
- else:
- condition_string = condition.__name__
- raise TimeoutException('Timed out while waiting %ds for %s.' %
- (timeout, condition_string))
- time.sleep(poll_interval)
-
-def FindElementAndPerformAction(tab, text, callback_code):
- """JavaScript snippet for finding an element with a given text on a page."""
- code = """
- (function() {
- var callback_function = """ + callback_code + """;
- function _findElement(element, text) {
- if (element.innerHTML == text) {
- callback_function
- return element;
- }
- for (var i in element.childNodes) {
- var found = _findElement(element.childNodes[i], text);
- if (found)
- return found;
- }
- return null;
- }
- var _element = _findElement(document, \"""" + text + """\");
- return callback_function(_element);
- })();"""
- return tab.EvaluateJavaScript(code)
-
-class PortPair(object):
- def __init__(self, local_port, remote_port):
- self.local_port = local_port
- self.remote_port = remote_port
-
-def GetAvailableLocalPort():
- tmp = socket.socket()
- tmp.bind(('', 0))
- port = tmp.getsockname()[1]
- tmp.close()
-
- return port
« no previous file with comments | « tools/telemetry/telemetry/user_agent_unittest.py ('k') | tools/telemetry/telemetry/util_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698