Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: check_curl.py

Issue 10252013: Implemented curl support for web requests (Closed)
Left Patch Set: Unbitrotted the patch Created April 11, 2013, 4:33 p.m.
Right Patch Set: Addressed review comments Created April 12, 2013, 1:37 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | include/AdblockPlus/WebRequest.h » ('j') | include/AdblockPlus/WebRequest.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding: utf-8 2 # coding: utf-8
3 3
4 import os, sys, subprocess, tempfile; 4 import os, sys, subprocess, tempfile;
5 baseDir = os.path.abspath(os.path.dirname(__file__)) 5 baseDir = os.path.abspath(os.path.dirname(__file__))
6 6
7 def check_curl(): 7 def check_curl():
8 (fd, name) = tempfile.mkstemp(dir=os.path.join(baseDir, 'build'), suffix='.h') 8 buildDir = os.path.join(baseDir, 'build')
Felix Dahlke 2013/04/12 03:53:50 This won't work for a fresh clone, as the build di
9 if not os.path.exists(buildDir):
10 os.makedirs(buildDir);
11 (fd, name) = tempfile.mkstemp(dir=buildDir, suffix='.h')
9 try: 12 try:
10 handle = os.fdopen(fd, 'wb'); 13 handle = os.fdopen(fd, 'wb');
11 handle.write('#include <curl/curl.h>') 14 handle.write('#include <curl/curl.h>')
12 handle.close(); 15 handle.close();
13 16
14 # This command won't work for Windows or Android build environments but we 17 # This command won't work for Windows or Android build environments but we
15 # don't want to use curl there anyway 18 # don't want to use curl there anyway
16 command = ['/usr/bin/env', 'gcc', '-E', name]; 19 command = ['/usr/bin/env', 'gcc', '-E', name];
17 process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subproces s.PIPE) 20 process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subproces s.PIPE)
18 process.communicate() 21 process.communicate()
19 22
20 if process.returncode: 23 if process.returncode:
21 # call failed, curl not available 24 # call failed, curl not available
22 sys.stdout.write('0') 25 sys.stdout.write('0')
23 else: 26 else:
24 # call succeeded, curl can be used 27 # call succeeded, curl can be used
25 sys.stdout.write('1') 28 sys.stdout.write('1')
26 finally: 29 finally:
27 os.remove(name) 30 os.remove(name)
28 31
29 if __name__ == '__main__': 32 if __name__ == '__main__':
30 check_curl() 33 check_curl()
LEFTRIGHT

Powered by Google App Engine
This is Rietveld