| OLD | NEW | 
|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python | 
| 2 # Copyright 2010 The Native Client Authors.  All rights reserved. | 2 # Copyright 2010 The Native Client Authors.  All rights reserved. | 
| 3 # Use of this source code is governed by a BSD-style license that can | 3 # Use of this source code is governed by a BSD-style license that can | 
| 4 # be found in the LICENSE file. | 4 # be found in the LICENSE file. | 
| 5 | 5 | 
| 6 """A library to assist automatically downloading files. | 6 """A library to assist automatically downloading files. | 
| 7 | 7 | 
| 8 This library is used by scripts that download tarballs, zipfiles, etc. as part | 8 This library is used by scripts that download tarballs, zipfiles, etc. as part | 
| 9 of the build process. | 9 of the build process. | 
| 10 """ | 10 """ | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 23 PLATFORM_COLLAPSE = { | 23 PLATFORM_COLLAPSE = { | 
| 24     'windows': 'windows', | 24     'windows': 'windows', | 
| 25     'win32': 'windows', | 25     'win32': 'windows', | 
| 26     'cygwin': 'windows', | 26     'cygwin': 'windows', | 
| 27     'linux': 'linux', | 27     'linux': 'linux', | 
| 28     'linux2': 'linux', | 28     'linux2': 'linux', | 
| 29     'darwin': 'mac', | 29     'darwin': 'mac', | 
| 30     'mac': 'mac', | 30     'mac': 'mac', | 
| 31 } | 31 } | 
| 32 | 32 | 
|  | 33 ARCH_COLLAPSE = { | 
|  | 34     'i386'  : 'x86-32', | 
|  | 35     'i686'  : 'x86-32', | 
|  | 36     'x86_64': 'x86-64', | 
|  | 37 } | 
|  | 38 | 
| 33 | 39 | 
| 34 def PlatformName(name=None): | 40 def PlatformName(name=None): | 
| 35   if name is None: | 41   if name is None: | 
| 36     name = sys.platform | 42     name = sys.platform | 
| 37   return PLATFORM_COLLAPSE[name] | 43   return PLATFORM_COLLAPSE[name] | 
| 38 | 44 | 
|  | 45 def ArchName(name=None): | 
|  | 46   if name is None: | 
|  | 47     if PlatformName() == 'windows': | 
|  | 48       # TODO(pdox): Figure out how to auto-detect 32-bit vs 64-bit Windows. | 
|  | 49       name = 'i386' | 
|  | 50     else: | 
|  | 51       import platform | 
|  | 52       name = platform.machine() | 
|  | 53   return ARCH_COLLAPSE[name] | 
| 39 | 54 | 
| 40 def EnsureFileCanBeWritten(filename): | 55 def EnsureFileCanBeWritten(filename): | 
| 41   directory = os.path.dirname(filename) | 56   directory = os.path.dirname(filename) | 
| 42   if not os.path.exists(directory): | 57   if not os.path.exists(directory): | 
| 43     os.makedirs(directory) | 58     os.makedirs(directory) | 
| 44 | 59 | 
| 45 | 60 | 
| 46 def WriteData(filename, data): | 61 def WriteData(filename, data): | 
| 47   EnsureFileCanBeWritten(filename) | 62   EnsureFileCanBeWritten(filename) | 
| 48   f = open(filename, 'wb') | 63   f = open(filename, 'wb') | 
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 118   Retry(shutil.move, src, dst) | 133   Retry(shutil.move, src, dst) | 
| 119 | 134 | 
| 120 | 135 | 
| 121 def RemoveDir(path): | 136 def RemoveDir(path): | 
| 122   if os.path.exists(path): | 137   if os.path.exists(path): | 
| 123     Retry(shutil.rmtree, path) | 138     Retry(shutil.rmtree, path) | 
| 124 | 139 | 
| 125 | 140 | 
| 126 def RemoveFile(path): | 141 def RemoveFile(path): | 
| 127   if os.path.exists(path): | 142   if os.path.exists(path): | 
| 128     Retry(os.unlink, path) | 143     Retry(os.unlink, path) | 
| OLD | NEW | 
|---|