Skip to content

Commit

Permalink
Merge pull request #2336 from piotr1212/travis37
Browse files Browse the repository at this point in the history
Add Django 2.1 and Python 3.7 to Travis tests
  • Loading branch information
DanCech committed Aug 23, 2018
2 parents 824800a + c2906cc commit 87240bf
Show file tree
Hide file tree
Showing 55 changed files with 480 additions and 96 deletions.
39 changes: 28 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,58 @@ language: python
python: 2.7
sudo: false

# Python 3.7 needs dist: xenial and sudo: true
matrix:
include:
- python: pypy
env:
- TOXENV=pypy-django111-pyparsing2
- python: 3.4
env:
- TOXENV=py34-django200-pyparsing2
- TOXENV=py34-django20-pyparsing2
- python: 3.5
env:
- TOXENV=py35-django200-pyparsing2
- python: 3.6
- TOXENV=py35-django21-pyparsing2
- python: 3.5
env:
- TOXENV=py36-django200-pyparsing2
- TOXENV=py35-django21-pyparsing2
- python: 3.6
env:
- TOXENV=py36-django200-pyparsing2-msgpack
- python: 3.6
- TOXENV=py36-django21-pyparsing2
- python: 3.7
sudo: true
dist: xenial
env:
- TOXENV=py36-django200-pyparsing2-pyhash
- python: 3.6
- TOXENV=py37-django21-pyparsing2-msgpack
- python: 3.7
sudo: true
dist: xenial
env:
- TOXENV=py37-django21-pyparsing2-pyhash
- python: 3.7
sudo: true
dist: xenial
env:
- TOXENV=py37-django21-pyparsing2-mysql TEST_MYSQL_PASSWORD=graphite
- python: 3.7
sudo: true
dist: xenial
env:
- TOXENV=py37-django21-pyparsing2-postgresql TEST_POSTGRESQL_PASSWORD=graphite
- python: 3.7
sudo: true
dist: xenial
env:
- TOXENV=lint

env:
- TOXENV=py27-django18-pyparsing2
- TOXENV=py27-django19-pyparsing2
- TOXENV=py27-django110-pyparsing2
- TOXENV=py27-django111-pyparsing2-rrdtool
- TOXENV=py27-django111-pyparsing2-msgpack
- TOXENV=py27-django111-pyparsing2-pyhash
- TOXENV=py27-django111-pyparsing2-mysql TEST_MYSQL_PASSWORD=graphite
- TOXENV=py27-django111-pyparsing2-postgresql TEST_POSTGRESQL_PASSWORD=graphite
- TOXENV=docs
- TOXENV=lint

addons:
apt:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# deactivate
#

Django>=1.8,<2.0.99
Django>=1.8,<2.1.99
python-memcached==1.58
txAMQP==0.8
django-tagging==0.4.6
Expand Down
5 changes: 1 addition & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ obsoletes = graphite <= 0.9.9
# E121 continuation line under-indented for hanging indent
# E261 at least two spaces before inline comment
# E226 missing whitespace around arithmetic operator
# E302 expected 2 blank lines, found 1
# E262 inline comment should start with '# '
# E701 multiple statements on one line (colon)
# E241 multiple spaces after ':'
Expand All @@ -42,11 +41,9 @@ obsoletes = graphite <= 0.9.9
# E401 multiple imports on one line
# E222 multiple spaces after operator
# E126 continuation line over-indented for hanging indent
# E303 too many blank lines
# E122 continuation line missing indentation or outdented
# E222 multiple spaces after operator
# E225 missing whitespace around operator
# E301 expected 1 blank line, found 0
# E228 missing whitespace around modulo operator
# E127 continuation line over-indented for visual indent
# E123 closing bracket does not match indentation of opening bracket's line
Expand All @@ -61,4 +58,4 @@ obsoletes = graphite <= 0.9.9
# E731 do not assign a lambda expression, use a def
# E114 indentation is not a multiple of four (comment)
# E266 too many leading '#' for block comment
ignore=E128,E111,E501,E231,E201,E202,E203,E251,E124,E265,E121,E261,E226,E302,E262,E701,E241,E221,E703,E502,F841,E401,E222,E126,E303,E122,E222,E225,E301,E228,E127,E123,E713,E125,E227,E271,E272,N802,N803,N806,E731,E114,E266
ignore=E128,E111,E501,E231,E201,E202,E203,E251,E124,E265,E121,E261,E226,E262,E701,E241,E221,E703,E502,F841,E401,E222,E126,E122,E222,E225,E228,E127,E123,E713,E125,E227,E271,E272,N802,N803,N806,E731,E114,E266
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@
'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',
],
**setup_kwargs
)
Expand Down
17 changes: 11 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[tox]
# Django 21 does not support Python 3.4
# Django 1.11 has a bug and does not work with Python 3.7 (this will be fixed)
envlist =
py{27,py}-django1{8,9,10,11}-pyparsing2{,-mysql,-postgresql,-rrdtool,-msgpack,-pyhash},
py{34,35,36}-django{18,19,110,111,200}-pyparsing2{,-mysql,-postgresql,-rrdtool,-msgpack,-pyhash},
lint, docs
py{27,py}-django1{8,11}-pyparsing2{,-rrdtool,-msgpack,-pyhash},
py{34}-django{18,111,20}-pyparsing2{,-rrdtool,-msgpack,-pyhash},
py{35,36}-django{18,111,20,21}-pyparsing2{,-rrdtool,-msgpack,-pyhash},
py37-django{20,21}-pyparsing2{,-rrdtool,-msgpack,-pyhash},
lint, docs

