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