| OLD | NEW |
| 1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
| 2 # Copyright 2011 Google Inc. All Rights Reserved. | 2 # Copyright 2011 Google Inc. All Rights Reserved. |
| 3 # | 3 # |
| 4 # Licensed under the Apache License, Version 2.0 (the "License"); | 4 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 # you may not use this file except in compliance with the License. | 5 # you may not use this file except in compliance with the License. |
| 6 # You may obtain a copy of the License at | 6 # You may obtain a copy of the License at |
| 7 # | 7 # |
| 8 # http://www.apache.org/licenses/LICENSE-2.0 | 8 # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 # | 9 # |
| 10 # Unless required by applicable law or agreed to in writing, software | 10 # Unless required by applicable law or agreed to in writing, software |
| 11 # distributed under the License is distributed on an "AS IS" BASIS, | 11 # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 # See the License for the specific language governing permissions and | 13 # See the License for the specific language governing permissions and |
| 14 # limitations under the License. | 14 # limitations under the License. |
| 15 """Implementation of gsutil version command.""" | 15 """Implementation of gsutil version command.""" |
| 16 | 16 |
| 17 from __future__ import absolute_import | 17 from __future__ import absolute_import |
| 18 | 18 |
| 19 from hashlib import md5 | 19 from hashlib import md5 |
| 20 import os | 20 import os |
| 21 import platform | 21 import platform |
| 22 import re | 22 import re |
| 23 import sys | 23 import sys |
| 24 | 24 |
| 25 import boto | 25 import boto |
| 26 import crcmod | 26 import crcmod |
| 27 import gslib | 27 import gslib |
| 28 from gslib.command import Command | 28 from gslib.command import Command |
| 29 from gslib.util import CheckMultiprocessingAvailableAndInit |
| 29 from gslib.util import GetConfigFilePath | 30 from gslib.util import GetConfigFilePath |
| 30 from gslib.util import MultiprocessingIsAvailable | |
| 31 from gslib.util import UsingCrcmodExtension | 31 from gslib.util import UsingCrcmodExtension |
| 32 | 32 |
| 33 | 33 |
| 34 _SYNOPSIS = """ | 34 _SYNOPSIS = """ |
| 35 gsutil version | 35 gsutil version |
| 36 """ | 36 """ |
| 37 | 37 |
| 38 _DETAILED_HELP_TEXT = (""" | 38 _DETAILED_HELP_TEXT = (""" |
| 39 <B>SYNOPSIS</B> | 39 <B>SYNOPSIS</B> |
| 40 """ + _SYNOPSIS + """ | 40 """ + _SYNOPSIS + """ |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 'installed via package manager: {is_package_install}\n' | 113 'installed via package manager: {is_package_install}\n' |
| 114 'editable install: {is_editable_install}\n' | 114 'editable install: {is_editable_install}\n' |
| 115 ) | 115 ) |
| 116 | 116 |
| 117 sys.stdout.write(long_form_output.format( | 117 sys.stdout.write(long_form_output.format( |
| 118 checksum=cur_checksum, | 118 checksum=cur_checksum, |
| 119 checksum_ok=checksum_ok_str, | 119 checksum_ok=checksum_ok_str, |
| 120 boto_version=boto.__version__, | 120 boto_version=boto.__version__, |
| 121 python_version=sys.version.replace('\n', ''), | 121 python_version=sys.version.replace('\n', ''), |
| 122 os_version='%s %s' % (platform.system(), platform.release()), | 122 os_version='%s %s' % (platform.system(), platform.release()), |
| 123 multiprocessing_available=MultiprocessingIsAvailable()[0], | 123 multiprocessing_available=( |
| 124 CheckMultiprocessingAvailableAndInit().is_available), |
| 124 cloud_sdk=(os.environ.get('CLOUDSDK_WRAPPER') == '1'), | 125 cloud_sdk=(os.environ.get('CLOUDSDK_WRAPPER') == '1'), |
| 125 config_path=config_path, | 126 config_path=config_path, |
| 126 gsutil_path=gslib.GSUTIL_PATH, | 127 gsutil_path=gslib.GSUTIL_PATH, |
| 127 compiled_crcmod=UsingCrcmodExtension(crcmod), | 128 compiled_crcmod=UsingCrcmodExtension(crcmod), |
| 128 is_package_install=gslib.IS_PACKAGE_INSTALL, | 129 is_package_install=gslib.IS_PACKAGE_INSTALL, |
| 129 is_editable_install=gslib.IS_EDITABLE_INSTALL, | 130 is_editable_install=gslib.IS_EDITABLE_INSTALL, |
| 130 )) | 131 )) |
| 131 | 132 |
| 132 return 0 | 133 return 0 |
| 133 | 134 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 153 files_to_checksum.append(os.path.join(root, filepath)) | 154 files_to_checksum.append(os.path.join(root, filepath)) |
| 154 # Sort to ensure consistent checksum build, no matter how os.walk | 155 # Sort to ensure consistent checksum build, no matter how os.walk |
| 155 # orders the list. | 156 # orders the list. |
| 156 for filepath in sorted(files_to_checksum): | 157 for filepath in sorted(files_to_checksum): |
| 157 f = open(filepath, 'r') | 158 f = open(filepath, 'r') |
| 158 content = f.read() | 159 content = f.read() |
| 159 content = re.sub(r'(\r\n|\r|\n)', '\n', content) | 160 content = re.sub(r'(\r\n|\r|\n)', '\n', content) |
| 160 m.update(content) | 161 m.update(content) |
| 161 f.close() | 162 f.close() |
| 162 return m.hexdigest() | 163 return m.hexdigest() |
| OLD | NEW |