Merge lp:~michael.nelson/ubuntu-webcatalog/rt-61147-nagios-sca-import-dict-config into lp:ubuntu-webcatalog

Proposed by Michael Nelson
Status: Merged
Approved by: Michael Nelson
Approved revision: 190
Merged at revision: 186
Proposed branch: lp:~michael.nelson/ubuntu-webcatalog/rt-61147-nagios-sca-import-dict-config
Merge into: lp:ubuntu-webcatalog
Diff against target: 216 lines (+46/-33)
7 files modified
.bzrignore (+1/-0)
django_project/config/main.cfg (+33/-7)
src/webcatalog/management/commands/import_exhibits.py (+1/-1)
src/webcatalog/management/commands/import_sca_apps.py (+9/-12)
src/webcatalog/schema.py (+0/-3)
src/webcatalog/templatetags/webcatalog.py (+2/-2)
src/webcatalog/wsgi.py (+0/-8)
To merge this branch: bzr merge lp:~michael.nelson/ubuntu-webcatalog/rt-61147-nagios-sca-import-dict-config
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+182386@code.launchpad.net

Commit message

Update logging dictConfig for use in deployments and add a specific logger for import_sca_apps.

Description of the change

This is to fix RT 61147 - just to verify the new config (well, ensure that the dev env uses the same setup) which is used in the separate config branch at:

https://code.launchpad.net/~michael.nelson/ca-configs/uwc-add-sca-import-logging-dict-config/+merge/182429

