-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug 775631 - Revert "bug761650 - dailymatviews as crontabber apps, r=…
…rhelmer" This reverts commit 3d3ab45.
- Loading branch information
Showing
10 changed files
with
246 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
|
||
. /etc/socorro/socorrorc | ||
|
||
NAME=`basename $0 .sh` | ||
lock $NAME | ||
pyjob $NAME startDailyMatviews | ||
EXIT_CODE=$? | ||
unlock $NAME | ||
|
||
exit $EXIT_CODE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#! /usr/bin/env python | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
|
||
import sys | ||
import logging | ||
import logging.handlers | ||
from datetime import date, timedelta | ||
|
||
try: | ||
import config.dailyMatviewsConfig as configModule | ||
except ImportError: | ||
import dailyMatviewsConfig as configModule | ||
|
||
import socorro.lib.ConfigurationManager as configurationManager | ||
import socorro.cron.dailyMatviews as dailyMatviews | ||
import socorro.lib.util as sutil | ||
|
||
try: | ||
config = configurationManager.newConfiguration( | ||
configurationModule=configModule, applicationName="dailyMatviews 0.1") | ||
except configurationManager.NotAnOptionError, x: | ||
print >>sys.stderr, x | ||
print >>sys.stderr, "for usage, try --help" | ||
sys.exit() | ||
|
||
logger = logging.getLogger("dailyMatviews") | ||
logger.setLevel(logging.DEBUG) | ||
|
||
sutil.setupLoggingHandlers(logger, config) | ||
sutil.echoConfig(logger, config) | ||
|
||
exitCode = 255 | ||
|
||
try: | ||
targetDate = date.today() - timedelta(1) | ||
exitCode = dailyMatviews.update(config, targetDate) | ||
finally: | ||
logger.info("done.") | ||
|
||
sys.exit(exitCode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/usr/bin/env python | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
|
||
import sys | ||
import logging | ||
import datetime | ||
import psycopg2 | ||
|
||
from socorro.lib.datetimeutil import utc_now | ||
|
||
logger = logging.getLogger('dailyMatviews') | ||
logger.addHandler(logging.StreamHandler(sys.stderr)) | ||
|
||
|
||
def update(config, targetDate): | ||
functions = ( | ||
# function name, parmeters, dependencies | ||
('update_product_versions', [], []), | ||
('update_signatures', [targetDate], []), | ||
('update_os_versions', [targetDate], []), | ||
('update_tcbs', [targetDate], | ||
['update_product_versions', 'update_signatures', 'update_os_versions']), | ||
('update_adu', [targetDate], []), | ||
('update_daily_crashes', [targetDate], | ||
['update_product_versions' 'update_signatures']), | ||
('update_hang_report', [targetDate], []), | ||
('update_rank_compare', [targetDate], []), | ||
('update_nightly_builds', [targetDate], []), | ||
) | ||
|
||
failed = set() | ||
databaseDSN = "" | ||
if 'databaseHost' in config: | ||
databaseDSN += 'host=%(databaseHost)s ' | ||
if 'databaseName' in config: | ||
databaseDSN += 'dbname=%(databaseName)s ' | ||
if 'databaseUserName' in config: | ||
databaseDSN += 'user=%(databaseUserName)s ' | ||
if 'databasePassword' in config: | ||
databaseDSN += 'password=%(databasePassword)s' | ||
dsn = databaseDSN % config | ||
connection = psycopg2.connect(dsn) | ||
cursor = connection.cursor() | ||
for funcname, parameters, deps in functions: | ||
if set(deps) & failed: | ||
# one of the deps previously failed, so skip this one | ||
logger.warn("For %r, dependency %s failed so skipping" | ||
% (funcname, ', '.join(set(deps) & failed))) | ||
continue | ||
logger.info('Running %s' % funcname) | ||
failureMessage = None | ||
success = False | ||
try: | ||
cursor.callproc(funcname, parameters) | ||
# fetchone() returns a tuple of length 1 | ||
result = cursor.fetchone() | ||
if result and result[0]: | ||
success = True | ||
else: | ||
# "expected" error | ||
logger.warn('%r failed' % funcname) | ||
failureMessage = '%s did not return true' % funcname | ||
except psycopg2.InternalError: | ||
# unexpected error | ||
logger.error('%r failed' % funcname, exc_info=True) | ||
import sys # don't assume that this has been imported | ||
__, error_value = sys.exc_info()[:2] | ||
failureMessage = str(error_value) | ||
if success: | ||
connection.commit() | ||
else: | ||
connection.rollback() | ||
failed.add(funcname) | ||
|
||
return len(failed) |
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.