[testenv]
whitelist_externals =
Expand Down Expand Up @@ -32,7 +36,8 @@ deps =
django19: Django>=1.9,<1.9.99
django110: Django>=1.10,<1.10.99
django111: Django>=1.11,<1.11.99
django200: Django>=2.0,<2.0.99
django20: Django>=2.0,<2.0.99
django21: Django>=2.1,<2.1.99
scandir
urllib3
redis
Expand Down Expand Up @@ -62,9 +67,9 @@ commands =
sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html

[testenv:lint]
basepython = python2.7
basepython = python3.7
deps =
flake8==2.6.2
flake8
commands =
flake8 {toxinidir}/webapp/graphite
flake8 {toxinidir}/webapp/tests
1 change: 1 addition & 0 deletions webapp/graphite/account/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.contrib import admin
from graphite.account.models import Profile,MyGraph


class MyGraphAdmin(admin.ModelAdmin):
list_display = ('profile','name')
list_filter = ('profile',)
Expand Down
9 changes: 5 additions & 4 deletions webapp/graphite/account/ldapBackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,21 @@ def authenticate(self, username=None, password=None):
try:
resultID = conn.search( settings.LDAP_SEARCH_BASE, scope, filter, returnFields )
resultType, resultData = conn.result( resultID, 0 )
if len(resultData) != 1: #User does not exist
if len(resultData) != 1: # User does not exist
return None

userDN = resultData[0][0]
try:
userMail = resultData[0][1]['mail'][0].decode("utf-8")
except:
except Exception:
userMail = "Unknown"

conn.simple_bind_s(userDN,password)
try:
user = User.objects.get(username=username)
except: #First time login, not in django's database
randomPasswd = User.objects.make_random_password(length=16) #To prevent login from django db user
except Exception: # First time login, not in django's database
# To prevent login from django db user
randomPasswd = User.objects.make_random_password(length=16)
user = User.objects.create_user(username, userMail, randomPasswd)
user.save()

Expand Down
4 changes: 4 additions & 0 deletions webapp/graphite/account/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ class Profile(models.Model):
advancedUI = models.BooleanField(default=False)
__str__ = lambda self: "Profile for %s" % self.user


class Variable(models.Model):
profile = models.ForeignKey(Profile, on_delete=models.CASCADE)
name = models.CharField(max_length=64)
value = models.CharField(max_length=64)


class View(models.Model):
profile = models.ForeignKey(Profile, on_delete=models.CASCADE)
name = models.CharField(max_length=64)


class Window(models.Model):
view = models.ForeignKey(View, on_delete=models.CASCADE)
name = models.CharField(max_length=64)
Expand All @@ -41,6 +44,7 @@ class Window(models.Model):
url = models.TextField()
interval = models.IntegerField(null=True)


class MyGraph(models.Model):
profile = models.ForeignKey(Profile, on_delete=models.CASCADE)
name = models.CharField(max_length=64)
Expand Down
3 changes: 3 additions & 0 deletions webapp/graphite/account/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,20 @@ def loginView(request):
else:
return render_to_response("login.html",{'nextPage' : nextPage})


def logoutView(request):
nextPage = request.GET.get('nextPage', reverse('browser'))
logout(request)
return HttpResponseRedirect(nextPage)


