python-openstackclient/openstackclient/common/timing.py
Tom Cocozzello 3d7a26bdec Defaults are ignored with flake8
If “ignore” is not set under flake8 in the tox.ini
file there there are defaults set to be ignored.

The depended patch fixes many of the problems.

Change-Id: Ieed2fe1c4654e201d3fe6d40ef93e247ee736f8b
Doc: http://flake8.readthedocs.org/en/latest/config.html#default
Depends-On: I935ab48e7c5bac5f88ecdb3a05f73fb44fc9f41d
Closes-Bug: #1548910
2016-02-23 11:08:36 -06:00

42 lines
1.3 KiB
Python

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
"""Timing Implementation"""
from openstackclient.common import command
class Timing(command.Lister):
"""Show timing data"""
def take_action(self, parsed_args):
column_headers = (
'URL',
'Seconds',
)
results = []
total = 0.0
for url, td in self.app.timing_data:
# NOTE(dtroyer): Take the long way here because total_seconds()
# was added in py27.
sec = (td.microseconds + (td.seconds + td.days *
86400) * 1e6) / 1e6
total += sec
results.append((url, sec))
results.append(('Total', total))
return (
column_headers,
results,
)