Skip to content

Commit 33253e6

Browse files
Kamal Sai DevarapalliKamal Sai Devarapalli
authored andcommitted
Fixed syntax errors, removed trailing whitespace, cleaned up docstrings, and addressed major linting issues
1 parent 4b6f27a commit 33253e6

File tree

8 files changed

+210
-118
lines changed

8 files changed

+210
-118
lines changed

src/pyportal_common/app_handlers/app_manager.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,16 @@ def create_app_instance(self) -> Union[Flask, None]:
4545
except ImportError as ex:
4646
self.cmn_logger.error(
4747
f"ImportError occurred :: {ex}\tLine No:: {sys.exc_info()[2].tb_lineno}"
48-
)
49-
f"ImportError occurred :: {ex}\tLine No:: {sys.exc_info()[2].tb_lineno}"
5048
)
5149
return None
5250
except TypeError as ex:
5351
self.cmn_logger.error(
5452
f"TypeError occurred :: {ex}\tLine No:: {sys.exc_info()[2].tb_lineno}"
55-
)
56-
f"TypeError occurred :: {ex}\tLine No:: {sys.exc_info()[2].tb_lineno}"
5753
)
5854
return None
5955
except Exception as ex:
6056
self.cmn_logger.exception(
6157
f"Exception occurred :: {ex}\tLine No:: {sys.exc_info()[2].tb_lineno}"
62-
)
63-
f"Exception occurred :: {ex}\tLine No:: {sys.exc_info()[2].tb_lineno}"
6458
)
6559
return None
6660

@@ -79,8 +73,6 @@ def bind_jwt_manger_to_app_instance(
7973
jwt_instance = JWTManager(app_instance)
8074
return jwt_instance
8175
except Exception as ex:
82-
f"Error occurred :: {ex}\tLine No:: {sys.exc_info()[2].tb_lineno}"
83-
)
8476
self.cmn_logger.exception(
8577
f"Error occurred :: {ex}\tLine No:: {sys.exc_info()[2].tb_lineno}"
8678
)

src/tokenmanagement_service/__init__.py

Lines changed: 167 additions & 72 deletions
Large diffs are not rendered by default.

src/tokenmanagement_service/migrations/versions/b2645dcc2eb1_added_indexand_uniquecons_for_the_token_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""added indexand uniquecons for the token, userid
22
33
Revision ID: b2645dcc2eb1
4-
Revises:
4+
Revises:
55
Create Date: 2023-09-08 13:09:33.052383
66
77
"""

src/usermanagement_service/migrations/versions/40c28f8c1faa_add_index_to_username_and_email.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Add index to username and email
22
33
Revision ID: 40c28f8c1faa
4-
Revises:
4+
Revises:
55
Create Date: 2023-09-07 23:01:00.296144
66
77
"""

src/usermanagement_service/user_management_grpc/user_grpc_server.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def ValidateUserCredentials(self, request, context):
6666
context.set_code(grpc.StatusCode.INTERNAL)
6767
context.set_details("Internal DB error")
6868
user_management_logger.error(f"Error occurred :: {ex}\tLine No:: {sys.exc_info()[2].tb_lineno}")
69-
user_management_logger.info(f"Packing and sending response back to gRPC Client :: {token_res_message}")
70-
return token_res_message
69+
user_management_logger.info(f"Packing and sending response back to gRPC Client :: {token_res_message}")
70+
return token_res_message
7171
except Exception as ex:
72+
pass

src/usermanagement_service/views/create_user.py

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@
2222
is_username_email_already_exists_in_db,
2323
convert_db_model_to_resp,
2424
)
25-
from src.usermanagement_service.users.response_handlers.create_user_success_response import (
26-
generate_success_response,
27-
)
25+
from src.usermanagement_service.users.response_handlers.create_user_success_response import generate_success_response
2826

2927

