Skip to content

Commit

Permalink
f strings are back. Now running in python 3.7-stretch
Browse files Browse the repository at this point in the history
  • Loading branch information
jffrancob committed Mar 29, 2022
1 parent e65f065 commit 415c610
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion fastagi/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Building stage
FROM python:3.5
FROM python:3.7-stretch

# copy the dependencies file to the working directory
COPY requirements.txt .
Expand Down
24 changes: 13 additions & 11 deletions fastagi/src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def __init__(self, *args, **kwargs):
self.user = {}
self.status = None

logger.info(f"{self.config}")

if not self.http_client:
self.http_client = aiohttp.ClientSession()

Expand All @@ -73,8 +75,8 @@ async def start(self):
)
id_field = self.config["idn"]["field"]
self.user[id_field] = id_number
logger.info("ID Number: %s" % id_number)
logger.info('Request: %s' % self.config["request"])
logger.info(f"ID Number: {id_number}")
logger.info(f'Request: {self.config["request"]}')

http_request = self.config["request"]["url"]
if http_request and id_number:
Expand All @@ -86,8 +88,8 @@ async def start(self):
else:
user_info = {}

logger.info("User: %s" % self.user)
logger.info("ID Number: %s" % user_info)
logger.info(f"User: {self.user}")
logger.info(f"ID Number: {user_info}")
if user_info:
self.user.update(user_info)

Expand All @@ -98,7 +100,7 @@ async def start(self):
await self.set_custom_vars()

async def choose_option(self, audioPrompt, optionList=['1', '2', '*'], tries=3):
logger.info("Starting choose_option with %s" % audioPrompt)
logger.info(f"Starting choose_option with {audioPrompt}")
sounds = self.config["sounds"]["choose-option"]
attemps = 0
while not tries or attemps < tries:
Expand All @@ -122,7 +124,7 @@ async def choose_option(self, audioPrompt, optionList=['1', '2', '*'], tries=3):

async def get_information(self, regExp, sounds, func_slide=None, tries=3,
confirm=3, timeout=2500, max_digits=255, cancel=None,
optionList=["1", "0", "*"]):
optionList=["1", "2", "*"]):
attemps = 0
try_again = False
while tries is None or attemps < tries:
Expand Down Expand Up @@ -196,25 +198,25 @@ async def http_request(self, url, method="GET", params=None, auth_data=None,
if timeout:
timeout = aiohttp.ClientTimeout(total=timeout)

logger.debug("%s, %s" % (url, params))
logger.debug(f"{url}, {params}")
async with self.http_client.request(method, url,
auth=auth,
params=params,
json=json_data,
headers=headers,
timeout=timeout
) as resp:
logger.debug("Response: %s" % resp)
logger.debug(f"Response: {resp}")
if json_result:
try:
response = await resp.json(content_type=None)
except Exception as error:
logger.error("Something failed trying to convert result into json: %s" % error)
logger.error(f"Something failed trying to convert result into json: {error}")
response = await resp.text()
else:
response = await resp.text()

logger.info("Response: %s" % response)
logger.info(f"Response: {response}")

return response

Expand All @@ -236,7 +238,7 @@ async def set_custom_vars(self):
for var, value in vars_dict.items():
if type(value) is str:
value = fmt.format(value, **self.user)
logger.info("Setting '%s' to '%s'" % (var, value))
logger.info(f"Setting '{var}' to '{value}'")
await self.agi.set_variable(var, value)


Expand Down

0 comments on commit 415c610

Please sign in to comment.