Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix botched merge from 14 Aug 23 in mscolab.py #2012

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 74 additions & 51 deletions mslib/msui/mscolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def login_handler(self):
r = s.post(url, data=data, timeout=tuple(config_loader(dataset="MSCOLAB_timeout")))
if r.status_code == 401:
raise requests.exceptions.ConnectionError
except requests.exceptions.ConnectionError as ex:
except requests.exceptions.RequestException as ex:
logging.error("unexpected error: %s %s %s", type(ex), url, ex)
self.set_status(
"Error",
Expand Down Expand Up @@ -589,18 +589,18 @@ def after_login(self, emailid, url, r):
# create socket connection here
try:
self.conn = sc.ConnectionManager(self.token, user=self.user, mscolab_server_url=self.mscolab_server_url)
except Exception as ex:
logging.debug("Couldn't create a socket connection: %s", ex)
show_popup(self.ui, "Error", "Couldn't create a socket connection. Maybe the MSColab server is too old. "
"New Login required!")
self.logout()
else:
# Update Last Used
data = {
"token": self.token
}
r = requests.post(f"{self.mscolab_server_url}/update_last_used", data=data,
timeout=tuple(config_loader(dataset="MSCOLAB_timeout")))
except Exception as ex:
logging.debug("Couldn't create a socket connection: %s", ex)
show_popup(self.ui, "Error", "Couldn't create a socket connection. Maybe the MSColab server is too old. "
"New Login required!")
self.logout()
else:
self.conn.signal_operation_list_updated.connect(self.reload_operation_list)
self.conn.signal_reload.connect(self.reload_window)
self.conn.signal_new_permission.connect(self.render_new_permission)
Expand Down Expand Up @@ -1087,7 +1087,12 @@ def handle_leave_operation(self):
"selected_userids": json.dumps([self.user["id"]])
}
url = urljoin(self.mscolab_server_url, "delete_bulk_permissions")
res = requests.post(url, data=data, timeout=tuple(config_loader(dataset="MSCOLAB_timeout")))
try:
res = requests.post(url, data=data, timeout=tuple(config_loader(dataset="MSCOLAB_timeout")))
except requests.exceptions.RequestException as e:
logging.error(e)
show_popup(self.ui, "Error", "Some error occurred! Please reconnect.")
self.logout()
if res.text != "False":
res = res.json()
if res["success"]:
Expand Down Expand Up @@ -1134,18 +1139,24 @@ def change_category_handler(self):
"value": entered_operation_category
}
url = urljoin(self.mscolab_server_url, 'update_operation')
r = requests.post(url, data=data, timeout=tuple(config_loader(dataset="MSCOLAB_timeout")))
if r.text == "True":
self.active_operation_category = entered_operation_category
self.reload_operation_list()
QtWidgets.QMessageBox.information(
self.ui,
"Update successful",
"Category is updated successfully.",
)
else:
show_popup(self.ui, "Error", "Your Connection is expired. New Login required!")
try:
r = requests.post(url, data=data, timeout=tuple(config_loader(dataset="MSCOLAB_timeout")))
except requests.exceptions.RequestException as e:
logging.error(e)
show_popup(self.ui, "Error", "Some error occurred! Please reconnect.")
self.logout()
else:
if r.text == "True":
self.active_operation_category = entered_operation_category
self.reload_operation_list()
QtWidgets.QMessageBox.information(
self.ui,
"Update successful",
"Category is updated successfully.",
)
else:
show_popup(self.ui, "Error", "Your Connection is expired. New Login required!")
self.logout()
else:
show_popup(self.ui, "Error", "Your Connection is expired. New Login required!")
self.logout()
Expand All @@ -1171,20 +1182,26 @@ def change_description_handler(self):
}

url = urljoin(self.mscolab_server_url, 'update_operation')
r = requests.post(url, data=data, timeout=tuple(config_loader(dataset="MSCOLAB_timeout")))
if r.text == "True":
# Update active operation description label
self.set_operation_desc_label(entered_operation_desc)

self.reload_operation_list()
QtWidgets.QMessageBox.information(
self.ui,
"Update successful",
"Description is updated successfully.",
)
else:
show_popup(self.ui, "Error", "Your Connection is expired. New Login required!")
try:
r = requests.post(url, data=data, timeout=tuple(config_loader(dataset="MSCOLAB_timeout")))
except requests.exceptions.RequestException as e:
logging.error(e)
show_popup(self.ui, "Error", "Some error occurred! Please reconnect.")
self.logout()
else:
if r.text == "True":
# Update active operation description label
self.set_operation_desc_label(entered_operation_desc)

self.reload_operation_list()
QtWidgets.QMessageBox.information(
self.ui,
"Update successful",
"Description is updated successfully.",
)
else:
show_popup(self.ui, "Error", "Your Connection is expired. New Login required!")
self.logout()
else:
show_popup(self.ui, "Error", "Your Connection is expired. New Login required!")
self.logout()
Expand All @@ -1209,26 +1226,32 @@ def rename_operation_handler(self):
"value": entered_operation_name
}
url = urljoin(self.mscolab_server_url, 'update_operation')
r = requests.post(url, data=data, timeout=tuple(config_loader(dataset="MSCOLAB_timeout")))
if r.text == "True":
# Update active operation name
self.active_operation_name = entered_operation_name

# Update active operation description
self.set_operation_desc_label(self.active_operation_description)
self.reload_operation_list()
self.reload_windows_slot()
# Update other user's operation list
self.conn.signal_operation_list_updated.connect(self.reload_operation_list)

QtWidgets.QMessageBox.information(
self.ui,
"Rename successful",
"Operation is renamed successfully.",
)
else:
show_popup(self.ui, "Error", "Your Connection is expired. New Login required!")
try:
r = requests.post(url, data=data, timeout=tuple(config_loader(dataset="MSCOLAB_timeout")))
except requests.exceptions.RequestException as e:
logging.error(e)
show_popup(self.ui, "Error", "Some error occurred! Please reconnect.")
self.logout()
else:
if r.text == "True":
# Update active operation name
self.active_operation_name = entered_operation_name

# Update active operation description
self.set_operation_desc_label(self.active_operation_description)
self.reload_operation_list()
self.reload_windows_slot()
# Update other user's operation list
self.conn.signal_operation_list_updated.connect(self.reload_operation_list)

QtWidgets.QMessageBox.information(
self.ui,
"Rename successful",
"Operation is renamed successfully.",
)
else:
show_popup(self.ui, "Error", "Your Connection is expired. New Login required!")
self.logout()
else:
show_popup(self.ui, "Error", "Your Connection is expired. New Login required!")
self.logout()
Expand Down