Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
34a8ccf
py3k: change all print statements to be functions
Ormod Aug 24, 2015
3ee58a7
py3k: Change exception syntax from old style commas to use the as syntax
Ormod Aug 24, 2015
a4572f3
tests: import Mock and patch from the test base file
Ormod Aug 24, 2015
a741895
py3k: add a pycompat helper file for imports
Ormod Aug 26, 2015
8e898fd
tests: import exception types through a relative import
Ormod Aug 24, 2015
c21a510
py3k: replace all dict.iteritems() with .items()
Ormod Aug 24, 2015
3afd21b
test: make filter iterators into lists for py3k compatibility
Ormod Aug 24, 2015
8bd1acf
py3k: replace xrange with range for compatibility
Ormod Aug 24, 2015
f28b235
py3k: Replace all uses of basestring with isinstance(x, str)
Ormod Aug 24, 2015
0ed4d81
py3k: use string.ascii_letters since it also exists in py3k
Ormod Aug 24, 2015
9addc26
py3k: Replace the obsolete use of string.replace with .replace()
Ormod Aug 24, 2015
d0e46bd
py3k: Replace some more uses of call and magicmock from the one in ba…
Ormod Aug 24, 2015
4cb8a4c
tests: import StringIO from the base test file
Ormod Aug 24, 2015
3618170
py3k: Change tests mock patching to use a variable from test base file
Ormod Aug 24, 2015
bee85ad
py3k: import urllib from a common pycompat file
Ormod Aug 24, 2015
00a7340
py3k: Fix cpickle import to have a fallback
Ormod Aug 24, 2015
23a7971
py3k: import Queue related functionality from pycompat
Ormod Aug 24, 2015
b4186e6
py3k: Move http client to a file with a different name to unmask the …
Ormod Aug 24, 2015
b01d6e3
py3k: Change xmlrpclib imports to work with both py3k and 2.x
Ormod Aug 24, 2015
fba635e
py3k: Since py3k no longer has a long type, mock int as its replacement
Ormod Aug 24, 2015
cbd98e3
py3k: subprocess returns bytes not strings on py3k, convert to unicode
Ormod Aug 24, 2015
9ec08f1
py3k: Fix test class to work with different type of __next__/next met…
Ormod Aug 25, 2015
01e3b81
py3k: Makefile/setup.py changes to support building both py2.x and py3k
Ormod Aug 26, 2015
d35960b
Makefile: get distribution name by asking python itself
Ormod Aug 26, 2015
3d1f143
pep8: Fix pep8 issues created during py3k work
Ormod Aug 26, 2015
55c7d56
py3k: Replace file() calls with open()
Ormod Aug 26, 2015
35510ed
py3k: Change imports to be relative imports for Handlers
Ormod Aug 26, 2015
40ee747
Add python 3 to Travis testing
shortdudey123 Mar 11, 2017
dfbe06e
Install python34 in Vagrant centos7-test host
shortdudey123 Mar 11, 2017
f0fadc5
More compatability changes
shortdudey123 Mar 11, 2017
1bdf771
Switch from izip to zip
shortdudey123 Mar 11, 2017
be0e557
Update urllib compat more
shortdudey123 Mar 11, 2017
73207d0
Fix several pep8 errors
shortdudey123 Mar 11, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .travis.requirements3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#MySQL-python
PyYAML
#beanstalkc
riemann-client
boto
configobj
docker-py
kitchen
mock
psutil
pymongo<3.0
statsd
#pyutmp
redis
simplejson
setproctitle
psycopg2
#PySensors
pysnmp
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ python:
# - "2.5"
- "2.6"
- "2.7"
- "3.4"
- "3.5"
- "3.6"

