Skip to content

Commit

Permalink
Merge pull request #284 from deniszh/backport/1.1.x/pr-271_pr-272_pr-…
Browse files Browse the repository at this point in the history
…273_pr-273_pr-277_pr-277_pr-280_pr-280_pr-282

[1.1.x] set package long description | Switch to setuptools | adding appropriate 'type' to sleep variable | adding appropriate 'type' to sleep variable | Add testing for py38-dev and remove py34 | whisper-fil
  • Loading branch information
deniszh authored Oct 23, 2019
2 parents 87ae6de + 60593a8 commit d88048b
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ ve
.idea
*.iml
*.swp
whisper.egg-info/
13 changes: 6 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
language: python
dist: xenial
sudo: false
python: 2.7

Expand All @@ -9,25 +10,23 @@ matrix:
- python: 2.7
env:
- TOXENV=py27
- python: 3.4
env:
- TOXENV=py34
- python: 3.5
env:
- TOXENV=py35
- python: 3.6
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
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include README.md
exclude .* MANIFEST.in
global-exclude __pycache__
global-exclude *.py[co]
Expand Down
2 changes: 1 addition & 1 deletion bin/rrd2whisper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
14 changes: 11 additions & 3 deletions bin/whisper-dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand All @@ -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

Expand All @@ -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)
34 changes: 17 additions & 17 deletions bin/whisper-fill.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion contrib/update-storage-times.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 10 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -12,18 +18,20 @@
author_email='[email protected]',
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'],
classifiers=[
'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
)
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[tox]
envlist =
py27,
py34,
py35,
py36,
py37,
py38,
pypy,
pypy3,
lint,
Expand Down

0 comments on commit d88048b

Please sign in to comment.