From ec56c5c5118495d0039d3b8bae49708f12cc2299 Mon Sep 17 00:00:00 2001 From: Jonathan Eads Date: Fri, 31 Jan 2014 18:25:34 -0800 Subject: [PATCH] command to export oauth credentials --- .../commands/export_project_credentials.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 treeherder/etl/management/commands/export_project_credentials.py diff --git a/treeherder/etl/management/commands/export_project_credentials.py b/treeherder/etl/management/commands/export_project_credentials.py new file mode 100644 index 000000000..bcd13c7b9 --- /dev/null +++ b/treeherder/etl/management/commands/export_project_credentials.py @@ -0,0 +1,30 @@ +import os +import json + +from django.core.management.base import BaseCommand + +from treeherder.model.models import Datasource +from treeherder.model.derived.base import TreeherderModelBase +from treeherder.etl import buildapi + + +class Command(BaseCommand): + """Management command to run mozilla pulse consumer.""" + + help = ( + "Exports the objectstore Oauth keys for etl data import tasks" + ) + + def handle(self, *args, **options): + + immutable_credentials = TreeherderModelBase.get_oauth_credentials() + + file_path = os.path.join( + os.path.dirname(os.path.dirname(os.path.dirname(__file__))), + 'data', + 'credentials.json' + ) + + keys_fh = open(file_path, 'w') + keys_fh.write(json.dumps(immutable_credentials)) + keys_fh.close()