| Index: mojo/public/tools/download_network_service.py
 | 
| diff --git a/mojo/services/network/download_network_service.py b/mojo/public/tools/download_network_service.py
 | 
| similarity index 71%
 | 
| rename from mojo/services/network/download_network_service.py
 | 
| rename to mojo/public/tools/download_network_service.py
 | 
| index d2472f4a8264474af66d5182bf59ef05d866fc64..82951514a751f4c05a90b025007584c878302634 100755
 | 
| --- a/mojo/services/network/download_network_service.py
 | 
| +++ b/mojo/public/tools/download_network_service.py
 | 
| @@ -18,16 +18,38 @@ if not sys.platform.startswith("linux"):
 | 
|  
 | 
|  # Add //tools to the system path so that we can import the gs helper.
 | 
|  script_dir = os.path.dirname(os.path.realpath(__file__))
 | 
| +
 | 
| +# TODO(blundell): Determine whether to move gs.py into the SDK or to inline the
 | 
| +# contents of that function in this file as is done in download_shell_binary.py.
 | 
|  tools_path = os.path.join(script_dir, os.pardir, os.pardir, os.pardir, "tools")
 | 
|  sys.path.insert(0, tools_path)
 | 
|  # pylint: disable=F0401
 | 
|  import gs
 | 
|  
 | 
|  
 | 
| -def download_app(app, version, platform, prebuilt_directory):
 | 
| +def download_app(app, version):
 | 
| +  prebuilt_directory = os.path.join(script_dir, "prebuilt/%s" % app)
 | 
| +  stamp_path = os.path.join(prebuilt_directory, "VERSION")
 | 
| +
 | 
| +  try:
 | 
| +    with open(stamp_path) as stamp_file:
 | 
| +      current_version = stamp_file.read().strip()
 | 
| +      if current_version == version:
 | 
| +        return  # Already have the right version.
 | 
| +  except IOError:
 | 
| +    pass  # If the stamp file does not exist we need to download a new binary.
 | 
| +
 | 
| +  for platform in _PLATFORMS:
 | 
| +    download_app_for_platform(app, version, platform)
 | 
| +
 | 
| +  with open(stamp_path, 'w') as stamp_file:
 | 
| +    stamp_file.write(version)
 | 
| +
 | 
| +def download_app_for_platform(app, version, platform):
 | 
|    binary_name = app + ".mojo"
 | 
|    gs_path = "gs://mojo/%s/%s/%s/%s.zip" % (app, version, platform, binary_name)
 | 
| -  output_directory = os.path.join(prebuilt_directory, platform)
 | 
| +  output_directory = os.path.join(script_dir,
 | 
| +                                  "prebuilt/%s/%s" % (app, platform))
 | 
|  
 | 
|    with tempfile.NamedTemporaryFile() as temp_zip_file:
 | 
|      gs.download_from_public_bucket(gs_path, temp_zip_file.name)
 | 
| @@ -37,33 +59,19 @@ def download_app(app, version, platform, prebuilt_directory):
 | 
|        z.extract(zi, output_directory)
 | 
|        os.chmod(os.path.join(output_directory, binary_name), mode)
 | 
|  
 | 
| -
 | 
|  def main():
 | 
|    parser = argparse.ArgumentParser(
 | 
|        description="Download prebuilt network service binaries from google " +
 | 
|                    "storage")
 | 
|    parser.parse_args()
 | 
|  
 | 
| -  prebuilt_directory_path = os.path.join(script_dir, "prebuilt")
 | 
| -  stamp_path = os.path.join(prebuilt_directory_path, "STAMP")
 | 
| -  version_path = os.path.join(script_dir, "VERSION")
 | 
| +  version_path = os.path.join(script_dir, "NETWORK_SERVICE_VERSION")
 | 
|    with open(version_path) as version_file:
 | 
|      version = version_file.read().strip()
 | 
|  
 | 
| -  try:
 | 
| -    with open(stamp_path) as stamp_file:
 | 
| -      current_version = stamp_file.read().strip()
 | 
| -      if current_version == version:
 | 
| -        return 0  # Already have the right version.
 | 
| -  except IOError:
 | 
| -    pass  # If the stamp file does not exist we need to download a new binary.
 | 
| -
 | 
| -  for platform in _PLATFORMS:
 | 
| -    for app in _APPS:
 | 
| -      download_app(app, version, platform, prebuilt_directory_path)
 | 
| +  for app in _APPS:
 | 
| +    download_app(app, version)
 | 
|  
 | 
| -  with open(stamp_path, 'w') as stamp_file:
 | 
| -    stamp_file.write(version)
 | 
|    return 0
 | 
|  
 | 
|  
 | 
| 
 |