clearwing

changeset 214:71aa97f9cb47 1.2.3-genius

Changing headers to work with new auth api
author Stelios <stv@roe.ac.uk>
date Wed Jul 25 16:24:59 2018 +0300 (2018-07-25)
parents a436ab67f0d3
children 00afcf3149d3
files .hgignore src/config-sample.py src/freeform_sql/firethorn_helpers.py src/freeform_sql/misc.py src/url_classes/data_tables_processing.py src/url_classes/dbaccess_LEGACY_form.py src/url_classes/dbaccess_SQL_form.py
line diff
     1.1 --- a/.hgignore	Thu Mar 02 17:39:37 2017 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,11 +0,0 @@
     1.4 -syntax: glob
     1.5 -
     1.6 -# Text editor backups
     1.7 -*~
     1.8 -*.*~
     1.9 -
    1.10 -# Python code.
    1.11 -*.pyc
    1.12 -
    1.13 -/src/templates/schema_browser/*
    1.14 -
     2.1 --- a/src/config-sample.py	Thu Mar 02 17:39:37 2017 +0000
     2.2 +++ b/src/config-sample.py	Wed Jul 25 16:24:59 2018 +0300
     2.3 @@ -116,3 +116,8 @@
     2.4  
     2.5  db_to_tap_map = {SURVEY_DB :SURVEY_TAP, '###' :'####'}
     2.6  taps_using_binary = ["http://dc.zah.uni-heidelberg.de"]
     2.7 +
     2.8 +firethorn_admin_username=""
     2.9 +firethorn_admin_password=""
    2.10 +firethorn_admin_community=""
    2.11 +
     3.1 --- a/src/freeform_sql/firethorn_helpers.py	Thu Mar 02 17:39:37 2017 +0000
     3.2 +++ b/src/freeform_sql/firethorn_helpers.py	Wed Jul 25 16:24:59 2018 +0300
     3.3 @@ -19,7 +19,7 @@
     3.4  
     3.5  def generate_available_list_from_workspace(log_info, workspace,add_catalogue_html,exclude_schema,exclude_schema_name,session):
     3.6  
     3.7 -    req = urllib2.Request( workspace + firethorn_config.type_select_uris["schemas"], headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : session.get("community_input","public (unknown)")})
     3.8 +    req = urllib2.Request( workspace + firethorn_config.type_select_uris["schemas"], headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password})
     3.9      response = urllib2.urlopen(req)
    3.10      workspace_schema_list = json.loads(response.read())
    3.11      response.close()
    3.12 @@ -64,7 +64,7 @@
    3.13          ### Create workspace
    3.14          workspace_name = 'workspace-' + t.strftime("%y%m%d_%H%M%S")
    3.15          data = urllib.urlencode({firethorn_config.resource_create_name_params['http://data.metagrid.co.uk/wfau/firethorn/types/entity/adql-resource-1.0.json'] : workspace_name})
    3.16 -        req = urllib2.Request( firethorn_config.workspace_creator, data, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : session.get("community_input","public (unknown)")})
    3.17 +        req = urllib2.Request( firethorn_config.workspace_creator, data, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password})
    3.18  
    3.19          response = urllib2.urlopen(req)
    3.20          js = json.loads(response.read())
    3.21 @@ -77,7 +77,7 @@
    3.22      try:
    3.23          ### Create Query Schema
    3.24          data = urllib.urlencode({firethorn_config.resource_create_name_params['http://data.metagrid.co.uk/wfau/firethorn/types/entity/adql-schema-1.0.json'] : "query_schema"})
    3.25 -        req = urllib2.Request( workspace +  firethorn_config.schema_create_uri, data, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : session.get("community_input","public (unknown)")})
    3.26 +        req = urllib2.Request( workspace +  firethorn_config.schema_create_uri, data, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password})
    3.27          response = urllib2.urlopen(req)
    3.28          query_schema = json.loads(response.read())["ident"]
    3.29          response.close()
    3.30 @@ -99,7 +99,7 @@
    3.31          if importname!="":
    3.32              data = urllib.urlencode({'urn:adql.copy.depth' : "THIN", firethorn_config.workspace_import_schema_base : ident, firethorn_config.workspace_import_schema_name : importname})
    3.33  
    3.34 -        req = urllib2.Request( workspace + firethorn_config.workspace_import_uri, data, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : session.get("community_input","public (unknown)")})
    3.35 +        req = urllib2.Request( workspace + firethorn_config.workspace_import_uri, data, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password})
    3.36          response = urllib2.urlopen(req)
    3.37      except Exception as e:
    3.38          logging.exception("Error importing catalogue")
    3.39 @@ -227,7 +227,7 @@
    3.40  
    3.41      try:
    3.42  
    3.43 -        req = urllib2.Request( resource, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : session.get("community_input","public (unknown)")})
    3.44 +        req = urllib2.Request( resource, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password})
    3.45          response = urllib2.urlopen(req)
    3.46          workspace = json.loads(response.read())["parent"]
    3.47          response.close()
     4.1 --- a/src/freeform_sql/misc.py	Thu Mar 02 17:39:37 2017 +0000
     4.2 +++ b/src/freeform_sql/misc.py	Wed Jul 25 16:24:59 2018 +0300
     4.3 @@ -184,14 +184,14 @@
     4.4          ### Create workspace
     4.5          workspace_name = 'workspace-' + t.strftime("%y%m%d_%H%M%S") 
     4.6          data = urllib.urlencode({firethorn_config.resource_create_name_params['http://data.metagrid.co.uk/wfau/firethorn/types/entity/adql-resource-1.0.json'] : workspace_name})
     4.7 -        req = urllib2.Request( firethorn_config.workspace_creator, data, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : session.get("community_input","public (unknown)")})
     4.8 +        req = urllib2.Request( firethorn_config.workspace_creator, data, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password})
     4.9          response = urllib2.urlopen(req)
    4.10          workspace = json.loads(response.read())["ident"]
    4.11          response.close()
    4.12          
    4.13          ### Create Query Schema 
    4.14          data = urllib.urlencode({firethorn_config.resource_create_name_params['http://data.metagrid.co.uk/wfau/firethorn/types/entity/adql-schema-1.0.json'] : "query_schema"})
    4.15 -        req = urllib2.Request( workspace +  firethorn_config.schema_create_uri, data, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : session.get("community_input","public (unknown)")})
    4.16 +        req = urllib2.Request( workspace +  firethorn_config.schema_create_uri, data, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password})
    4.17          response = urllib2.urlopen(req) 
    4.18          query_schema = json.loads(response.read())["ident"]
    4.19          response.close()
    4.20 @@ -215,7 +215,7 @@
    4.21                  data = urllib.urlencode({'urn:adql.copy.depth' : "THIN", firethorn_config.workspace_import_schema_base : ident})
    4.22              
    4.23            
    4.24 -            req = urllib2.Request( workspace + firethorn_config.workspace_import_uri, data, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : session.get("community_input","public (unknown)")}) 
    4.25 +            req = urllib2.Request( workspace + firethorn_config.workspace_import_uri, data, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password}) 
    4.26              response = urllib2.urlopen(req)
    4.27              response.close()
    4.28              
    4.29 @@ -386,7 +386,7 @@
    4.30      """
    4.31      
    4.32      def get_status(url):
    4.33 -        request2 = urllib2.Request(url, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : session.get("community_input","public (unknown)")})
    4.34 +        request2 = urllib2.Request(url, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password})
    4.35          f_read = urllib2.urlopen(request2)
    4.36          query_json = f_read.read()
    4.37          return query_json
    4.38 @@ -406,7 +406,7 @@
    4.39          data = urllib.urlencode({ firethorn_config.query_status_update : "COMPLETED", "adql.query.wait.time" : 60000})
    4.40          
    4.41          #data = urllib.urlencode({ firethorn_config.query_status_update : "RUNNING", 'adql.query.delay.every' : '10000', 'adql.query.delay.first':'10000', 'adql.query.delay.last':'10000'})
    4.42 -        request = urllib2.Request(url, data, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : session.get("community_input","public (unknown)")})
    4.43 +        request = urllib2.Request(url, data, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password})
    4.44  
    4.45  
    4.46          f_update = urllib2.urlopen(request)
    4.47 @@ -697,7 +697,7 @@
    4.48  
    4.49          urlenc = { firethorn_config.query_name_param : query_name,  firethorn_config.query_param : query}
    4.50          data = urllib.urlencode(urlenc)
    4.51 -        request = urllib2.Request(query_space + firethorn_config.query_create_uri, data, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : session.get("community_input","public (unknown)")})
    4.52 +        request = urllib2.Request(query_space + firethorn_config.query_create_uri, data, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password})
    4.53  
    4.54          f = urllib2.urlopen(request)
    4.55          query_create_result = json.loads(f.read())
    4.56 @@ -715,7 +715,7 @@
    4.57          if results_adql_url!=None:
    4.58                 
    4.59              try :
    4.60 -                req_rez_table = urllib2.Request( results_adql_url, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : session.get("community_input","public (unknown)")})
    4.61 +                req_rez_table = urllib2.Request( results_adql_url, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password})
    4.62                  response_rez_table = urllib2.urlopen(req_rez_table) 
    4.63                  response_rez_table_json = response_rez_table.read()
    4.64                  result_adql_table = json.loads(response_rez_table_json)["fullname"]
    4.65 @@ -1256,7 +1256,7 @@
    4.66      Get the parent workspace of a schema
    4.67      """
    4.68      
    4.69 -    req = urllib2.Request( schema, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : session.get("community_input","public (unknown)")} )
    4.70 +    req = urllib2.Request( schema, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password} )
    4.71      response = urllib2.urlopen(req)
    4.72      workspace = json.loads(response.read())["parent"]
    4.73      response.close()
    4.74 @@ -1268,7 +1268,7 @@
    4.75      Get the parent workspace of a schema
    4.76      """
    4.77      
    4.78 -    req = urllib2.Request( obj, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : session.get("community_input","public (unknown)")} )
    4.79 +    req = urllib2.Request( obj, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password} )
    4.80      response = urllib2.urlopen(req)
    4.81      info = json.loads(response.read())
    4.82      response.close()
     5.1 --- a/src/url_classes/data_tables_processing.py	Thu Mar 02 17:39:37 2017 +0000
     5.2 +++ b/src/url_classes/data_tables_processing.py	Wed Jul 25 16:24:59 2018 +0300
     5.3 @@ -1029,7 +1029,7 @@
     5.4              web.header('Content-Type', 'multipart/form-data')
     5.5              if save_as=='vo':
     5.6                  query = firethorn_base  + '/blue/query/' + queryid
     5.7 -                request = urllib2.Request(query, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : session.get("community_input","public (unknown)")} )
     5.8 +                request = urllib2.Request(query, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password} )
     5.9                  f = urllib2.urlopen(request)
    5.10                  query_json = json.loads(f.read())
    5.11                  queryvotable = query_json["results"]["formats"]["votable"]
     6.1 --- a/src/url_classes/dbaccess_LEGACY_form.py	Thu Mar 02 17:39:37 2017 +0000
     6.2 +++ b/src/url_classes/dbaccess_LEGACY_form.py	Wed Jul 25 16:24:59 2018 +0300
     6.3 @@ -69,7 +69,7 @@
     6.4                  exclude_schema_alias =  config.PRIVATE_SURVEY_DB 
     6.5                  atlasschema = atlasprivate
     6.6              try :
     6.7 -                req_exc = urllib2.Request( atlasschema, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : session.get("community_input","public (unknown)")})
     6.8 +                req_exc = urllib2.Request( atlasschema, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password})
     6.9                  response_exc = urllib2.urlopen(req_exc) 
    6.10                  response_exc_json = response_exc.read()
    6.11                  exclude_schema_name = json.loads(response_exc_json)["fullname"]
    6.12 @@ -149,7 +149,7 @@
    6.13                          exclude_schema_alias =  config.PRIVATE_SURVEY_DB 
    6.14                          atlasschema = atlasprivate   
    6.15                      try :
    6.16 -                        req_exc = urllib2.Request( atlasschema, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : session.get("community_input","public (unknown)")})
    6.17 +                        req_exc = urllib2.Request( atlasschema, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password})
    6.18                          response_exc = urllib2.urlopen(req_exc) 
    6.19                          response_exc_json = response_exc.read()
    6.20                          exclude_schema_name = json.loads(response_exc_json)["fullname"]
     7.1 --- a/src/url_classes/dbaccess_SQL_form.py	Thu Mar 02 17:39:37 2017 +0000
     7.2 +++ b/src/url_classes/dbaccess_SQL_form.py	Wed Jul 25 16:24:59 2018 +0300
     7.3 @@ -68,7 +68,7 @@
     7.4                  exclude_schema_alias =  config.PRIVATE_SURVEY_DB 
     7.5                  atlasschema = atlasprivate
     7.6              try :
     7.7 -                req_exc = urllib2.Request( atlasschema, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : session.get("community_input","public (unknown)")})
     7.8 +                req_exc = urllib2.Request( atlasschema, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password})
     7.9                  response_exc = urllib2.urlopen(req_exc) 
    7.10                  response_exc_json = response_exc.read()
    7.11                  exclude_schema_name = json.loads(response_exc_json)["fullname"]
    7.12 @@ -142,7 +142,7 @@
    7.13                          exclude_schema_alias =  config.PRIVATE_SURVEY_DB 
    7.14                          atlasschema = atlasprivate   
    7.15                      try :
    7.16 -                        req_exc = urllib2.Request( atlasschema, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : session.get("community_input","public (unknown)")})
    7.17 +                        req_exc = urllib2.Request( atlasschema, headers={"Accept" : "application/json", "firethorn.auth.identity" : session.get("email","unknown user"), "firethorn.auth.community" : config.firethorn_admin_community, "firethorn.auth.username" : config.firethorn_admin_username, "firethorn.auth.password" : config.firethorn_admin_password})
    7.18                          response_exc = urllib2.urlopen(req_exc) 
    7.19                          response_exc_json = response_exc.read()
    7.20                          exclude_schema_name = json.loads(response_exc_json)["fullname"]