Skip to content

Commit

Permalink
bug 775631 - Revert "bug761650 - dailymatviews as crontabber apps, r=…
Browse files Browse the repository at this point in the history
…rhelmer"

This reverts commit 3d3ab45.
  • Loading branch information
rhelmer committed Jul 19, 2012
1 parent 35da8e3 commit 3443e54
Show file tree
Hide file tree
Showing 10 changed files with 246 additions and 233 deletions.
14 changes: 5 additions & 9 deletions config/crontabber.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
; 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/.

+include /etc/socorro/postgres.ini

# name: database
Expand All @@ -16,15 +20,6 @@ database_class=socorro.external.postgresql.connection_context.ConnectionContext
# converter: class_list_converter
jobs='''socorro.cron.jobs.weekly_reports_partitions.WeeklyReportsPartitionsCronApp|7d
socorro.cron.jobs.nightly_builds.NightlyBuildsCronApp|1d
socorro.cron.jobs.matviews.ProductVersionsCronApp|1d
socorro.cron.jobs.matviews.SignaturesCronApp|1d
socorro.cron.jobs.matviews.OSVersionsCronApp|1d
socorro.cron.jobs.matviews.TCBSCronApp|1d
socorro.cron.jobs.matviews.ADUCronApp|1d
socorro.cron.jobs.matviews.DailyCrashesCronApp|1d
socorro.cron.jobs.matviews.HangReportCronApp|1d
socorro.cron.jobs.matviews.RankCompareCronApp|1d
socorro.cron.jobs.matviews.NightlyBuildsCronApp|1d
'''

# name: stderr_error_logging_level
Expand Down Expand Up @@ -66,3 +61,4 @@ syslog_port=514
# doc: a class that will execute transactions
# converter: configman.converters.class_converter
transaction_executor_class=socorro.database.transaction_executor.TransactionExecutor

15 changes: 15 additions & 0 deletions scripts/crons/cron_daily_matviews.sh
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
43 changes: 43 additions & 0 deletions scripts/startDailyMatviews.py
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)
78 changes: 78 additions & 0 deletions socorro/cron/dailyMatviews.py
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)
87 changes: 0 additions & 87 deletions socorro/cron/jobs/matviews.py

This file was deleted.

Empty file.
56 changes: 0 additions & 56 deletions socorro/unittest/cron/jobs/base.py

This file was deleted.

80 changes: 0 additions & 80 deletions socorro/unittest/cron/jobs/test_matviews.py

This file was deleted.

Loading

0 comments on commit 3443e54

Please sign in to comment.