To post a comment you must log in.
Revision history for this message
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2013-02-28 16:23:58 +0000
3+++ .bzrignore 2013-08-27 15:27:42 +0000
4@@ -16,3 +16,4 @@
5 django_project/local.cfg
6 django_project/sreclient.py
7 oopses/
8+tmp/*
9
10=== modified file 'django_project/config/main.cfg'
11--- django_project/config/main.cfg 2013-04-26 14:24:42 +0000
12+++ django_project/config/main.cfg 2013-08-27 15:27:42 +0000
13@@ -79,23 +79,49 @@
14 handlers = django_logging_handlers
15 loggers = django_logging_loggers
16 root = django_logging_root
17+formatters = django_logging_formatters
18
19 [django_logging_root]
20 level = WARNING
21
22 [django_logging_loggers]
23 django = django_logger
24+webcatalog.management.commands.import_sca_apps = import_sca_logger
25
26 [django_logger]
27-handlers = null
28-level = WARNING
29+handlers = webapp
30+level = INFO
31
32 [django_logging_handlers]
33-null = django_null_logging_handler
34-
35-[django_null_logging_handler]
36-level = WARNING
37-class = django.utils.log.NullHandler
38+webapp = webapp_logging_handler
39+importer = import_sca_apps_handler
40+
41+[webapp_logging_handler]
42+class = logging.handlers.WatchedFileHandler
43+level = INFO
44+formatter = simple
45+filename = ./tmp/webapp.log
46+
47+[import_sca_apps_handler]
48+class = logging.handlers.WatchedFileHandler
49+level = INFO
50+formatter = simple_no_name
51+filename = ./tmp/import_sca_apps.log
52+
53+[import_sca_logger]
54+handlers = importer
55+propagate = false
56+level = INFO
57+
58+[django_logging_formatters]
59+simple = django_logging_simple_format
60+simple_no_name = django_logging_simple_no_name_format
61+
62+[django_logging_simple_format]
63+format = %%(asctime)s - %%(name)s - %%(levelname)s - %%(message)s
64+
65+[django_logging_simple_no_name_format]
66+format = %%(asctime)s - %%(levelname)s - %%(message)s
67
68 [openid]
69 openid_sso_server_url = https://login.staging.ubuntu.com
70
71=== modified file 'src/webcatalog/management/commands/import_exhibits.py'
72--- src/webcatalog/management/commands/import_exhibits.py 2012-08-20 15:34:18 +0000
73+++ src/webcatalog/management/commands/import_exhibits.py 2013-08-27 15:27:42 +0000
74@@ -81,4 +81,4 @@
75 # Unpublish other exhibits
76 Exhibit.objects.filter(published=True).exclude(
77 sca_id__in=[xibit['id'] for xibit in exhibits]).update(
78- published=False)
79+ published=False)
80
81=== modified file 'src/webcatalog/management/commands/import_sca_apps.py'
82--- src/webcatalog/management/commands/import_sca_apps.py 2012-08-21 13:57:11 +0000
83+++ src/webcatalog/management/commands/import_sca_apps.py 2013-08-27 15:27:42 +0000
84@@ -22,6 +22,7 @@
85 from __future__ import absolute_import
86
87 import json
88+import logging
89 import os
90 import urllib
91 from collections import defaultdict
92@@ -42,12 +43,15 @@
93 __all__ = []
94
95
96+logger = logging.getLogger(__name__)
97+
98+
99 class Command(BaseCommand):
100 help = "Import for-purchase applications from Software Center."
101- verbosity = 0
102
103 def handle(self, *args, **options):
104 url = '%sapplications/any/ubuntu/any/any/' % settings.SCA_API_URL
105+ logger.info("Starting import of sca apps at {0}".format(url))
106 # call api and get apps for purchase
107 response = urllib.urlopen(url)
108 if response.code != 200:
109@@ -55,8 +59,8 @@
110 app_list = json.loads(response.read())
111 imported_apps = Application.objects.filter(
112 imported_from_sca=True).values_list(
113- 'package_name',
114- 'distroseries__code_name')
115+ 'package_name',
116+ 'distroseries__code_name')
117 existing_apps = defaultdict(list)
118 for package_name, code_name in imported_apps:
119 existing_apps[package_name].append(code_name)
120@@ -71,7 +75,7 @@
121 distroseries, created = DistroSeries.objects.get_or_create(
122 code_name=series_name)
123 if created:
124- self.output(
125+ logger.info(
126 "Created a DistroSeries record called '{0}'.\n".format(
127 series_name), 1)
128 package_name = self.import_app_from_data(
129@@ -91,6 +95,7 @@
130 Application.objects.filter(
131 package_name=package_name,
132 distroseries__code_name__in=series).delete()
133+ logger.info("Finished import of {0} sca apps.".format(len(app_list)))
134
135 def import_app_from_data(self, app_data, icon_data, distroseries):
136 form = SCAApplicationForm.from_api_data(
137@@ -100,7 +105,6 @@
138 department_names = app_data.get('department', [])
139 app.update_departments(department_names)
140 self.add_icon_to_app(app, data=icon_data)
141- self.output(u"{0} created.\n".format(app.name).encode('utf-8'), 1)
142 return app.package_name
143
144 def get_icon_data(self, app_data):
145@@ -125,10 +129,3 @@
146 finally:
147 if os.path.exists(filename):
148 os.unlink(filename)
149-
150- def output(self, message, level=None, flush=False):
151- if hasattr(self, 'stdout'):
152- if level is None or self.verbosity >= level:
153- self.stdout.write(message)
154- if flush:
155- self.stdout.flush()
156
157=== modified file 'src/webcatalog/schema.py'
158--- src/webcatalog/schema.py 2013-04-09 13:26:31 +0000
159+++ src/webcatalog/schema.py 2013-08-27 15:27:42 +0000
160@@ -80,9 +80,6 @@
161 google_analytics_id = schema.StringOption()
162 secondary_google_analytics_id = schema.StringOption()
163
164- class logging(schema.Section):
165- webapp_logging_config = schema.StringOption()
166-
167 class preflight(schema.Section):
168 preflight_base_template = schema.StringOption(
169 default="webcatalog/base.html")
170
171=== modified file 'src/webcatalog/templatetags/webcatalog.py'
172--- src/webcatalog/templatetags/webcatalog.py 2013-02-22 21:02:05 +0000
173+++ src/webcatalog/templatetags/webcatalog.py 2013-08-27 15:27:42 +0000
174@@ -79,8 +79,8 @@
175 '{application_name} is also available for '
176 '<a href="{app_in_series_url}">your version of '
177 'Ubuntu</a>.').format(
178- application_name=escape(application.name),
179- app_in_series_url=app_in_series_url)
180+ application_name=escape(application.name),
181+ app_in_series_url=app_in_series_url)
182 context['message_text'] = mark_safe(
183 context['message_text'])
184 return context
185
186=== modified file 'src/webcatalog/wsgi.py'
187--- src/webcatalog/wsgi.py 2013-02-28 16:23:58 +0000
188+++ src/webcatalog/wsgi.py 2013-08-27 15:27:42 +0000
189@@ -17,12 +17,10 @@
190
191 """wsgi stack for the Apps Directory."""
192
193-import logging.config
194 import oops_dictconfig
195 import oops_wsgi
196 import oops_wsgi.django
197 import os
198-import platform
199 import uuid
200
201 from django.conf import settings
202@@ -64,12 +62,6 @@
203 if settings.SHOULD_SERVE_HTTPS:
204 os.environ['HTTPS'] = 'on'
205
206- default_id = ''.join(x for x in platform.node() if x.isalpha())
207- appserver_id = getattr(settings, 'APPSERVER_ID', default_id)
208- logging_config = settings.WEBAPP_LOGGING_CONFIG
209- if logging_config:
210- logging.config.fileConfig(logging_config)
211-
212 non_oops_app = EagerOOPSWSGIHandler()
213
214 config = oops_dictconfig.config_from_dict(settings.OOPSES)
215
216=== added directory 'tmp'

Subscribers

People subscribed via source and target branches