cache:
directories:
Expand All @@ -14,7 +17,8 @@ cache:
# command to install dependencies, e.g. pip install -r requirements.txt
install:
- pip install Cython
- pip install -r .travis.requirements.txt
- if [[ $TRAVIS_PYTHON_VERSION == 2* ]]; then pip install -r .travis.requirements.txt; fi
- if [[ $TRAVIS_PYTHON_VERSION == 3* ]]; then pip install -r .travis.requirements3.txt; fi
- pip install pep8==1.5.7
- pip install coveralls
- if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then pip install unittest2; fi
Expand Down
24 changes: 16 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ PROJECT=diamond
VERSION :=$(shell bash version.sh )
RELEASE :=$(shell ls -1 dist/*.noarch.rpm 2>/dev/null | wc -l )
HASH :=$(shell git rev-parse HEAD )
DISTRO=precise
DISTRO:=$(shell python -c "import platform;print(platform.linux_distribution()[0])")
PYTHON?=python3

all:
@echo "make run - Run Diamond from this directory"
Expand Down Expand Up @@ -40,19 +41,19 @@ docs: version
make test

sdist: version
./setup.py sdist --prune
$(PYTHON) setup.py sdist

bdist: version
./setup.py bdist --prune
$(PYTHON) setup.py bdist

bdist_wheel: version
USE_SETUPTOOLS=1 ./setup.py bdist_wheel
$(PYTHON) setup.py bdist_wheel

install: version
./setup.py install --root $(DESTDIR)
$(PYTHON) setup.py install --root $(DESTDIR)

develop: version
USE_SETUPTOOLS=1 ./setup.py develop
$(PYTHON) setup.py develop

rpm: buildrpm

Expand All @@ -62,14 +63,20 @@ buildrpm: sdist
--build-requires='python, python-configobj, python-setuptools' \
--requires='python, python-configobj, python-setuptools'

buildrpmpy3: sdist
$(PYTHON) setup.py bdist_rpm \
--release=`ls dist/*.noarch.rpm | wc -l` \
--build-requires='python3, python3-configobj' \
--requires='python3, python3-configobj'

deb: builddeb

sdeb: buildsourcedeb

builddeb: version
dch --newversion $(VERSION) --distribution unstable --force-distribution -b "Last Commit: $(shell git log -1 --pretty=format:'(%ai) %H %cn <%ce>')"
dch --release "new upstream"
./setup.py sdist --prune
./setup.py sdist
mkdir -p build
tar -C build -zxf dist/$(PROJECT)-$(VERSION).tar.gz
(cd build/$(PROJECT)-$(VERSION) && debuild -us -uc -v$(VERSION))
Expand All @@ -78,7 +85,7 @@ builddeb: version
buildsourcedeb: version
dch --newversion $(VERSION)~$(DISTRO) --distribution $(DISTRO) --force-distribution -b "Last Commit: $(shell git log -1 --pretty=format:'(%ai) %H %cn <%ce>')"
dch --release "new upstream"
./setup.py sdist --prune
./setup.py sdist
mkdir -p build
tar -C build -zxf dist/$(PROJECT)-$(VERSION).tar.gz
(cd build/$(PROJECT)-$(VERSION) && debuild -S -sa -v$(VERSION))
Expand All @@ -96,6 +103,7 @@ clean:
./setup.py clean
rm -rf dist build MANIFEST .tox *.log
find . -name '*.pyc' -delete
find -name __pycache__ -delete

version:
./version.sh > version.txt
Expand Down
6 changes: 6 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,17 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
c.vm.provision "shell", inline: "sudo rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm"
c.vm.provision "shell", inline: "sudo yum install -y git rpm-build python-configobj python-test python-mock tree vim-enhanced MySQL-python htop gcc"

# Install python 3
c.vm.provision "shell", inline: "sudo yum install -y python34 python34-devel"
c.vm.provision "shell", inline: "curl -O https://bootstrap.pypa.io/get-pip.py && sudo /usr/bin/python3.4 get-pip.py"

# Install python libraries needed by specific collectors
c.vm.provision "shell", inline: "sudo yum install -y postgresql-devel" # req for psycopg2
c.vm.provision "shell", inline: "sudo yum install -y Cython" # req for pyutmp
c.vm.provision "shell", inline: "sudo yum install -y lm_sensors-devel lm_sensors python-devel" # req for pyutmp
c.vm.provision "shell", inline: "sudo yum install -y python-pip"
c.vm.provision "shell", inline: "sudo pip install -r /vagrant/.travis.requirements.txt"
c.vm.provision "shell", inline: "sudo pip3 install -r /vagrant/.travis.requirements3.txt"

# Setup Diamond to run as a service
c.vm.provision "shell", inline: "sudo yum install -y python-setuptools"
Expand All @@ -104,6 +109,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

# Build Diamond docs and run tests
c.vm.provision "shell", inline: "sudo pip install pep8==1.5.7"
c.vm.provision "shell", inline: "sudo pip3 install pep8==1.5.7"
c.vm.provision "shell", inline: "echo 'Build docs...' && python /vagrant/build_doc.py"
c.vm.provision "shell", inline: "echo 'Running tests...' && python /vagrant/test.py"
c.vm.provision "shell", inline: "echo 'Running pep8...' && pep8 --config=/vagrant/.pep8 /vagrant/src /vagrant/bin/diamond /vagrant/bin/diamond-setup /vagrant/build_doc.py /vagrant/setup.py /vagrant/test.py"
Expand Down
49 changes: 26 additions & 23 deletions bin/diamond
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python
# coding=utf-8
from __future__ import print_function

import os
import sys
Expand Down Expand Up @@ -110,27 +111,27 @@ def main():
gid = -1

if options.version:
print "Diamond version %s" % (get_diamond_version())
print("Diamond version %s" % (get_diamond_version()))
sys.exit(0)

# Initialize Config
options.configfile = os.path.abspath(options.configfile)
if os.path.exists(options.configfile):
config = configobj.ConfigObj(options.configfile)
else:
print >> sys.stderr, "ERROR: Config file: %s does not exist." % (
options.configfile)
print("ERROR: Config file: %s does not exist." % (
options.configfile), file=sys.stderr)
parser.print_help(sys.stderr)
sys.exit(1)

# Initialize Logging
log = setup_logging(options.configfile, options.log_stdout)

# Pass the exit up stream rather then handle it as an general exception
except SystemExit, e:
except SystemExit as e:
raise SystemExit

except Exception, e:
except Exception as e:
import traceback
sys.stderr.write("Unhandled exception: %s" % str(e))
sys.stderr.write("traceback: %s" % traceback.format_exc())
Expand All @@ -146,7 +147,7 @@ def main():

# Read existing pid file
try:
pf = file(options.pidfile, 'r')
pf = open(options.pidfile, 'r')
pid = int(pf.read().strip())
pf.close()
except (IOError, ValueError):
Expand All @@ -159,11 +160,11 @@ def main():
# Pid is not real
os.unlink(options.pidfile)
pid = None
print >> sys.stderr, (
"WARN: Bogus pid file was found. I deleted it.")
print("WARN: Bogus pid file was found. I deleted it.",
file=sys.stderr)
else:
print >> sys.stderr, (
"ERROR: Pidfile exists. Server already running?")
print("ERROR: Pidfile exists. Server already running?",
file=sys.stderr)
sys.exit(1)

# Get final GIDs
Expand All @@ -185,9 +186,10 @@ def main():
# Write pid file
pid = str(os.getpid())
try:
pf = file(options.pidfile, 'w+')
except IOError, e:
print >> sys.stderr, "Failed to write PID file: %s" % (e)
pf = open(options.pidfile, 'w+')
except IOError as e:
print("Failed to write PID file: %s" % (e),
file=sys.stderr)
sys.exit(1)
pf.write("%s\n" % pid)
pf.close()
Expand All @@ -211,8 +213,9 @@ def main():
# Set UID
os.setuid(uid)

except Exception, e:
print >> sys.stderr, "ERROR: Failed to set UID/GID. %s" % (e)
except Exception as e:
print("ERROR: Failed to set UID/GID. %s" % (e),
file=sys.stderr)
sys.exit(1)

# Log
Expand All @@ -236,8 +239,8 @@ def main():
if pid > 0:
# Exit first paren
sys.exit(0)
except OSError, e:
print >> sys.stderr, "Failed to fork process." % (e)
except OSError as e:
print("Failed to fork process." % (e), file=sys.stderr)
sys.exit(1)
# Decouple from parent environmen
os.setsid()
Expand All @@ -248,8 +251,8 @@ def main():
if pid > 0:
# Exit second paren
sys.exit(0)
except OSError, e:
print >> sys.stderr, "Failed to fork process." % (e)
except OSError as e:
print("Failed to fork process." % (e), file=sys.stderr)
sys.exit(1)
# Close file descriptors so that we can detach
sys.stdout.close()
Expand All @@ -268,8 +271,8 @@ def main():
# Write pid file
pid = str(os.getpid())
try:
pf = file(options.pidfile, 'w+')
except IOError, e:
pf = open(options.pidfile, 'w+')
except IOError as e:
log.error("Failed to write child PID file: %s" % (e))
sys.exit(1)
pf.write("%s\n" % pid)
Expand Down Expand Up @@ -317,10 +320,10 @@ def main():
server.run()

# Pass the exit up stream rather then handle it as an general exception
except SystemExit, e:
except SystemExit as e:
raise SystemExit

except Exception, e:
except Exception as e:
import traceback
log.error("Unhandled exception: %s" % str(e))
log.error("traceback: %s" % traceback.format_exc())
Expand Down
Loading