This adds a function similar to the shell 'which' command to detect
if curl is available, rather than assuming curl is available on
a posix system. Cleaner.
... | ... |
@@ -28,13 +28,28 @@ exclude_tests = [] |
28 | 28 |
|
29 | 29 |
verbose = False |
30 | 30 |
|
31 |
-if os.name == "posix": |
|
31 |
+# https://stackoverflow.com/questions/377017/test-if-executable-exists-in-python/377028#377028 |
|
32 |
+def which(program): |
|
33 |
+ def is_exe(fpath): |
|
34 |
+ return os.path.isfile(fpath) and os.access(fpath, os.X_OK) |
|
35 |
+ |
|
36 |
+ fpath, fname = os.path.split(program) |
|
37 |
+ if fpath: |
|
38 |
+ if is_exe(program): |
|
39 |
+ return program |
|
40 |
+ else: |
|
41 |
+ for path in os.environ["PATH"].split(os.pathsep): |
|
42 |
+ path = path.strip('"') |
|
43 |
+ exe_file = os.path.join(path, program) |
|
44 |
+ if is_exe(exe_file): |
|
45 |
+ return exe_file |
|
46 |
+ |
|
47 |
+ return None |
|
48 |
+ |
|
49 |
+if which('curl') is not None: |
|
32 | 50 |
have_curl = True |
33 |
-elif os.name == "nt": |
|
34 |
- have_curl = False |
|
35 | 51 |
else: |
36 |
- print "Unknown platform: %s" % os.name |
|
37 |
- sys.exit(1) |
|
52 |
+ have_curl = False |
|
38 | 53 |
|
39 | 54 |
config_file = None |
40 | 55 |
if os.getenv("HOME"): |