Fix run_query() use of args by adding arguments

run_query() was copied from elsewhere and relied on args being
available to get the token and proxy config. Those are now passed as
function arguments.
master
Lertsenem 2020-07-07 16:11:51 +02:00
parent e58ba0a3b3
commit ba7843e3f5
1 changed files with 7 additions and 3 deletions

View File

@ -203,16 +203,20 @@ numEntrants: {nbe}""" \
name = self.name, name = self.name,
date = self.startAt, date = self.startAt,
loc = self.venueName, loc = self.venueName,
addr = self.venueAddress,
city = self.city,
ctry = self.countryCode,
slug = self.slug, slug = self.slug,
nbe = self.numEntrants, nbe = self.numEntrants,
) )
# ============================================================================= # =============================================================================
def run_query( def run_query(
query_name, query_name,
variables = {}, variables = {},
token = "",
proxy = None,
query_dir = "queries", query_dir = "queries",
query_extension = "gql", query_extension = "gql",
api_url = API_URL, api_url = API_URL,
@ -240,7 +244,7 @@ def run_query(
# Build headers # Build headers
headers = { headers = {
"Authorization": "Bearer {token}".format(token = args.token), "Authorization": "Bearer {token}".format(token = token),
"Accept": "application/json", "Accept": "application/json",
"Content-Type": "application/json" "Content-Type": "application/json"
} }
@ -256,7 +260,7 @@ def run_query(
API_URL, API_URL,
json.dumps(payload).encode("utf-8"), json.dumps(payload).encode("utf-8"),
headers = headers, headers = headers,
proxies = {"http": args.proxy, "https": args.proxy}, proxies = {"http": proxy, "https": proxy},
) )
try: try: