-
Notifications
You must be signed in to change notification settings - Fork 69
Python 3 support #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Python 3 support #13
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d6397dd
py3 support: Fixup print statements
polotek c690021
py3 support: dictionary update
polotek a53a05b
py3 support: xrange to range
polotek 82aabef
py3 support: use explicit octal literal
polotek 81fa59a
py3 support: hash byte encoding
polotek 7f0f97a
py3 support: Update classifiers with py3 support
polotek 3b092f3
py3 support: Remove 3.2 support because of unicode
polotek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ | |
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from __future__ import absolute_import | ||
| from __future__ import print_function | ||
| from cloudwatchmon.cloud_watch_client import * | ||
|
|
||
| import argparse | ||
|
|
@@ -29,6 +31,7 @@ | |
| import re | ||
| import sys | ||
| import time | ||
| from six.moves import range | ||
|
|
||
| CLIENT_NAME = 'CloudWatch-PutInstanceData' | ||
| FileCache.CLIENT_NAME = CLIENT_NAME | ||
|
|
@@ -167,7 +170,9 @@ def __add_metric_dimensions(self, name, unit, value, common_dims, dims): | |
| self.names.append(name) | ||
| self.units.append(unit) | ||
| self.values.append(value) | ||
| self.dimensions.append(dict(common_dims.items() + dim.items())) | ||
| final_dims = common_dims.copy() | ||
| final_dims.update(dims) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This results in a runtime error: |
||
| self.dimensions.append(final_dims) | ||
|
|
||
| def send(self, verbose): | ||
| boto_debug = 2 if verbose else 0 | ||
|
|
@@ -181,7 +186,7 @@ def send(self, verbose): | |
|
|
||
| size = len(self.names) | ||
|
|
||
| for idx_start in xrange(0, size, AWS_LIMIT_METRICS_SIZE): | ||
| for idx_start in range(0, size, AWS_LIMIT_METRICS_SIZE): | ||
| idx_end = idx_start + AWS_LIMIT_METRICS_SIZE | ||
| response = conn.put_metric_data('System/Linux', | ||
| self.names[idx_start:idx_end], | ||
|
|
@@ -403,7 +408,7 @@ def add_static_file_metrics(args, metrics): | |
| (label, unit, value) = [x.strip() for x in line.split(',')] | ||
| metrics.add_metric(label, unit, value) | ||
| except ValueError: | ||
| print 'Ignore unparseable metric: "' + line + '"' | ||
| print('Ignore unparseable metric: "' + line + '"') | ||
| pass | ||
|
|
||
|
|
||
|
|
@@ -465,7 +470,7 @@ def main(): | |
| args = parser.parse_args() | ||
|
|
||
| if args.version: | ||
| print CLIENT_NAME + ' version ' + VERSION | ||
| print(CLIENT_NAME + ' version ' + VERSION) | ||
| return 0 | ||
|
|
||
| try: | ||
|
|
@@ -476,13 +481,13 @@ def main(): | |
| time.sleep(random.randint(0, 19)) | ||
|
|
||
| if args.verbose: | ||
| print 'Working in verbose mode' | ||
| print 'Boto-Version: ' + boto.__version__ | ||
| print('Working in verbose mode') | ||
| print('Boto-Version: ' + boto.__version__) | ||
|
|
||
| metadata = get_metadata() | ||
|
|
||
| if args.verbose: | ||
| print 'Instance metadata: ' + str(metadata) | ||
| print('Instance metadata: ' + str(metadata)) | ||
|
|
||
| region = metadata['placement']['availability-zone'][:-1] | ||
| instance_id = metadata['instance-id'] | ||
|
|
@@ -493,7 +498,7 @@ def main(): | |
| args.verbose) | ||
|
|
||
| if args.verbose: | ||
| print 'Autoscaling group: ' + autoscaling_group_name | ||
| print('Autoscaling group: ' + autoscaling_group_name) | ||
|
|
||
| metrics = Metrics(region, | ||
| instance_id, | ||
|
|
@@ -515,16 +520,16 @@ def main(): | |
| add_disk_metrics(args, metrics) | ||
|
|
||
| if args.verbose: | ||
| print 'Request:\n' + str(metrics) | ||
| print('Request:\n' + str(metrics)) | ||
|
|
||
| if args.verify: | ||
| if not args.from_cron: | ||
| print 'Verification completed successfully. ' \ | ||
| 'No actual metrics sent to CloudWatch.' | ||
| print('Verification completed successfully. ' \ | ||
| 'No actual metrics sent to CloudWatch.') | ||
| else: | ||
| metrics.send(args.verbose) | ||
| if not args.from_cron: | ||
| print 'Successfully reported metrics to CloudWatch.' | ||
| print('Successfully reported metrics to CloudWatch.') | ||
| except Exception as e: | ||
| log_error(str(e), args.from_cron) | ||
| return 1 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, if this may result in the same problem as below...