From 24b47e0000a64ea4b02cf776734e9e8ce5803047 Mon Sep 17 00:00:00 2001 From: Denis Poisson Date: Mon, 20 Nov 2017 13:40:08 +0100 Subject: [PATCH] Fix Python linter error - Part 7 --- .../hello_django/hello_django/settings.py | 15 +++++++++++++ webapp_demo/hello_django/hello_django/urls.py | 18 ++++++++++++++- webapp_demo/hello_django/hello_django/wsgi.py | 15 +++++++++++++ webapp_demo/hello_django/manage.py | 16 +++++++++++++- .../hello_django/prometheus_app/admin.py | 17 +++++++++++++- .../hello_django/prometheus_app/apps.py | 15 +++++++++++++ .../hello_django/prometheus_app/models.py | 17 +++++++++++++- .../hello_django/prometheus_app/tests.py | 17 +++++++++++++- .../hello_django/prometheus_app/urls.py | 17 +++++++++++++- .../hello_django/prometheus_app/views.py | 22 ++++++++++++++++--- 10 files changed, 160 insertions(+), 9 deletions(-) diff --git a/webapp_demo/hello_django/hello_django/settings.py b/webapp_demo/hello_django/hello_django/settings.py index 6c949e88d..368f38e23 100644 --- a/webapp_demo/hello_django/hello_django/settings.py +++ b/webapp_demo/hello_django/hello_django/settings.py @@ -1,3 +1,18 @@ +#!/usr/bin/env python +# coding=utf-8 + +# 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. + """ Django settings for hello_django project. diff --git a/webapp_demo/hello_django/hello_django/urls.py b/webapp_demo/hello_django/hello_django/urls.py index 95b2a7169..deb70ec21 100644 --- a/webapp_demo/hello_django/hello_django/urls.py +++ b/webapp_demo/hello_django/hello_django/urls.py @@ -1,3 +1,18 @@ +#!/usr/bin/env python +# coding=utf-8 + +# 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. + """hello_django URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: @@ -13,7 +28,8 @@ 1. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ -from django.conf.urls import url, include +from django.conf.urls import include +from django.conf.urls import url from django.contrib import admin urlpatterns = [ diff --git a/webapp_demo/hello_django/hello_django/wsgi.py b/webapp_demo/hello_django/hello_django/wsgi.py index a4271c507..5950255c1 100644 --- a/webapp_demo/hello_django/hello_django/wsgi.py +++ b/webapp_demo/hello_django/hello_django/wsgi.py @@ -1,3 +1,18 @@ +#!/usr/bin/env python +# coding=utf-8 + +# 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. + """ WSGI config for hello_django project. diff --git a/webapp_demo/hello_django/manage.py b/webapp_demo/hello_django/manage.py index b56986094..46f1a4475 100755 --- a/webapp_demo/hello_django/manage.py +++ b/webapp_demo/hello_django/manage.py @@ -1,4 +1,18 @@ #!/usr/bin/env python +# coding=utf-8 + +# 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. + import os import sys @@ -11,7 +25,7 @@ # issue is really that Django is missing to avoid masking other # exceptions on Python 2. try: - import django + import django # noqa:F401 except ImportError: raise ImportError( "Couldn't import Django. Are you sure it's installed and " diff --git a/webapp_demo/hello_django/prometheus_app/admin.py b/webapp_demo/hello_django/prometheus_app/admin.py index 8c38f3f3d..0bc3bdca6 100644 --- a/webapp_demo/hello_django/prometheus_app/admin.py +++ b/webapp_demo/hello_django/prometheus_app/admin.py @@ -1,3 +1,18 @@ -from django.contrib import admin +#!/usr/bin/env python +# coding=utf-8 + +# 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. + +from django.contrib import admin # noqa: F401 # Register your models here. diff --git a/webapp_demo/hello_django/prometheus_app/apps.py b/webapp_demo/hello_django/prometheus_app/apps.py index d67523096..46185df90 100644 --- a/webapp_demo/hello_django/prometheus_app/apps.py +++ b/webapp_demo/hello_django/prometheus_app/apps.py @@ -1,3 +1,18 @@ +#!/usr/bin/env python +# coding=utf-8 + +# 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. + from __future__ import unicode_literals from django.apps import AppConfig diff --git a/webapp_demo/hello_django/prometheus_app/models.py b/webapp_demo/hello_django/prometheus_app/models.py index bd4b2abe9..09e4bbb8f 100644 --- a/webapp_demo/hello_django/prometheus_app/models.py +++ b/webapp_demo/hello_django/prometheus_app/models.py @@ -1,5 +1,20 @@ +#!/usr/bin/env python +# coding=utf-8 + +# 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. + from __future__ import unicode_literals -from django.db import models +from django.db import models # noqa: F401 # Create your models here. diff --git a/webapp_demo/hello_django/prometheus_app/tests.py b/webapp_demo/hello_django/prometheus_app/tests.py index 7ce503c2d..63a891e0f 100644 --- a/webapp_demo/hello_django/prometheus_app/tests.py +++ b/webapp_demo/hello_django/prometheus_app/tests.py @@ -1,3 +1,18 @@ -from django.test import TestCase +#!/usr/bin/env python +# coding=utf-8 + +# 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. + +from django.test import TestCase # noqa: F401 # Create your tests here. diff --git a/webapp_demo/hello_django/prometheus_app/urls.py b/webapp_demo/hello_django/prometheus_app/urls.py index 6eebe4d7c..e710fdef9 100644 --- a/webapp_demo/hello_django/prometheus_app/urls.py +++ b/webapp_demo/hello_django/prometheus_app/urls.py @@ -1,7 +1,22 @@ +#!/usr/bin/env python +# coding=utf-8 + +# 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. + # howdy/urls.py from django.conf.urls import url from prometheus_app import views urlpatterns = [ url(r'^$', views.HomePageView.as_view()), -] \ No newline at end of file +] diff --git a/webapp_demo/hello_django/prometheus_app/views.py b/webapp_demo/hello_django/prometheus_app/views.py index b6861de40..60623cdcb 100644 --- a/webapp_demo/hello_django/prometheus_app/views.py +++ b/webapp_demo/hello_django/prometheus_app/views.py @@ -1,8 +1,24 @@ +#!/usr/bin/env python +# coding=utf-8 + +# 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. + # prometheus_app/views.py from django.shortcuts import render from django.views.generic import TemplateView -from prometheus_client import start_http_server, Counter +from prometheus_client import Counter +from prometheus_client import start_http_server CLICK_TIME = Counter('button_click_counter', 'Counter for a button', ['version', 'button_name']) @@ -16,8 +32,8 @@ class HomePageView(TemplateView): def get(self, request, **kwargs): context = { - 'current_value': 0.0 - } + 'current_value': 0.0 + } if request.GET.get('click_btn'): CLICK_TIME.labels(version='v1.0', button_name='START').inc( amount=1)