forked from mozilla-services/socorro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug 860090 add a fake adu generation script
- Loading branch information
1 parent
0d44bb6
commit 29a8828
Showing
1 changed file
with
30 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/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 os | ||
from os.path import join, getsize | ||
import sys | ||
import psycopg2 | ||
import psycopg2.extensions | ||
import psycopg2.extras | ||
|
||
#connect to CSD database | ||
csd = psycopg2.connect("dbname=breakpad user=postgres port=5432") | ||
csd_cur = csd.cursor() | ||
# check if we already have ADU for the day | ||
csd_cur.execute("""SELECT COUNT(*) FROM raw_adu WHERE "date" = 'yesterday'::date""") | ||
|
||
if csd_cur.fetchone()[0] > 0: | ||
sys.stderr.write('raw_adu has already been exported for yesterday\n') | ||
sys.exit(-1) | ||
|
||
#dump raw_adu to file | ||
csd_cur.execute("""INSERT into raw_adu (select adu_count, 'yesterday'::date as "date", product_name, product_os_platform, product_os_version, product_version, build, build_channel, product_guid from raw_adu where date in (select max(date) from raw_adu) ) ;""") | ||
csd.commit() | ||
csd.close() | ||
|
||
print 'raw_adu successfully updated' | ||
|
||
sys.exit(0) |