{"action":"created","comment":{"url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/pulls/comments/55214921","id":55214921,"diff_hunk":"@@ -1,52 +1,67 @@\n import os\n+import sys\n import inspect\n+import traceback\n+import json\n from flask.ext.cors import CORS\n+from flask.ext.bcrypt import Bcrypt\n from flask import Flask\n-import json\n+from dataactcore.utils.cloudLogger import CloudLogger\n from dataactcore.utils.jsonResponse import JsonResponse\n+from dataactbroker.handlers.aws.sesEmail import sesEmail\n+from dataactbroker.handlers.accountHandler import AccountHandler\n from dataactbroker.handlers.aws.session import DynamoInterface, SessionTable\n from dataactbroker.fileRoutes import add_file_routes\n from dataactbroker.loginRoutes import add_login_routes\n+from dataactbroker.userRoutes import add_user_routes\n \n def runApp():\n-    \"\"\"Set up the Application\"\"\"\n-    def getAppConfiguration() :\n-        \"\"\"gets the web_api_configuration JSON\"\"\"\n-        path = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))\n-        configFile = path + \"/web_api_configuration.json\"\n-        return json.loads(open(configFile,\"r\").read())\n+    try :\n+        \"\"\"Set up the Application\"\"\"\n+        # Create application\n+        config_path = \"\".join([os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))),\"/config\"])\n+        app = Flask(__name__,instance_path=config_path)\n \n-    config = getAppConfiguration()\n-    # Set parameters\n-    debugFlag = config[\"server_debug\"]  # Should be false for prod\n-    runLocal = config[\"local_dynamo\"]  # False for prod, when True this assumes that the Dynamo is on the same server\n-    JsonResponse.debugMode = config[\"rest_trace\"]\n-     #Allows for real Credentials to be created for S3 uploads\n-    # Get the project's root folder\n-    PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))\n+        def getAppConfiguration() :\n+            \"\"\"gets the web_api_configuration JSON\"\"\"\n+            configFile = \"\".join([app.instance_path, \"/web_api_configuration.json\"])\n+            return json.loads(open(configFile,\"r\").read())\n \n-    # Create application\n-    app = Flask(__name__)\n-    app.config.from_object(__name__)\n-    if(config[\"origins\"] ==  \"*\"):\n-        cors = CORS(app,supports_credentials=True)\n-    else:\n-        cors = CORS(app,supports_credentials=True,origins=config[\"origins\"])\n-    #Enable AWS Sessions\n-    app.session_interface = DynamoInterface()\n+        config = getAppConfiguration()\n+        # Set parameters\n+        AccountHandler.FRONT_END = config[\"frontend_url\"]\n+        sesEmail.SIGNING_KEY =  config[\"security_key\"]\n+        debugFlag = config[\"server_debug\"]  # Should be false for prod\n+        runLocal = config[\"local_dynamo\"]  # False for prod, when True this assumes that the Dynamo is on the same server\n+        JsonResponse.debugMode = config[\"rest_trace\"]\n \n-    # Root will point to index.html\n-    @app.route(\"/\", methods=[\"GET\"])\n-    def root():\n-        return \"Broker is running\"\n+        app.config.from_object(__name__)\n \n+        if(config[\"origins\"] ==  \"*\"):\n+            cors = CORS(app,supports_credentials=True)\n+        else:\n+            cors = CORS(app,supports_credentials=True,origins=config[\"origins\"])\n+        #Enable AWS Sessions\n+        app.session_interface = DynamoInterface()\n+        # Set up bcrypt\n+        bcrypt = Bcrypt(app)\n+        # Root will point to index.html\n+        @app.route(\"/\", methods=[\"GET\"])\n+        def root():\n+            return \"Broker is running\"\n \n-    # Add routes for modules here\n-    add_login_routes(app)\n-    add_file_routes(app,config[\"create_credentials\"])\n-    SessionTable.localPort  = int( config[\"dynamo_port\"])\n-    SessionTable.setup(app, runLocal)\n-    app.run(debug=debugFlag,threaded=True,host=\"0.0.0.0\",port= int(config[\"port\"]))\n \n+        # Add routes for modules here\n+        add_login_routes(app,bcrypt)\n+        add_file_routes(app,config[\"create_credentials\"])\n+        add_user_routes(app,config[\"system_email\"],bcrypt)\n+        SessionTable.localPort  = int( config[\"dynamo_port\"])\n+        SessionTable.setup(app, runLocal)\n+        app.run(debug=debugFlag,threaded=True,host=\"0.0.0.0\",port= int(config[\"port\"]))\n+    except Exception as e:\n+        exc_type, exc_obj, exc_tb = sys.exc_info()\n+        trace = traceback.extract_tb(exc_tb, 10)\n+        CloudLogger.logError('Broker App Level Error: ',e,trace)\n+        del exc_tb","path":"dataactbroker/app.py","position":99,"original_position":99,"commit_id":"c64ac7da1ced47305a600ae6678ab0e9040b8232","original_commit_id":"65eff67f29b734d7b2e4230d538cc58a16e3505d","user":{"login":"jworcestBAH","id":11858333,"avatar_url":"https://avatars.githubusercontent.com/u/11858333?v=3","gravatar_id":"","url":"https://api.github.com/users/jworcestBAH","html_url":"https://github.com/jworcestBAH","followers_url":"https://api.github.com/users/jworcestBAH/followers","following_url":"https://api.github.com/users/jworcestBAH/following{/other_user}","gists_url":"https://api.github.com/users/jworcestBAH/gists{/gist_id}","starred_url":"https://api.github.com/users/jworcestBAH/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jworcestBAH/subscriptions","organizations_url":"https://api.github.com/users/jworcestBAH/orgs","repos_url":"https://api.github.com/users/jworcestBAH/repos","events_url":"https://api.github.com/users/jworcestBAH/events{/privacy}","received_events_url":"https://api.github.com/users/jworcestBAH/received_events","type":"User","site_admin":false},"body":"There are cautions on stackoverflow about setting the traceback to a local variable, it can cause a circular reference that interferes with garbage collection, so it is recommended to delete it manually after use.  See https://docs.python.org/2/library/sys.html#sys.exc_info for more info on this.","created_at":"2016-03-07T15:04:04Z","updated_at":"2016-03-07T15:04:04Z","html_url":"https://github.com/fedspendingtransparency/data-act-broker/pull/3#discussion_r55214921","pull_request_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/pulls/comments/55214921"},"html":{"href":"https://github.com/fedspendingtransparency/data-act-broker/pull/3#discussion_r55214921"},"pull_request":{"href":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/pulls/3","id":61460440,"html_url":"https://github.com/fedspendingtransparency/data-act-broker/pull/3","diff_url":"https://github.com/fedspendingtransparency/data-act-broker/pull/3.diff","patch_url":"https://github.com/fedspendingtransparency/data-act-broker/pull/3.patch","issue_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/issues/3","number":3,"state":"open","locked":false,"title":"User account feature","user":{"login":"jworcestBAH","id":11858333,"avatar_url":"https://avatars.githubusercontent.com/u/11858333?v=3","gravatar_id":"","url":"https://api.github.com/users/jworcestBAH","html_url":"https://github.com/jworcestBAH","followers_url":"https://api.github.com/users/jworcestBAH/followers","following_url":"https://api.github.com/users/jworcestBAH/following{/other_user}","gists_url":"https://api.github.com/users/jworcestBAH/gists{/gist_id}","starred_url":"https://api.github.com/users/jworcestBAH/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jworcestBAH/subscriptions","organizations_url":"https://api.github.com/users/jworcestBAH/orgs","repos_url":"https://api.github.com/users/jworcestBAH/repos","events_url":"https://api.github.com/users/jworcestBAH/events{/privacy}","received_events_url":"https://api.github.com/users/jworcestBAH/received_events","type":"User","site_admin":false},"body":"Sprint 7 features, primarily focused on user accounts","created_at":"2016-03-02T20:18:46Z","updated_at":"2016-03-07T15:04:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"155fb02b713c1026707054a2b0e68765802def75","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/pulls/3/commits","review_comments_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/pulls/3/comments","review_comment_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/issues/3/comments","statuses_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/statuses/c64ac7da1ced47305a600ae6678ab0e9040b8232","head":{"label":"fedspendingtransparency:user_account_feature","ref":"user_account_feature","sha":"c64ac7da1ced47305a600ae6678ab0e9040b8232","user":{"login":"fedspendingtransparency","id":8397762,"avatar_url":"https://avatars.githubusercontent.com/u/8397762?v=3","gravatar_id":"","url":"https://api.github.com/users/fedspendingtransparency","html_url":"https://github.com/fedspendingtransparency","followers_url":"https://api.github.com/users/fedspendingtransparency/followers","following_url":"https://api.github.com/users/fedspendingtransparency/following{/other_user}","gists_url":"https://api.github.com/users/fedspendingtransparency/gists{/gist_id}","starred_url":"https://api.github.com/users/fedspendingtransparency/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fedspendingtransparency/subscriptions","organizations_url":"https://api.github.com/users/fedspendingtransparency/orgs","repos_url":"https://api.github.com/users/fedspendingtransparency/repos","events_url":"https://api.github.com/users/fedspendingtransparency/events{/privacy}","received_events_url":"https://api.github.com/users/fedspendingtransparency/received_events","type":"Organization","site_admin":false},"repo":{"id":47127389,"name":"data-act-broker","full_name":"fedspendingtransparency/data-act-broker","owner":{"login":"fedspendingtransparency","id":8397762,"avatar_url":"https://avatars.githubusercontent.com/u/8397762?v=3","gravatar_id":"","url":"https://api.github.com/users/fedspendingtransparency","html_url":"https://github.com/fedspendingtransparency","followers_url":"https://api.github.com/users/fedspendingtransparency/followers","following_url":"https://api.github.com/users/fedspendingtransparency/following{/other_user}","gists_url":"https://api.github.com/users/fedspendingtransparency/gists{/gist_id}","starred_url":"https://api.github.com/users/fedspendingtransparency/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fedspendingtransparency/subscriptions","organizations_url":"https://api.github.com/users/fedspendingtransparency/orgs","repos_url":"https://api.github.com/users/fedspendingtransparency/repos","events_url":"https://api.github.com/users/fedspendingtransparency/events{/privacy}","received_events_url":"https://api.github.com/users/fedspendingtransparency/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fedspendingtransparency/data-act-broker","description":"","fork":false,"url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker","forks_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/forks","keys_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/teams","hooks_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/hooks","issue_events_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/issues/events{/number}","events_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/events","assignees_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/assignees{/user}","branches_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/branches{/branch}","tags_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/tags","blobs_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/git/refs{/sha}","trees_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/statuses/{sha}","languages_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/languages","stargazers_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/stargazers","contributors_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/contributors","subscribers_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/subscribers","subscription_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/subscription","commits_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/commits{/sha}","git_commits_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/git/commits{/sha}","comments_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/comments{/number}","issue_comment_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/issues/comments{/number}","contents_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/contents/{+path}","compare_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/merges","archive_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/downloads","issues_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/issues{/number}","pulls_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/pulls{/number}","milestones_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/milestones{/number}","notifications_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/labels{/name}","releases_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/releases{/id}","deployments_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/deployments","created_at":"2015-11-30T15:21:57Z","updated_at":"2016-03-02T15:55:37Z","pushed_at":"2016-03-04T20:43:17Z","git_url":"git://github.com/fedspendingtransparency/data-act-broker.git","ssh_url":"git@github.com:fedspendingtransparency/data-act-broker.git","clone_url":"https://github.com/fedspendingtransparency/data-act-broker.git","svn_url":"https://github.com/fedspendingtransparency/data-act-broker","homepage":null,"size":267,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"fedspendingtransparency:dev","ref":"dev","sha":"51a667ebf9dd1009f90db3d3ad46a03d8f931273","user":{"login":"fedspendingtransparency","id":8397762,"avatar_url":"https://avatars.githubusercontent.com/u/8397762?v=3","gravatar_id":"","url":"https://api.github.com/users/fedspendingtransparency","html_url":"https://github.com/fedspendingtransparency","followers_url":"https://api.github.com/users/fedspendingtransparency/followers","following_url":"https://api.github.com/users/fedspendingtransparency/following{/other_user}","gists_url":"https://api.github.com/users/fedspendingtransparency/gists{/gist_id}","starred_url":"https://api.github.com/users/fedspendingtransparency/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fedspendingtransparency/subscriptions","organizations_url":"https://api.github.com/users/fedspendingtransparency/orgs","repos_url":"https://api.github.com/users/fedspendingtransparency/repos","events_url":"https://api.github.com/users/fedspendingtransparency/events{/privacy}","received_events_url":"https://api.github.com/users/fedspendingtransparency/received_events","type":"Organization","site_admin":false},"repo":{"id":47127389,"name":"data-act-broker","full_name":"fedspendingtransparency/data-act-broker","owner":{"login":"fedspendingtransparency","id":8397762,"avatar_url":"https://avatars.githubusercontent.com/u/8397762?v=3","gravatar_id":"","url":"https://api.github.com/users/fedspendingtransparency","html_url":"https://github.com/fedspendingtransparency","followers_url":"https://api.github.com/users/fedspendingtransparency/followers","following_url":"https://api.github.com/users/fedspendingtransparency/following{/other_user}","gists_url":"https://api.github.com/users/fedspendingtransparency/gists{/gist_id}","starred_url":"https://api.github.com/users/fedspendingtransparency/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fedspendingtransparency/subscriptions","organizations_url":"https://api.github.com/users/fedspendingtransparency/orgs","repos_url":"https://api.github.com/users/fedspendingtransparency/repos","events_url":"https://api.github.com/users/fedspendingtransparency/events{/privacy}","received_events_url":"https://api.github.com/users/fedspendingtransparency/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fedspendingtransparency/data-act-broker","description":"","fork":false,"url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker","forks_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/forks","keys_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/teams","hooks_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/hooks","issue_events_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/issues/events{/number}","events_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/events","assignees_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/assignees{/user}","branches_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/branches{/branch}","tags_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/tags","blobs_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/git/refs{/sha}","trees_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/statuses/{sha}","languages_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/languages","stargazers_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/stargazers","contributors_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/contributors","subscribers_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/subscribers","subscription_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/subscription","commits_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/commits{/sha}","git_commits_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/git/commits{/sha}","comments_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/comments{/number}","issue_comment_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/issues/comments{/number}","contents_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/contents/{+path}","compare_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/merges","archive_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/downloads","issues_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/issues{/number}","pulls_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/pulls{/number}","milestones_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/milestones{/number}","notifications_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/labels{/name}","releases_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/releases{/id}","deployments_url":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/deployments","created_at":"2015-11-30T15:21:57Z","updated_at":"2016-03-02T15:55:37Z","pushed_at":"2016-03-04T20:43:17Z","git_url":"git://github.com/fedspendingtransparency/data-act-broker.git","ssh_url":"git@github.com:fedspendingtransparency/data-act-broker.git","clone_url":"https://github.com/fedspendingtransparency/data-act-broker.git","svn_url":"https://github.com/fedspendingtransparency/data-act-broker","homepage":null,"size":267,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/pulls/3"},"html":{"href":"https://github.com/fedspendingtransparency/data-act-broker/pull/3"},"issue":{"href":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/issues/3"},"comments":{"href":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/fedspendingtransparency/data-act-broker/statuses/c64ac7da1ced47305a600ae6678ab0e9040b8232"}}}}