def editProfile(request):
if not isAuthenticated(request.user):
return HttpResponseRedirect(reverse('browser'))
context = { 'profile' : getProfile(request) }
return render_to_response("editProfile.html",context)


def updateProfile(request):
profile = getProfile(request,allowDefault=False)
if profile:
Expand Down
5 changes: 3 additions & 2 deletions webapp/graphite/browser/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def myGraphLookup(request):

nodes.append(node)

except:
except Exception:
log.exception("browser.views.myGraphLookup(): could not complete request.")

if not nodes:
Expand All @@ -165,6 +165,7 @@ def myGraphLookup(request):

return json_response(nodes, request)


def userGraphLookup(request):
"View for User Graphs navigation"
user = request.GET.get('user')
Expand Down Expand Up @@ -257,7 +258,7 @@ def userGraphLookup(request):

nodes.append(node)

except:
except Exception:
log.exception("browser.views.userLookup(): could not complete request for %s" % username)

if not nodes:
Expand Down
2 changes: 1 addition & 1 deletion webapp/graphite/carbonlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def get_connection(self, host):
connection.settimeout(self.timeout)
try:
connection.connect((server, port))
except:
except socket.error:
self.last_failure[host] = time.time()
raise
else:
Expand Down
8 changes: 4 additions & 4 deletions webapp/graphite/composer/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist


def composer(request):
profile = getProfile(request)
context = {
Expand Down Expand Up @@ -71,8 +72,7 @@ def mygraph(request):
try:
newGraph = MyGraph(profile=profile,name=graphName,url=url)
newGraph.save()

except:
except Exception:
log.exception("Failed to create new MyGraph in /composer/mygraph/, graphName=%s" % graphName)
return HttpResponse("Failed to save graph %s" % graphName)

Expand Down Expand Up @@ -120,5 +120,5 @@ def send_email(request):
s.sendmail('composer@%s' % gethostname(),recipients,message.as_string())
s.quit()
return HttpResponse( "OK" )
except:
return HttpResponse( format_exc() )
except Exception:
return HttpResponse(format_exc())
2 changes: 2 additions & 0 deletions webapp/graphite/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
from graphite.util import json
import six


class Dashboard(models.Model):
name = models.CharField(primary_key=True, max_length=128)
owners = models.ManyToManyField(Profile, related_name='dashboards')
state = models.TextField()
__str__ = lambda self: "Dashboard [%s]" % self.name


class Template(models.Model):

class Admin: pass
Expand Down
2 changes: 2 additions & 0 deletions webapp/graphite/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

ALL_PERMISSIONS = ['change', 'delete']


class DashboardConfig:
def __init__(self):
self.last_read = 0
Expand Down Expand Up @@ -201,6 +202,7 @@ def template(request, name, val):
context['initialState'] = json.dumps(state)
return render_to_response("dashboard.html", context)


def getPermissions(user):
"""Return [change, delete] based on authorisation model and user privileges/groups"""
if user and not isAuthenticated(user):
Expand Down
2 changes: 2 additions & 0 deletions webapp/graphite/events/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
from tagging.managers import (ModelTaggedItemManager as BaseModelTaggedItemManager,
TaggedItem)


class ContentTypeMixin(object):
def with_intersection(self, tags, queryset=None):
if queryset is None:
return TaggedItem.objects.get_intersection_by_model(self.model, tags)
else:
return TaggedItem.objects.get_intersection_by_model(queryset, tags)


class ModelTaggedItemManager(ContentTypeMixin, BaseModelTaggedItemManager):
pass
2 changes: 1 addition & 1 deletion webapp/graphite/events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
else:
from tagging.fields import TagField


class Event(models.Model):
when = models.DateTimeField()
what = models.CharField(max_length=255)
Expand Down Expand Up @@ -41,7 +42,6 @@ def find_events(time_from=None, time_until=None, tags=None, set_operation=None):
if time_until is not None:
query = query.filter(when__lte=time_until)


result = list(query.order_by("when"))
return result

Expand Down
1 change: 1 addition & 0 deletions webapp/graphite/finders/ceres.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from graphite.finders import get_real_metric_path, extract_variants
from graphite.tags.utils import TaggedSeries


class CeresFinder(BaseFinder):
def __init__(self, directory=None):
directory = directory or settings.CERES_DIR
Expand Down

0 comments on commit 87240bf

Please sign in to comment.