diff --git a/.gitignore b/.gitignore index 4acbbda6..582b9a67 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ ve .idea *.iml *.swp +whisper.egg-info/ diff --git a/.travis.yml b/.travis.yml index 78b1d235..78f386f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: python +dist: xenial sudo: false python: 2.7 @@ -9,9 +10,6 @@ matrix: - python: 2.7 env: - TOXENV=py27 - - python: 3.4 - env: - - TOXENV=py34 - python: 3.5 env: - TOXENV=py35 @@ -19,15 +17,16 @@ matrix: env: - TOXENV=py36 - python: 3.7 - dist: xenial - sudo: true env: - TOXENV=py37 + - python: "3.8-dev" + env: + - TOXENV=py38 - python: 3.7 - dist: xenial - sudo: true env: - TOXENV=lint + allow_failures: + - python: "3.8-dev" install: - pip install tox diff --git a/MANIFEST.in b/MANIFEST.in index b16f3092..9e8199cd 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,4 @@ +include README.md exclude .* MANIFEST.in global-exclude __pycache__ global-exclude *.py[co] diff --git a/bin/rrd2whisper.py b/bin/rrd2whisper.py index 0fde5302..4abe7247 100755 --- a/bin/rrd2whisper.py +++ b/bin/rrd2whisper.py @@ -157,7 +157,7 @@ values = [row[column_index] for row in rows] timestamps = list(range(*time_info)) datapoints = zip(timestamps, values) - datapoints = filter(lambda p: p[1] is not None, datapoints) + datapoints = [datapoint for datapoint in datapoints if datapoint[1] is not None] print(' migrating %d datapoints from archive %d' % (len(datapoints), archiveNumber)) archiveNumber -= 1 whisper.update_many(path, datapoints) diff --git a/bin/whisper-dump.py b/bin/whisper-dump.py index 49e3b155..caadcc10 100755 --- a/bin/whisper-dump.py +++ b/bin/whisper-dump.py @@ -26,6 +26,9 @@ option_parser.add_option( '-t', '--time-format', action='store', type='string', dest='time_format', help='Time format to use with --pretty; see time.strftime()') +option_parser.add_option( + '-r', '--raw', default=False, action='store_true', + help='Dump value only in the same format for whisper-update (UTC timestamps)') (options, args) = option_parser.parse_args() if len(args) != 1: @@ -101,7 +104,8 @@ def dump_archive_headers(archives): def dump_archives(archives, options): for i, archive in enumerate(archives): - print('Archive %d data:' % i) + if not options.raw: + print('Archive %d data:' % i) offset = archive['offset'] for point in xrange(archive['points']): (timestamp, value) = struct.unpack( @@ -116,7 +120,10 @@ def dump_archives(archives, options): timestr = time.ctime(timestamp) else: timestr = str(timestamp) - print('%d: %s, %10.35g' % (point, timestr, value)) + if options.raw: + print('%s:%.35g' % (timestamp, value)) + else: + print('%d: %s, %10.35g' % (point, timestr, value)) offset += whisper.pointSize print @@ -126,5 +133,6 @@ def dump_archives(archives, options): map = mmap_file(path) header = read_header(map) -dump_header(header) +if not options.raw: + dump_header(header) dump_archives(header['archives'], options) diff --git a/bin/whisper-fill.py b/bin/whisper-fill.py index aac9ef3d..84eccb68 100755 --- a/bin/whisper-fill.py +++ b/bin/whisper-fill.py @@ -122,27 +122,27 @@ def fill_archives(src, dst, startFrom): def main(): - option_parser = optparse.OptionParser( - usage='%prog [--lock] src dst', - description='copies data from src in dst, if missing') - option_parser.add_option( - '--lock', help='Lock whisper files', - default=False, action='store_true') - (options, args) = option_parser.parse_args() + option_parser = optparse.OptionParser( + usage='%prog [--lock] src dst', + description='copies data from src in dst, if missing') + option_parser.add_option( + '--lock', help='Lock whisper files', + default=False, action='store_true') + (options, args) = option_parser.parse_args() - if len(args) != 2: - option_parser.print_help() - sys.exit(1) + if len(args) != 2: + option_parser.print_help() + sys.exit(1) - if options.lock is True and whisper.CAN_LOCK: - whisper.LOCK = True + if options.lock is True and whisper.CAN_LOCK: + whisper.LOCK = True - src = args[0] - dst = args[1] - startFrom = time.time() + src = args[0] + dst = args[1] + startFrom = time.time() - fill_archives(src, dst, startFrom) + fill_archives(src, dst, startFrom) if __name__ == "__main__": - main() + main() diff --git a/contrib/update-storage-times.py b/contrib/update-storage-times.py index 5ae970e2..bc37c77c 100755 --- a/contrib/update-storage-times.py +++ b/contrib/update-storage-times.py @@ -175,7 +175,7 @@ def cli_opts(): parser.add_argument('--bindir', action='store', dest='bindir', help="The root path to whisper-resize.py and whisper-info.py", default='/opt/graphite/bin') - parser.add_argument('--sleep', action='store', dest='sleep', + parser.add_argument('--sleep', action='store', type=float, dest='sleep', help="Sleep this amount of time in seconds between metric comparisons", default=0.3) return parser.parse_args() diff --git a/setup.py b/setup.py index 8b9c696b..8b8c69ee 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,13 @@ #!/usr/bin/env python +import os from glob import glob -from distutils.core import setup +from setuptools import setup + + +def read(fname): + with open(os.path.join(os.path.dirname(__file__), fname)) as f: + return f.read() setup( @@ -12,6 +18,8 @@ author_email='chrismd@gmail.com', license='Apache Software License 2.0', description='Fixed size round-robin style database', + long_description=read('README.md'), + long_description_content_type='text/markdown', py_modules=['whisper'], scripts=glob('bin/*') + glob('contrib/*'), install_requires=['six'], @@ -19,11 +27,11 @@ 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', ], + zip_safe=False ) diff --git a/tox.ini b/tox.ini index 7eee05a2..86475539 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,10 @@ [tox] envlist = py27, - py34, py35, py36, py37, + py38, pypy, pypy3, lint,