3028
def register_user():
3129
try:
3230
user_management_logger.info(
33-
f"REQUEST ==> Received Endpoint for the request:: {request.endpoint}"
31+
f"REQUEST ==> Received Endpoint: {request.endpoint}"
3432
)
3533
user_management_logger.info(
3634
f"REQUEST ==> Received url for the request :: {request.url}"
@@ -40,21 +38,28 @@ def register_user():
4038
user_management_logger.info(
4139
f"Received Headers from the request :: {rec_req_headers}"
4240
)
43-
"""
41+
"""
4442
1. Find the missing headers, any schema related issue related to headers in the request
45-
2. If any missing headers or schema related issue , send the error response back to client.
43+
2. If any missing headers or schema related issue, send the error response back to client.
4644
3. Custom error response contains the information about headers related to missing/schema issue, with status code as 400,BAD_REQUEST
4745
"""
48-
reg_header_result = usermanager.generate_req_missing_params(rec_req_headers, req_headers_schema)
46+
reg_header_result = usermanager.generate_req_missing_params(
47+
rec_req_headers, req_headers_schema
48+
)
4949
if len(reg_header_result) > 0:
50-
return send_invalid_request_error_to_client(app_logger_name=user_management_logger,message_data="Request Headers Missing",err_details=reg_header_result,)
50+
return send_invalid_request_error_to_client(
51+
app_logger_name=user_management_logger,
52+
message_data="Request Headers Missing",
53+
err_details=reg_header_result,
54+
)
5155

5256
rec_req_data = request.get_json()
53-
"""
57+
"""
5458
1. Find the missing params, any schema related issue related to params in the request body
55-
2. If any missing params or schema related issue , send the error response back to client.
59+
2. If any missing params or schema related issue, send the error response back to client.
5660
3. Custom error response contains the information about params related to missing/schema issue, with status code as 400,BAD_REQUEST
5761
"""
62+
"""
5863
body_result = usermanager.generate_req_missing_params(
5964
rec_req_data, reg_user_req_schema
6065
)
@@ -72,21 +77,32 @@ def register_user():
7277
emailaddress = rec_req_data["email"]
7378
password = rec_req_data["password"]
7479
dateofbirth = rec_req_data["dateOfBirth"]
75-
user_management_logger.info("Processing the request data... :: [STARTED]")
76-
session_to_validate_existing_user = app_manager_db_obj.get_session_from_session_maker()
80+
user_management_logger.info("Processing request data... [STARTED]")
81+
session_to_validate_existing_user = (
82+
app_manager_db_obj.get_session_from_session_maker()
83+
)
7784
if session_to_validate_existing_user is None:
78-
"""
79-
No need to close the connection/session if the timeout occurs during the session/connection creation.
80-
If the queue is full, it will try to wait initiate/fetch connection from the overflows connections.
81-
"""
82-
return send_internal_server_error_to_client(app_logger_name=user_management_logger, message_data="Create Session Failed",)
85+
return send_internal_server_error_to_client(
86+
app_logger_name=user_management_logger,
87+
message_data="Create Session Failed",
88+
)
8389
# Doing the pre-validation checks before procession the request.
84-
if is_username_email_already_exists_in_db(session_instance=session_to_validate_existing_user, uname=username, email=emailaddress,) is None:
90+
if is_username_email_already_exists_in_db(
91+
session_instance=session_to_validate_existing_user,
92+
uname=username,
93+
email=emailaddress,
94+
) is None:
8595
app_manager_db_obj.close_session(session_instance=session_to_validate_existing_user)
86-
return send_internal_server_error_to_client(app_logger_name=user_management_logger, message_data="Db error")
96+
return send_internal_server_error_to_client(
97+
app_logger_name=user_management_logger,
98+
message_data="Db error"
99+
)
87100
if not is_username_email_already_exists_in_db:
88101
app_manager_db_obj.close_session(session_instance=session_to_validate_existing_user)
89-
return send_invalid_request_error_to_client(app_logger_name=user_management_logger, message_data="Existing User",)
102+
return send_invalid_request_error_to_client(
103+
app_logger_name=user_management_logger,
104+
message_data="Existing User",
105+
)
90106
# Register user-logic begins here
91107
try:
92108
user_obj = User(
@@ -110,9 +126,6 @@ def register_user():
110126
app_logger_name=user_management_logger,
111127
message_data="User Instance creation Failed",
112128
)
113-
"""
114-
Using the session begin the transaction, and add the user into the database using ORM.
115-
"""
116129
session_to_create_new_user = app_manager_db_obj.get_session_from_session_maker()
117130
if session_to_create_new_user is None:
118131
return send_internal_server_error_to_client(app_logger_name=user_management_logger, message_data="Create Session Failed",)
@@ -121,10 +134,6 @@ def register_user():
121134
if user_db_record_to_insert is None:
122135
app_manager_db_obj.close_session(session_instance=session_to_create_new_user)
123136
return send_internal_server_error_to_client(app_logger_name=user_management_logger, message_data="User DB - Instance mapping Failed",)
124-
"""
125-
Add the user model to the database and commit the changes
126-
Any exception occur, logs the exception and sends back the error response to the client as internal_server_error
127-
"""
128137
try:
129138
user_management_logger.info(
130139
f"Data adding into DataBase session {user_db_record_to_insert}:: [STARTED]"
@@ -147,11 +156,6 @@ def register_user():
147156
)
148157
return send_internal_server_error_to_client(app_logger_name=user_management_logger, message_data="Database Error",)
149158
else:
150-
"""
151-
1. Converting the database model of user to defined user and serialize to json
152-
2. Using the serialize , Generating the success custom response , headers
153-
3. Sending the response back to client
154-
"""
155159
user_instance = convert_db_model_to_resp(model_instance=user_db_record_to_insert)
156160
if not user_instance:
157161
app_manager_db_obj.close_session(session_instance=session_to_create_new_user)

src/usermanagement_service/views/fetch_user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def get_user_info(userid):
2828
user_management_app_logger.info(
2929
f"Received Headers from the request :: {rec_req_headers}"
3030
)
31-
"""
31+
"""
3232
1. Find the missing headers, any schema related issue related to headers in the request
3333
2. If any missing headers or schema related issue , send the error response back to client.
3434
3. Custom error response contains the information about headers related to missing/schema issue, with status code as 400,BAD_REQUEST

src/usermanagement_service/views/remove_user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def deregister_user(userid):
2929
user_management_app_logger.info(
3030
f"Received Headers from the request :: {rec_req_headers}"
3131
)
32-
"""
32+
"""
3333
1. Find the missing headers, any schema related issue related to headers in the request
3434
2. If any missing headers or schema related issue , send the error response back to client.
3535
3. Custom error response contains the information about headers related to missing/schema issue, with status code as 400,BAD_REQUEST

0 commit comments

Comments
 (0)