| OLD | NEW |
| 1 # Copyright 2014 The LUCI Authors. All rights reserved. | 1 # Copyright 2014 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """Generates the swarming_bot.zip archive for the bot. | 5 """Generates the swarming_bot.zip archive for the bot. |
| 6 | 6 |
| 7 Unlike the other source files, this file can be run from ../tools/bot_archive.py | 7 Unlike the other source files, this file can be run from ../tools/bot_archive.py |
| 8 stand-alone to generate a swarming_bot.zip for local testing so it doesn't | 8 stand-alone to generate a swarming_bot.zip for local testing so it doesn't |
| 9 import anything from the AppEngine SDK. | 9 import anything from the AppEngine SDK. |
| 10 | 10 |
| 11 The hash of the content of the files in the archive is used to define the | 11 The hash of the content of the files in the archive is used to define the |
| 12 current version of the swarming bot code. | 12 current version of the swarming bot code. |
| 13 """ | 13 """ |
| 14 | 14 |
| 15 import hashlib | 15 import hashlib |
| 16 import json | 16 import json |
| 17 import logging | 17 import logging |
| 18 import os | 18 import os |
| 19 import StringIO | 19 import StringIO |
| 20 import zipfile | 20 import zipfile |
| 21 | 21 |
| 22 | 22 |
| 23 # List of files needed by the swarming bot. | 23 # List of files needed by the swarming bot. |
| 24 # TODO(maruel): Make the list automatically generated? | 24 # TODO(maruel): Make the list automatically generated? |
| 25 FILES = ( | 25 FILES = ( |
| 26 '__main__.py', | 26 '__main__.py', |
| 27 'adb/__init__.py', |
| 28 'adb/adb_commands.py', |
| 29 'adb/adb_protocol.py', |
| 30 'adb/common.py', |
| 31 'adb/contrib/__init__.py', |
| 32 'adb/contrib/adb_commands_safe.py', |
| 33 'adb/contrib/high.py', |
| 34 'adb/contrib/parallel.py', |
| 35 'adb/fastboot.py', |
| 36 'adb/filesync_protocol.py', |
| 37 'adb/sign_pythonrsa.py', |
| 38 'adb/usb_exceptions.py', |
| 27 'api/__init__.py', | 39 'api/__init__.py', |
| 28 'api/bot.py', | 40 'api/bot.py', |
| 41 'api/os_utilities.py', |
| 29 'api/parallel.py', | 42 'api/parallel.py', |
| 30 'api/os_utilities.py', | |
| 31 'api/platforms/__init__.py', | 43 'api/platforms/__init__.py', |
| 32 'api/platforms/android.py', | 44 'api/platforms/android.py', |
| 33 'api/platforms/common.py', | 45 'api/platforms/common.py', |
| 34 'api/platforms/gce.py', | 46 'api/platforms/gce.py', |
| 35 'api/platforms/gpu.py', | 47 'api/platforms/gpu.py', |
| 36 'api/platforms/linux.py', | 48 'api/platforms/linux.py', |
| 37 'api/platforms/osx.py', | 49 'api/platforms/osx.py', |
| 38 'api/platforms/posix.py', | 50 'api/platforms/posix.py', |
| 39 'api/platforms/win.py', | 51 'api/platforms/win.py', |
| 40 'bot_code/__init__.py', | 52 'bot_code/__init__.py', |
| 41 'bot_code/bot_auth.py', | 53 'bot_code/bot_auth.py', |
| 42 'bot_code/bot_main.py', | 54 'bot_code/bot_main.py', |
| 43 'bot_code/common.py', | 55 'bot_code/common.py', |
| 44 'bot_code/file_reader.py', | 56 'bot_code/file_reader.py', |
| 45 'bot_code/file_refresher.py', | 57 'bot_code/file_refresher.py', |
| 46 'bot_code/remote_client.py', | 58 'bot_code/remote_client.py', |
| 47 'bot_code/remote_client_grpc.py', | 59 'bot_code/remote_client_grpc.py', |
| 48 'bot_code/singleton.py', | 60 'bot_code/singleton.py', |
| 49 'bot_code/task_runner.py', | 61 'bot_code/task_runner.py', |
| 50 'bot_code/workers_pb2.py', | 62 'bot_code/workers_pb2.py', |
| 51 'client/auth.py', | 63 'client/auth.py', |
| 52 'client/cipd.py', | 64 'client/cipd.py', |
| 53 'client/isolated_format.py', | 65 'client/isolated_format.py', |
| 54 'client/isolateserver.py', | 66 'client/isolateserver.py', |
| 55 'client/named_cache.py', | 67 'client/named_cache.py', |
| 56 'client/run_isolated.py', | 68 'client/run_isolated.py', |
| 57 'config/__init__.py', | 69 'config/__init__.py', |
| 70 'infra_libs/__init__.py', |
| 71 'infra_libs/_command_line_linux.py', |
| 72 'infra_libs/_command_line_stub.py', |
| 73 'infra_libs/httplib2_utils.py', |
| 74 'infra_libs/ts_mon/__init__.py', |
| 75 'infra_libs/ts_mon/common/__init__.py', |
| 76 'infra_libs/ts_mon/common/distribution.py', |
| 77 'infra_libs/ts_mon/common/errors.py', |
| 78 'infra_libs/ts_mon/common/helpers.py', |
| 79 'infra_libs/ts_mon/common/http_metrics.py', |
| 80 'infra_libs/ts_mon/common/interface.py', |
| 81 'infra_libs/ts_mon/common/metric_store.py', |
| 82 'infra_libs/ts_mon/common/metrics.py', |
| 83 'infra_libs/ts_mon/common/monitors.py', |
| 84 'infra_libs/ts_mon/common/pb_to_popo.py', |
| 85 'infra_libs/ts_mon/common/standard_metrics.py', |
| 86 'infra_libs/ts_mon/common/targets.py', |
| 87 'infra_libs/ts_mon/config.proto', |
| 88 'infra_libs/ts_mon/config.py', |
| 89 'infra_libs/ts_mon/protos/__init__.py', |
| 90 'infra_libs/ts_mon/protos/current/__init__.py', |
| 91 'infra_libs/ts_mon/protos/current/acquisition_network_device.proto', |
| 92 'infra_libs/ts_mon/protos/current/acquisition_network_device_pb2.py', |
| 93 'infra_libs/ts_mon/protos/current/acquisition_task.proto', |
| 94 'infra_libs/ts_mon/protos/current/acquisition_task_pb2.py', |
| 95 'infra_libs/ts_mon/protos/current/metrics.proto', |
| 96 'infra_libs/ts_mon/protos/current/metrics_pb2.py', |
| 97 'infra_libs/ts_mon/protos/new/__init__.py', |
| 98 'infra_libs/ts_mon/protos/new/acquisition_network_device.proto', |
| 99 'infra_libs/ts_mon/protos/new/acquisition_network_device_pb2.py', |
| 100 'infra_libs/ts_mon/protos/new/acquisition_task.proto', |
| 101 'infra_libs/ts_mon/protos/new/acquisition_task_pb2.py', |
| 102 'infra_libs/ts_mon/protos/new/any.proto', |
| 103 'infra_libs/ts_mon/protos/new/any_pb2.py', |
| 104 'infra_libs/ts_mon/protos/new/metrics.proto', |
| 105 'infra_libs/ts_mon/protos/new/metrics_pb2.py', |
| 106 'infra_libs/ts_mon/protos/new/timestamp.proto', |
| 107 'infra_libs/ts_mon/protos/new/timestamp_pb2.py', |
| 108 'infra_libs/utils.py', |
| 58 'libs/__init__.py', | 109 'libs/__init__.py', |
| 59 'libs/arfile/__init__.py', | 110 'libs/arfile/__init__.py', |
| 60 'libs/arfile/arfile.py', | 111 'libs/arfile/arfile.py', |
| 61 'libs/luci_context/__init__.py', | 112 'libs/luci_context/__init__.py', |
| 62 'libs/luci_context/luci_context.py', | 113 'libs/luci_context/luci_context.py', |
| 114 'python_libusb1/__init__.py', |
| 115 'python_libusb1/libusb1.py', |
| 116 'python_libusb1/usb1.py', |
| 63 'third_party/__init__.py', | 117 'third_party/__init__.py', |
| 64 'third_party/colorama/__init__.py', | 118 'third_party/colorama/__init__.py', |
| 65 'third_party/colorama/ansi.py', | 119 'third_party/colorama/ansi.py', |
| 66 'third_party/colorama/ansitowin32.py', | 120 'third_party/colorama/ansitowin32.py', |
| 67 'third_party/colorama/initialise.py', | 121 'third_party/colorama/initialise.py', |
| 68 'third_party/colorama/win32.py', | 122 'third_party/colorama/win32.py', |
| 69 'third_party/colorama/winterm.py', | 123 'third_party/colorama/winterm.py', |
| 70 'third_party/depot_tools/__init__.py', | 124 'third_party/depot_tools/__init__.py', |
| 71 'third_party/depot_tools/fix_encoding.py', | 125 'third_party/depot_tools/fix_encoding.py', |
| 72 'third_party/depot_tools/subcommand.py', | 126 'third_party/depot_tools/subcommand.py', |
| 127 'third_party/google/__init__.py', |
| 128 'third_party/google/protobuf/__init__.py', |
| 129 'third_party/google/protobuf/descriptor.py', |
| 130 'third_party/google/protobuf/descriptor_database.py', |
| 131 'third_party/google/protobuf/descriptor_pb2.py', |
| 132 'third_party/google/protobuf/descriptor_pool.py', |
| 133 'third_party/google/protobuf/internal/__init__.py', |
| 134 'third_party/google/protobuf/internal/api_implementation.py', |
| 135 'third_party/google/protobuf/internal/containers.py', |
| 136 'third_party/google/protobuf/internal/decoder.py', |
| 137 'third_party/google/protobuf/internal/encoder.py', |
| 138 'third_party/google/protobuf/internal/enum_type_wrapper.py', |
| 139 'third_party/google/protobuf/internal/message_listener.py', |
| 140 'third_party/google/protobuf/internal/python_message.py', |
| 141 'third_party/google/protobuf/internal/type_checkers.py', |
| 142 'third_party/google/protobuf/internal/well_known_types.py', |
| 143 'third_party/google/protobuf/internal/wire_format.py', |
| 144 'third_party/google/protobuf/message.py', |
| 145 'third_party/google/protobuf/message_factory.py', |
| 146 'third_party/google/protobuf/reflection.py', |
| 147 'third_party/google/protobuf/symbol_database.py', |
| 148 'third_party/google/protobuf/text_encoding.py', |
| 149 'third_party/google/protobuf/text_format.py', |
| 150 'third_party/googleapiclient/__init__.py', |
| 151 'third_party/googleapiclient/channel.py', |
| 152 'third_party/googleapiclient/discovery.py', |
| 153 'third_party/googleapiclient/discovery_cache/__init__.py', |
| 154 'third_party/googleapiclient/discovery_cache/appengine_memcache.py', |
| 155 'third_party/googleapiclient/discovery_cache/base.py', |
| 156 'third_party/googleapiclient/discovery_cache/file_cache.py', |
| 157 'third_party/googleapiclient/errors.py', |
| 158 'third_party/googleapiclient/http.py', |
| 159 'third_party/googleapiclient/mimeparse.py', |
| 160 'third_party/googleapiclient/model.py', |
| 161 'third_party/googleapiclient/sample_tools.py', |
| 162 'third_party/googleapiclient/schema.py', |
| 73 'third_party/httplib2/__init__.py', | 163 'third_party/httplib2/__init__.py', |
| 74 'third_party/httplib2/cacerts.txt', | 164 'third_party/httplib2/cacerts.txt', |
| 75 'third_party/httplib2/iri2uri.py', | 165 'third_party/httplib2/iri2uri.py', |
| 76 'third_party/httplib2/socks.py', | 166 'third_party/httplib2/socks.py', |
| 77 'third_party/oauth2client/__init__.py', | 167 'third_party/oauth2client/__init__.py', |
| 78 'third_party/oauth2client/_helpers.py', | 168 'third_party/oauth2client/_helpers.py', |
| 79 'third_party/oauth2client/_openssl_crypt.py', | 169 'third_party/oauth2client/_openssl_crypt.py', |
| 80 'third_party/oauth2client/_pycrypto_crypt.py', | 170 'third_party/oauth2client/_pycrypto_crypt.py', |
| 81 'third_party/oauth2client/client.py', | 171 'third_party/oauth2client/client.py', |
| 82 'third_party/oauth2client/clientsecrets.py', | 172 'third_party/oauth2client/clientsecrets.py', |
| 83 'third_party/oauth2client/crypt.py', | 173 'third_party/oauth2client/crypt.py', |
| 84 'third_party/oauth2client/file.py', | 174 'third_party/oauth2client/file.py', |
| 85 'third_party/oauth2client/gce.py', | 175 'third_party/oauth2client/gce.py', |
| 86 'third_party/oauth2client/keyring_storage.py', | 176 'third_party/oauth2client/keyring_storage.py', |
| 87 'third_party/oauth2client/locked_file.py', | 177 'third_party/oauth2client/locked_file.py', |
| 88 'third_party/oauth2client/multistore_file.py', | 178 'third_party/oauth2client/multistore_file.py', |
| 89 'third_party/oauth2client/service_account.py', | 179 'third_party/oauth2client/service_account.py', |
| 90 'third_party/oauth2client/tools.py', | 180 'third_party/oauth2client/tools.py', |
| 91 'third_party/oauth2client/util.py', | 181 'third_party/oauth2client/util.py', |
| 92 'third_party/oauth2client/xsrfutil.py', | 182 'third_party/oauth2client/xsrfutil.py', |
| 183 'third_party/pyasn1-modules/pyasn1_modules/__init__.py', |
| 184 'third_party/pyasn1-modules/pyasn1_modules/pem.py', |
| 185 'third_party/pyasn1-modules/pyasn1_modules/rfc1155.py', |
| 186 'third_party/pyasn1-modules/pyasn1_modules/rfc1157.py', |
| 187 'third_party/pyasn1-modules/pyasn1_modules/rfc1901.py', |
| 188 'third_party/pyasn1-modules/pyasn1_modules/rfc1902.py', |
| 189 'third_party/pyasn1-modules/pyasn1_modules/rfc1905.py', |
| 190 'third_party/pyasn1-modules/pyasn1_modules/rfc2251.py', |
| 191 'third_party/pyasn1-modules/pyasn1_modules/rfc2314.py', |
| 192 'third_party/pyasn1-modules/pyasn1_modules/rfc2315.py', |
| 193 'third_party/pyasn1-modules/pyasn1_modules/rfc2437.py', |
| 194 'third_party/pyasn1-modules/pyasn1_modules/rfc2459.py', |
| 195 'third_party/pyasn1-modules/pyasn1_modules/rfc2511.py', |
| 196 'third_party/pyasn1-modules/pyasn1_modules/rfc2560.py', |
| 197 'third_party/pyasn1-modules/pyasn1_modules/rfc3412.py', |
| 198 'third_party/pyasn1-modules/pyasn1_modules/rfc3414.py', |
| 199 'third_party/pyasn1-modules/pyasn1_modules/rfc3447.py', |
| 200 'third_party/pyasn1-modules/pyasn1_modules/rfc4210.py', |
| 201 'third_party/pyasn1-modules/pyasn1_modules/rfc5208.py', |
| 93 'third_party/pyasn1/pyasn1/__init__.py', | 202 'third_party/pyasn1/pyasn1/__init__.py', |
| 94 'third_party/pyasn1/pyasn1/codec/__init__.py', | 203 'third_party/pyasn1/pyasn1/codec/__init__.py', |
| 95 'third_party/pyasn1/pyasn1/codec/ber/__init__.py', | 204 'third_party/pyasn1/pyasn1/codec/ber/__init__.py', |
| 96 'third_party/pyasn1/pyasn1/codec/ber/decoder.py', | 205 'third_party/pyasn1/pyasn1/codec/ber/decoder.py', |
| 97 'third_party/pyasn1/pyasn1/codec/ber/encoder.py', | 206 'third_party/pyasn1/pyasn1/codec/ber/encoder.py', |
| 98 'third_party/pyasn1/pyasn1/codec/ber/eoo.py', | 207 'third_party/pyasn1/pyasn1/codec/ber/eoo.py', |
| 99 'third_party/pyasn1/pyasn1/codec/cer/__init__.py', | 208 'third_party/pyasn1/pyasn1/codec/cer/__init__.py', |
| 100 'third_party/pyasn1/pyasn1/codec/cer/decoder.py', | 209 'third_party/pyasn1/pyasn1/codec/cer/decoder.py', |
| 101 'third_party/pyasn1/pyasn1/codec/cer/encoder.py', | 210 'third_party/pyasn1/pyasn1/codec/cer/encoder.py', |
| 102 'third_party/pyasn1/pyasn1/codec/der/__init__.py', | 211 'third_party/pyasn1/pyasn1/codec/der/__init__.py', |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 'third_party/rsa/rsa/key.py', | 282 'third_party/rsa/rsa/key.py', |
| 174 'third_party/rsa/rsa/parallel.py', | 283 'third_party/rsa/rsa/parallel.py', |
| 175 'third_party/rsa/rsa/pem.py', | 284 'third_party/rsa/rsa/pem.py', |
| 176 'third_party/rsa/rsa/pkcs1.py', | 285 'third_party/rsa/rsa/pkcs1.py', |
| 177 'third_party/rsa/rsa/prime.py', | 286 'third_party/rsa/rsa/prime.py', |
| 178 'third_party/rsa/rsa/randnum.py', | 287 'third_party/rsa/rsa/randnum.py', |
| 179 'third_party/rsa/rsa/transform.py', | 288 'third_party/rsa/rsa/transform.py', |
| 180 'third_party/rsa/rsa/util.py', | 289 'third_party/rsa/rsa/util.py', |
| 181 'third_party/rsa/rsa/varblock.py', | 290 'third_party/rsa/rsa/varblock.py', |
| 182 'third_party/six/__init__.py', | 291 'third_party/six/__init__.py', |
| 292 'third_party/uritemplate/__init__.py', |
| 183 'utils/__init__.py', | 293 'utils/__init__.py', |
| 184 'utils/auth_server.py', | 294 'utils/auth_server.py', |
| 185 'utils/authenticators.py', | 295 'utils/authenticators.py', |
| 186 'utils/cacert.pem', | 296 'utils/cacert.pem', |
| 187 'utils/file_path.py', | 297 'utils/file_path.py', |
| 188 'utils/fs.py', | 298 'utils/fs.py', |
| 189 'utils/large.py', | 299 'utils/large.py', |
| 190 'utils/logging_utils.py', | 300 'utils/logging_utils.py', |
| 191 'utils/lru.py', | 301 'utils/lru.py', |
| 192 'utils/net.py', | 302 'utils/net.py', |
| 193 'utils/oauth.py', | 303 'utils/oauth.py', |
| 194 'utils/on_error.py', | 304 'utils/on_error.py', |
| 195 'utils/subprocess42.py', | 305 'utils/subprocess42.py', |
| 196 'utils/threading_utils.py', | 306 'utils/threading_utils.py', |
| 197 'utils/tools.py', | 307 'utils/tools.py', |
| 198 'utils/zip_package.py', | 308 'utils/zip_package.py', |
| 199 'adb/__init__.py', | |
| 200 'adb/adb_commands.py', | |
| 201 'adb/adb_protocol.py', | |
| 202 'adb/common.py', | |
| 203 'adb/contrib/__init__.py', | |
| 204 'adb/contrib/adb_commands_safe.py', | |
| 205 'adb/contrib/high.py', | |
| 206 'adb/contrib/parallel.py', | |
| 207 'adb/fastboot.py', | |
| 208 'adb/filesync_protocol.py', | |
| 209 'adb/sign_pythonrsa.py', | |
| 210 'adb/usb_exceptions.py', | |
| 211 'python_libusb1/__init__.py', | |
| 212 'python_libusb1/libusb1.py', | |
| 213 'python_libusb1/usb1.py', | |
| 214 ) | 309 ) |
| 215 | 310 |
| 216 | 311 |
| 217 def is_windows(): | 312 def is_windows(): |
| 218 """Returns True if this code is running under Windows.""" | 313 """Returns True if this code is running under Windows.""" |
| 219 return os.__file__[0] != '/' | 314 return os.__file__[0] != '/' |
| 220 | 315 |
| 221 | 316 |
| 222 def resolve_symlink(path): | 317 def resolve_symlink(path): |
| 223 """Processes path containing symlink on Windows. | 318 """Processes path containing symlink on Windows. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 h.update(str(len(name))) | 405 h.update(str(len(name))) |
| 311 h.update(name) | 406 h.update(name) |
| 312 h.update(str(len(content))) | 407 h.update(str(len(content))) |
| 313 h.update(content) | 408 h.update(content) |
| 314 except IOError: | 409 except IOError: |
| 315 logging.warning('Missing expected file. Hash will be invalid.') | 410 logging.warning('Missing expected file. Hash will be invalid.') |
| 316 bot_version = h.hexdigest() | 411 bot_version = h.hexdigest() |
| 317 logging.info( | 412 logging.info( |
| 318 'get_swarming_bot_version(%s) = %s', sorted(additionals), bot_version) | 413 'get_swarming_bot_version(%s) = %s', sorted(additionals), bot_version) |
| 319 return bot_version | 414 return bot_version |
| OLD | NEW |