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

Unified Diff: native_client_sdk/src/examples/httpd.py

Issue 10868089: add PRESUBMIT for native_client_sdk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 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
Index: native_client_sdk/src/examples/httpd.py
diff --git a/native_client_sdk/src/examples/httpd.py b/native_client_sdk/src/examples/httpd.py
index e715f5bed22b601ef603a1fba5872b43f27e6b54..a130ed105cbc21ec47690704afa2971aa9365c03 100755
--- a/native_client_sdk/src/examples/httpd.py
+++ b/native_client_sdk/src/examples/httpd.py
@@ -19,16 +19,17 @@ import sys
import urlparse
-EXAMPLE_PATH=os.path.dirname(os.path.abspath(__file__))
+EXAMPLE_PATH = os.path.dirname(os.path.abspath(__file__))
NACL_SDK_ROOT = os.getenv('NACL_SDK_ROOT', os.path.dirname(EXAMPLE_PATH))
if os.path.exists(NACL_SDK_ROOT):
sys.path.append(os.path.join(NACL_SDK_ROOT, 'tools'))
+ # pylint: disable=F0401
import decode_dump
import getos
else:
- NACL_SDK_ROOT=None
+ NACL_SDK_ROOT = None
last_nexe = None
last_nmf = None
@@ -63,6 +64,8 @@ def SanityCheckDirectory():
# faster responses.
class QuittableHTTPServer(SocketServer.ThreadingMixIn,
BaseHTTPServer.HTTPServer):
+ is_running = False
+
def serve_forever(self, timeout=0.5):
self.is_running = True
self.timeout = timeout
@@ -77,13 +80,13 @@ class QuittableHTTPServer(SocketServer.ThreadingMixIn,
# "Safely" split a string at |sep| into a [key, value] pair. If |sep| does not
-# exist in |str|, then the entire |str| is the key and the value is set to an
+# exist in |pair|, then the entire |pair| is the key and the value is set to an
# empty string.
-def KeyValuePair(str, sep='='):
- if sep in str:
- return str.split(sep)
+def KeyValuePair(pair, sep='='):
+ if sep in pair:
+ return pair.split(sep)
else:
- return [str, '']
+ return [pair, '']
# A small handler that looks for '?quit=1' query in the path and shuts itself
@@ -103,28 +106,28 @@ class QuittableHTTPHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
path = self.translate_path(self.path)
f = None
if os.path.isdir(path):
- if not self.path.endswith('/'):
- # redirect browser - doing basically what apache does
- self.send_response(301)
- self.send_header("Location", self.path + "/")
- self.end_headers()
- return None
- for index in "index.html", "index.htm":
- index = os.path.join(path, index)
- if os.path.exists(index):
- path = index
- break
- else:
- return self.list_directory(path)
+ if not self.path.endswith('/'):
+ # redirect browser - doing basically what apache does
+ self.send_response(301)
+ self.send_header("Location", self.path + "/")
+ self.end_headers()
+ return None
+ for index in "index.html", "index.htm":
+ index = os.path.join(path, index)
+ if os.path.exists(index):
+ path = index
+ break
+ else:
+ return self.list_directory(path)
ctype = self.guess_type(path)
try:
- # Always read in binary mode. Opening files in text mode may cause
- # newline translations, making the actual size of the content
- # transmitted *less* than the content-length!
- f = open(path, 'rb')
+ # Always read in binary mode. Opening files in text mode may cause
+ # newline translations, making the actual size of the content
+ # transmitted *less* than the content-length!
+ f = open(path, 'rb')
except IOError:
- self.send_error(404, "File not found")
- return None
+ self.send_error(404, "File not found")
+ return None
self.send_response(200)
self.send_header("Content-type", ctype)
fs = os.fstat(f.fileno())
@@ -156,7 +159,6 @@ class QuittableHTTPHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
def do_POST(self):
- (_, _,path, query, _) = urlparse.urlsplit(self.path)
if 'Content-Length' in self.headers:
if not NACL_SDK_ROOT:
self.wfile('Could not find NACL_SDK_ROOT to decode trace.')
« no previous file with comments | « native_client_sdk/src/build_tools/update_nacl_manifest.py ('k') | native_client_sdk/src/tools/create_nmf.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698