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

Unified Diff: build/android/devil/android/ports.py

Issue 1314313004: [Android][telemetry] Update pylib imports for modules that moved into devil. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 | « build/android/buildbot/bb_device_steps.py ('k') | build/android/devil/utils/reraiser_thread_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/devil/android/ports.py
diff --git a/build/android/pylib/ports.py b/build/android/devil/android/ports.py
similarity index 88%
rename from build/android/pylib/ports.py
rename to build/android/devil/android/ports.py
index fa0345b6b96efb01d40fe58ea7f355e514e091a6..49ee4e34e376c3471632ceb35bf6ce013feedaf2 100644
--- a/build/android/pylib/ports.py
+++ b/build/android/devil/android/ports.py
@@ -12,7 +12,12 @@ import os
import socket
import traceback
-from pylib import constants
+# The net test server is started from port 10201.
+_TEST_SERVER_PORT_FIRST = 10201
+_TEST_SERVER_PORT_LAST = 30000
+# A file to record next valid port of test server.
+_TEST_SERVER_PORT_FILE = '/tmp/test_server_port'
+_TEST_SERVER_PORT_LOCKFILE = '/tmp/test_server_port.lock'
# The following two methods are used to allocate the port source for various
@@ -27,10 +32,10 @@ def ResetTestServerPortAllocation():
Returns True if reset successes. Otherwise returns False.
"""
try:
- with open(constants.TEST_SERVER_PORT_FILE, 'w') as fp:
- fp.write('%d' % constants.TEST_SERVER_PORT_FIRST)
- if os.path.exists(constants.TEST_SERVER_PORT_LOCKFILE):
- os.unlink(constants.TEST_SERVER_PORT_LOCKFILE)
+ with open(_TEST_SERVER_PORT_FILE, 'w') as fp:
+ fp.write('%d' % _TEST_SERVER_PORT_FIRST)
+ if os.path.exists(_TEST_SERVER_PORT_LOCKFILE):
+ os.unlink(_TEST_SERVER_PORT_LOCKFILE)
return True
except Exception as e:
logging.error(e)
@@ -47,19 +52,19 @@ def AllocateTestServerPort():
port = 0
ports_tried = []
try:
- fp_lock = open(constants.TEST_SERVER_PORT_LOCKFILE, 'w')
+ fp_lock = open(_TEST_SERVER_PORT_LOCKFILE, 'w')
fcntl.flock(fp_lock, fcntl.LOCK_EX)
# Get current valid port and calculate next valid port.
- if not os.path.exists(constants.TEST_SERVER_PORT_FILE):
+ if not os.path.exists(_TEST_SERVER_PORT_FILE):
ResetTestServerPortAllocation()
- with open(constants.TEST_SERVER_PORT_FILE, 'r+') as fp:
+ with open(_TEST_SERVER_PORT_FILE, 'r+') as fp:
port = int(fp.read())
ports_tried.append(port)
while not IsHostPortAvailable(port):
port += 1
ports_tried.append(port)
- if (port > constants.TEST_SERVER_PORT_LAST or
- port < constants.TEST_SERVER_PORT_FIRST):
+ if (port > _TEST_SERVER_PORT_LAST or
+ port < _TEST_SERVER_PORT_FIRST):
port = 0
else:
fp.seek(0, os.SEEK_SET)
« no previous file with comments | « build/android/buildbot/bb_device_steps.py ('k') | build/android/devil/utils/reraiser_thread_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698