mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-15 23:40:17 +02:00
Corrections for typos in logging.
Rephrased EveManager exceptions to reflect determination id is not of type rather than failure of function.
This commit is contained in:
parent
6c3085f78c
commit
08cd2c1f1a
@ -167,7 +167,7 @@ class EveManager:
|
|||||||
logger.info("Deleted user %s api key id %s" % (user_id, api_id))
|
logger.info("Deleted user %s api key id %s" % (user_id, api_id))
|
||||||
apikeypair.delete()
|
apikeypair.delete()
|
||||||
else:
|
else:
|
||||||
logger.error("Unable to delete api: user mismatch: key id %s not owned by %s" % (api_id, user_id))
|
logger.error("Unable to delete api: user mismatch: key id %s owned by user id %s, not deleting user id %s" % (api_id, apikeypair.user.id, user_id))
|
||||||
else:
|
else:
|
||||||
logger.warn("Unable to locate api id %s - cannot delete." % api_id)
|
logger.warn("Unable to locate api id %s - cannot delete." % api_id)
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ class EveManager:
|
|||||||
logger.info("Deleting user %s character %s from api %s" % (user_id, char, api_id))
|
logger.info("Deleting user %s character %s from api %s" % (user_id, char, api_id))
|
||||||
char.delete()
|
char.delete()
|
||||||
else:
|
else:
|
||||||
logger.error("Unable to delete character %s by api %s: user mismatch: character not owned by %s" % (char, api_id, user_id))
|
logger.error("Unable to delete character %s by api %s: user mismatch: character owned by user id%s, not deleting user id %s" % (char, api_id, char.user.id, user_id))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check_if_character_exist(char_name):
|
def check_if_character_exist(char_name):
|
||||||
|
@ -62,10 +62,10 @@ def group_reject_request(request, group_request_id):
|
|||||||
group_request = GroupRequest.objects.get(id=group_request_id)
|
group_request = GroupRequest.objects.get(id=group_request_id)
|
||||||
|
|
||||||
if group_request:
|
if group_request:
|
||||||
logger.info("User %s rejected group request from user %s for %s" % (request.user, group_request.user, group_request.group.name))
|
logger.info("User %s rejected group request from user %s to group %s" % (request.user, group_request.user, group_request.group.name))
|
||||||
group_request.delete()
|
group_request.delete()
|
||||||
except:
|
except:
|
||||||
logger.exception("Unhandled exception occured while user %s attempting to reject group request id %s." % (request.user, group_request_id), exc_info=True)
|
logger.exception("Unhandled exception occured while user %s attempting to reject group request id %s" % (request.user, group_request_id), exc_info=True)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return HttpResponseRedirect("/group/management/")
|
return HttpResponseRedirect("/group/management/")
|
||||||
@ -83,7 +83,7 @@ def group_leave_accept_request(request, group_request_id):
|
|||||||
group_request.delete()
|
group_request.delete()
|
||||||
logger.info("User %s accepted group leave request from user %s to group %s" % (request.user, group_request.user, group_request.group.name))
|
logger.info("User %s accepted group leave request from user %s to group %s" % (request.user, group_request.user, group_request.group.name))
|
||||||
except:
|
except:
|
||||||
logger.exception("Unhandled exception occured while user %s attempting to accept group leave request id %s." % (request.user, group_request_id), exc_info=True)
|
logger.exception("Unhandled exception occured while user %s attempting to accept group leave request id %s" % (request.user, group_request_id), exc_info=True)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return HttpResponseRedirect("/group/management/")
|
return HttpResponseRedirect("/group/management/")
|
||||||
@ -98,9 +98,9 @@ def group_leave_reject_request(request, group_request_id):
|
|||||||
|
|
||||||
if group_request:
|
if group_request:
|
||||||
group_request.delete()
|
group_request.delete()
|
||||||
logger.info("User %s rejected group leave request from user %s for %s" % (request.user, group_request.user, group_request.group.name))
|
logger.info("User %s rejected group leave request from user %s for group %s" % (request.user, group_request.user, group_request.group.name))
|
||||||
except:
|
except:
|
||||||
logger.exception("Unhandled exception occured while user %s attempting to reject group leave request id %s." % (request.user, group_request_id), exc_info=True)
|
logger.exception("Unhandled exception occured while user %s attempting to reject group leave request id %s" % (request.user, group_request_id), exc_info=True)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return HttpResponseRedirect("/group/management/")
|
return HttpResponseRedirect("/group/management/")
|
||||||
|
@ -96,7 +96,7 @@ def hr_application_personal_view(request, app_id):
|
|||||||
logger.warn("HRApplication id %s user %s does not match request user %s - returning blank application." % (app_id, application.user, request.user))
|
logger.warn("HRApplication id %s user %s does not match request user %s - returning blank application." % (app_id, application.user, request.user))
|
||||||
application = HRApplication()
|
application = HRApplication()
|
||||||
else:
|
else:
|
||||||
logger.warn("Unable to locate HRApplication matching id %s - returning blank application to user %s" % (app_id, request.user))
|
logger.error("Unable to locate HRApplication matching id %s - returning blank application to user %s" % (app_id, request.user))
|
||||||
application = HRApplication()
|
application = HRApplication()
|
||||||
context = {'application': application}
|
context = {'application': application}
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ def hr_application_personal_removal(request, app_id):
|
|||||||
application.delete()
|
application.delete()
|
||||||
logger.info("Deleted HRApplication with id %s for user %s to corp %s" % (app_id, request.user, application.corp))
|
logger.info("Deleted HRApplication with id %s for user %s to corp %s" % (app_id, request.user, application.corp))
|
||||||
else:
|
else:
|
||||||
logger.warn("HRapplication id %s user %s does not match request user %s - refusing to delete." % (app_id, application.user, request.user))
|
logger.error("HRapplication id %s user %s does not match request user %s - refusing to delete." % (app_id, application.user, request.user))
|
||||||
return HttpResponseRedirect("/hr_application_management/")
|
return HttpResponseRedirect("/hr_application_management/")
|
||||||
|
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ def hr_application_view(request, app_id):
|
|||||||
if HRApplication.objects.filter(id=app_id).exists():
|
if HRApplication.objects.filter(id=app_id).exists():
|
||||||
application = HRApplication.objects.get(id=app_id)
|
application = HRApplication.objects.get(id=app_id)
|
||||||
comments = HRApplicationComment.objects.all().filter(application=application)
|
comments = HRApplicationComment.objects.all().filter(application=application)
|
||||||
logger.debug("Retrieved hrpplication id %s for user %s with comments %s" % (app_id, request.user, commends))
|
logger.debug("Retrieved hrpplication id %s on behalf of user %s with comments %s" % (app_id, request.user, commends))
|
||||||
else:
|
else:
|
||||||
application = HRApplication()
|
application = HRApplication()
|
||||||
comments = []
|
comments = []
|
||||||
@ -164,9 +164,9 @@ def hr_application_remove(request, app_id):
|
|||||||
logger.info("Deleted HRApplication id %s on behalf of user %s" % (app_id, request.user))
|
logger.info("Deleted HRApplication id %s on behalf of user %s" % (app_id, request.user))
|
||||||
application.delete()
|
application.delete()
|
||||||
else:
|
else:
|
||||||
logger.error("Unable to delete HRApplication with id %s for user %s: application is NoneType" % (app_id, request.user))
|
logger.error("Unable to delete HRApplication with id %s on behalf of user %s: application is NoneType" % (app_id, request.user))
|
||||||
else:
|
else:
|
||||||
logger.error("Unable to delete HRApplication with id %s for user %s: application not found." % (app_id, request.user))
|
logger.error("Unable to delete HRApplication with id %s on behalf of user %s: application not found." % (app_id, request.user))
|
||||||
|
|
||||||
return HttpResponseRedirect("/hr_application_management/")
|
return HttpResponseRedirect("/hr_application_management/")
|
||||||
|
|
||||||
@ -231,6 +231,7 @@ def hr_application_search(request):
|
|||||||
return render_to_response('registered/hrapplicationsearchview.html',
|
return render_to_response('registered/hrapplicationsearchview.html',
|
||||||
context, context_instance=RequestContext(request))
|
context, context_instance=RequestContext(request))
|
||||||
else:
|
else:
|
||||||
|
logger.debug("Form invalid - returning for user %s to retry." % request.user)
|
||||||
context = {'applications': None, 'search_form': form}
|
context = {'applications': None, 'search_form': form}
|
||||||
return render_to_response('registered/hrapplicationsearchview.html',
|
return render_to_response('registered/hrapplicationsearchview.html',
|
||||||
context, context_instance=RequestContext(request))
|
context, context_instance=RequestContext(request))
|
||||||
|
@ -26,10 +26,10 @@ class DiscordAPIManager:
|
|||||||
path = DISCORD_URL + "/users/@me"
|
path = DISCORD_URL + "/users/@me"
|
||||||
r = requests.get(path, headers=custom_headers)
|
r = requests.get(path, headers=custom_headers)
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
logger.debug("Token starting with %s still valid." % token[0:5])
|
logger.debug("Token starting with %s passed validation." % token[0:5])
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
logger.debug("Token starting with %s vailed validation with status code %s" % (token[0:5], r.status_code))
|
logger.debug("Token starting with %s failed validation with status code %s" % (token[0:5], r.status_code))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -403,4 +403,5 @@ class DiscordManager:
|
|||||||
logger.info("Deleted user with id %s from discord server id %s" % (user_id, settings.DISCORD_SERVER_ID))
|
logger.info("Deleted user with id %s from discord server id %s" % (user_id, settings.DISCORD_SERVER_ID))
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
|
logger.exception("An unhandled exception has occured.", exc_info=True)
|
||||||
return False
|
return False
|
||||||
|
@ -94,7 +94,7 @@ class EveApiManager():
|
|||||||
api = evelink.api.API(api_key=(api_id, api_key))
|
api = evelink.api.API(api_key=(api_id, api_key))
|
||||||
account = evelink.account.Account(api=api)
|
account = evelink.account.Account(api=api)
|
||||||
info = account.key_info()
|
info = account.key_info()
|
||||||
logger.debug("API has mask %s, required is %s." % (info[0]['access_mask'], settings.MEMBER_API_MASK))
|
logger.debug("API has mask %s, required is %s" % (info[0]['access_mask'], settings.MEMBER_API_MASK))
|
||||||
return info[0]['access_mask'] & int(settings.MEMBER_API_MASK) == int(settings.MEMBER_API_MASK)
|
return info[0]['access_mask'] & int(settings.MEMBER_API_MASK) == int(settings.MEMBER_API_MASK)
|
||||||
|
|
||||||
except evelink.api.APIError as error:
|
except evelink.api.APIError as error:
|
||||||
@ -109,7 +109,7 @@ class EveApiManager():
|
|||||||
api = evelink.api.API(api_key=(api_id, api_key))
|
api = evelink.api.API(api_key=(api_id, api_key))
|
||||||
account = evelink.account.Account(api=api)
|
account = evelink.account.Account(api=api)
|
||||||
info = account.key_info()
|
info = account.key_info()
|
||||||
logger.debug("API has mask %s, required is %s." % (info[0]['access_mask'], settings.BLUE_API_MASK))
|
logger.debug("API has mask %s, required is %s" % (info[0]['access_mask'], settings.BLUE_API_MASK))
|
||||||
return info[0]['access_mask'] & int(settings.BLUE_API_MASK) == int(settings.BLUE_API_MASK)
|
return info[0]['access_mask'] & int(settings.BLUE_API_MASK) == int(settings.BLUE_API_MASK)
|
||||||
|
|
||||||
except evelink.api.APIError as error:
|
except evelink.api.APIError as error:
|
||||||
@ -141,7 +141,7 @@ class EveApiManager():
|
|||||||
logger.info("Verified api id %s is still valid." % api_id)
|
logger.info("Verified api id %s is still valid." % api_id)
|
||||||
return True
|
return True
|
||||||
except evelink.api.APIError as error:
|
except evelink.api.APIError as error:
|
||||||
logger.exception("Unhandled APIError occured.", exc_info=True)
|
logger.exception("APIError occured while validating api id %s" % api_id, exc_info=True)
|
||||||
|
|
||||||
logger.info("API id %s is invalid." % api_id)
|
logger.info("API id %s is invalid." % api_id)
|
||||||
return False
|
return False
|
||||||
@ -156,7 +156,7 @@ class EveApiManager():
|
|||||||
logger.info("Verified API server is online and reachable.")
|
logger.info("Verified API server is online and reachable.")
|
||||||
return True
|
return True
|
||||||
except evelink.api.APIError as error:
|
except evelink.api.APIError as error:
|
||||||
logger.exception("Unhandled APIError occured.", exc_info=True)
|
logger.exception("APIError occured while trying to query api server. Possibly offline?", exc_info=True)
|
||||||
|
|
||||||
logger.warn("Unable to reach API server.")
|
logger.warn("Unable to reach API server.")
|
||||||
return False
|
return False
|
||||||
@ -172,14 +172,14 @@ class EveApiManager():
|
|||||||
logger.debug("Confirmed id %s is a corp." % corp_id)
|
logger.debug("Confirmed id %s is a corp." % corp_id)
|
||||||
return True
|
return True
|
||||||
except evelink.api.APIError as error:
|
except evelink.api.APIError as error:
|
||||||
logger.exception("Unhandled APIError occured.", exc_info=True)
|
logger.exception("APIError occured while checking if id %s is corp. Possibly not corp?" % corp_id, exc_info=True)
|
||||||
|
|
||||||
logger.debug("Unable to verify id %s is corp." % corp_id)
|
logger.debug("Unable to verify id %s is corp." % corp_id)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_corp_standings():
|
def get_corp_standings():
|
||||||
if settings.CORP_API_ID != "":
|
if settings.CORP_API_ID and settings.CORP_API_VCODE:
|
||||||
try:
|
try:
|
||||||
logger.debug("Getting corp standings with api id %s" % settings.CORP_API_ID)
|
logger.debug("Getting corp standings with api id %s" % settings.CORP_API_ID)
|
||||||
api = evelink.api.API(api_key=(settings.CORP_API_ID, settings.CORP_API_VCODE))
|
api = evelink.api.API(api_key=(settings.CORP_API_ID, settings.CORP_API_VCODE))
|
||||||
@ -206,9 +206,9 @@ class EveApiManager():
|
|||||||
logger.debug("Confirmed id %s is an alliance." % alliance_id)
|
logger.debug("Confirmed id %s is an alliance." % alliance_id)
|
||||||
return True
|
return True
|
||||||
except evelink.api.APIError as error:
|
except evelink.api.APIError as error:
|
||||||
logger.exception("Unhandled APIError occured.", exc_info=True)
|
logger.exception("APIError occured while checking if id %s is an alliance. Possibly not alliance?" % alliance_id, exc_info=True)
|
||||||
|
|
||||||
logger.debug("Unable to verify id %s is an alliance." % alliance_id)
|
logger.debug("Unable to verify id %s is an an alliance." % alliance_id)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -222,7 +222,7 @@ class EveApiManager():
|
|||||||
logger.debug("Confirmed id %s is a character." % character_id)
|
logger.debug("Confirmed id %s is a character." % character_id)
|
||||||
return True
|
return True
|
||||||
except evelink.api.APIError as error:
|
except evelink.api.APIError as error:
|
||||||
logger.exception("Unhandled APIError occured.", exc_info=True)
|
logger.exception("APIError occured while checking if id %s is a character. Possibly not character?" % character_id, exc_info=True)
|
||||||
|
|
||||||
logger.debug("Unable to verify id %s is a character." % character_id)
|
logger.debug("Unable to verify id %s is a character." % character_id)
|
||||||
return False
|
return False
|
||||||
|
@ -79,7 +79,7 @@ class IPBoardManager:
|
|||||||
ret = IPBoardManager.exec_xmlrpc('getAllGroups')
|
ret = IPBoardManager.exec_xmlrpc('getAllGroups')
|
||||||
for group in ret:
|
for group in ret:
|
||||||
groups.append(group["g_title"])
|
groups.append(group["g_title"])
|
||||||
logger.info("Retrieved group list from IPBoard: %s" % groups)
|
logger.debug("Retrieved group list from IPBoard: %s" % groups)
|
||||||
return groups
|
return groups
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -89,25 +89,25 @@ class IPBoardManager:
|
|||||||
if type(ret) is list:
|
if type(ret) is list:
|
||||||
for group in ret:
|
for group in ret:
|
||||||
groups.append(group["g_title"])
|
groups.append(group["g_title"])
|
||||||
logger.info("Got user %s IPBoard groups %s" % (username, groups))
|
logger.debug("Got user %s IPBoard groups %s" % (username, groups))
|
||||||
return groups
|
return groups
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def add_group(group):
|
def add_group(group):
|
||||||
ret = IPBoardManager.exec_xmlrpc('addGroup', group=group)
|
ret = IPBoardManager.exec_xmlrpc('addGroup', group=group)
|
||||||
logger.info("Added IPBoard group %s, response %s" % (group, ret))
|
logger.info("Added IPBoard group %s" % group)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def add_user_to_group(username, group):
|
def add_user_to_group(username, group):
|
||||||
ret = IPBoardManager.exec_xmlrpc('addUserToGroup', username=username, group=group)
|
ret = IPBoardManager.exec_xmlrpc('addUserToGroup', username=username, group=group)
|
||||||
logger.info("Added IPBoard user %s to group %s, response %s" % (username, group, ret))
|
logger.info("Added IPBoard user %s to group %s" % (username, group))
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def remove_user_from_group(username, group):
|
def remove_user_from_group(username, group):
|
||||||
ret = IPBoardManager.exec_xmlrpc('removeUserFromGroup', username=username, group=group)
|
ret = IPBoardManager.exec_xmlrpc('removeUserFromGroup', username=username, group=group)
|
||||||
logger.info("Removed IPBoard user %s from group %s, reponse %s" % (username, group, ret))
|
logger.info("Removed IPBoard user %s from group %s" % (username, group))
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -19,7 +19,7 @@ class OpenfireManager:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def send_broadcast_threaded(group_name, broadcast_message):
|
def send_broadcast_threaded(group_name, broadcast_message):
|
||||||
logger.info("Starting broadcast to %s with message %s" % (group_name, broadcast_message))
|
logger.debug("Starting broadcast to %s with message %s" % (group_name, broadcast_message))
|
||||||
broadcast_thread = XmppThread(1, "XMPP Broadcast Thread", 1, group_name, broadcast_message)
|
broadcast_thread = XmppThread(1, "XMPP Broadcast Thread", 1, group_name, broadcast_message)
|
||||||
broadcast_thread.start()
|
broadcast_thread.start()
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ class OpenfireManager:
|
|||||||
logger.info("Added openfire user %s" % username)
|
logger.info("Added openfire user %s" % username)
|
||||||
except exception.UserAlreadyExistsException:
|
except exception.UserAlreadyExistsException:
|
||||||
# User exist
|
# User exist
|
||||||
logger.warn("Attempting to add a user %s to openfire which already exists on server." % username)
|
logger.error("Attempting to add a user %s to openfire which already exists on server." % username)
|
||||||
return "", ""
|
return "", ""
|
||||||
|
|
||||||
return sanatized_username, password
|
return sanatized_username, password
|
||||||
@ -64,7 +64,7 @@ class OpenfireManager:
|
|||||||
logger.info("Deleted user %s from openfire." % username)
|
logger.info("Deleted user %s from openfire." % username)
|
||||||
return True
|
return True
|
||||||
except exception.UserNotFoundException:
|
except exception.UserNotFoundException:
|
||||||
logger.warn("Attempting to delete a user %s from openfire which was not found on server." % username)
|
logger.error("Attempting to delete a user %s from openfire which was not found on server." % username)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -7,6 +7,8 @@ from django.db import connections
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class Phpbb3Manager:
|
class Phpbb3Manager:
|
||||||
@ -64,6 +66,7 @@ class Phpbb3Manager:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __get_group_id(groupname):
|
def __get_group_id(groupname):
|
||||||
|
logger.debug("Getting phpbb3 group id for groupname %s" % groupname)
|
||||||
cursor = connections['phpbb3'].cursor()
|
cursor = connections['phpbb3'].cursor()
|
||||||
cursor.execute(Phpbb3Manager.SQL_GET_GROUP_ID, [groupname])
|
cursor.execute(Phpbb3Manager.SQL_GET_GROUP_ID, [groupname])
|
||||||
row = cursor.fetchone()
|
row = cursor.fetchone()
|
||||||
@ -72,6 +75,7 @@ class Phpbb3Manager:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __get_user_id(username):
|
def __get_user_id(username):
|
||||||
|
logger.debug("Getting phpbb3 user id for username %s" % username)
|
||||||
cursor = connections['phpbb3'].cursor()
|
cursor = connections['phpbb3'].cursor()
|
||||||
cursor.execute(Phpbb3Manager.SQL_USER_ID_FROM_USERNAME, [username])
|
cursor.execute(Phpbb3Manager.SQL_USER_ID_FROM_USERNAME, [username])
|
||||||
row = cursor.fetchone()
|
row = cursor.fetchone()
|
||||||
@ -79,11 +83,12 @@ class Phpbb3Manager:
|
|||||||
logger.debug("Got phpbb user id %s for username %s" % (row[0], username))
|
logger.debug("Got phpbb user id %s for username %s" % (row[0], username))
|
||||||
return row[0]
|
return row[0]
|
||||||
else:
|
else:
|
||||||
logger.warn("Username %s not found on phpbb. Unable to determine user id." % username)
|
logger.error("Username %s not found on phpbb. Unable to determine user id." % username)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __get_all_groups():
|
def __get_all_groups():
|
||||||
|
logger.debug("Getting all phpbb3 groups.")
|
||||||
cursor = connections['phpbb3'].cursor()
|
cursor = connections['phpbb3'].cursor()
|
||||||
cursor.execute(Phpbb3Manager.SQL_GET_ALL_GROUPS)
|
cursor.execute(Phpbb3Manager.SQL_GET_ALL_GROUPS)
|
||||||
rows = cursor.fetchall()
|
rows = cursor.fetchall()
|
||||||
@ -95,6 +100,7 @@ class Phpbb3Manager:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __get_user_groups(userid):
|
def __get_user_groups(userid):
|
||||||
|
logger.debug("Getting phpbb3 user id %s groups" % userid)
|
||||||
cursor = connections['phpbb3'].cursor()
|
cursor = connections['phpbb3'].cursor()
|
||||||
cursor.execute(Phpbb3Manager.SQL_GET_USER_GROUPS, [userid])
|
cursor.execute(Phpbb3Manager.SQL_GET_USER_GROUPS, [userid])
|
||||||
out = [row[0] for row in cursor.fetchall()]
|
out = [row[0] for row in cursor.fetchall()]
|
||||||
@ -109,6 +115,7 @@ class Phpbb3Manager:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __create_group(groupname):
|
def __create_group(groupname):
|
||||||
|
logger.debug("Creating phpbb3 group %s" % groupname)
|
||||||
cursor = connections['phpbb3'].cursor()
|
cursor = connections['phpbb3'].cursor()
|
||||||
cursor.execute(Phpbb3Manager.SQL_ADD_GROUP, [groupname, groupname])
|
cursor.execute(Phpbb3Manager.SQL_ADD_GROUP, [groupname, groupname])
|
||||||
logger.info("Created phpbb group %s" % groupname)
|
logger.info("Created phpbb group %s" % groupname)
|
||||||
@ -116,6 +123,7 @@ class Phpbb3Manager:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __add_user_to_group(userid, groupid):
|
def __add_user_to_group(userid, groupid):
|
||||||
|
logger.debug("Adding phpbb3 user id %s to group id %s" % (userid, groupid))
|
||||||
try:
|
try:
|
||||||
cursor = connections['phpbb3'].cursor()
|
cursor = connections['phpbb3'].cursor()
|
||||||
cursor.execute(Phpbb3Manager.SQL_ADD_USER_GROUP, [groupid, userid, 0])
|
cursor.execute(Phpbb3Manager.SQL_ADD_USER_GROUP, [groupid, userid, 0])
|
||||||
@ -126,6 +134,7 @@ class Phpbb3Manager:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __remove_user_from_group(userid, groupid):
|
def __remove_user_from_group(userid, groupid):
|
||||||
|
logger.debug("Removing phpbb3 user id %s from group id %s" % (userid, groupid))
|
||||||
cursor = connections['phpbb3'].cursor()
|
cursor = connections['phpbb3'].cursor()
|
||||||
try:
|
try:
|
||||||
cursor.execute(Phpbb3Manager.SQL_REMOVE_USER_GROUP, [userid, groupid])
|
cursor.execute(Phpbb3Manager.SQL_REMOVE_USER_GROUP, [userid, groupid])
|
||||||
@ -155,9 +164,9 @@ class Phpbb3Manager:
|
|||||||
"", ""])
|
"", ""])
|
||||||
Phpbb3Manager.update_groups(username_clean, groups)
|
Phpbb3Manager.update_groups(username_clean, groups)
|
||||||
Phpbb3Manager.__add_avatar(username_clean, characterid)
|
Phpbb3Manager.__add_avatar(username_clean, characterid)
|
||||||
logger.info("Added phpbb user %s" % username)
|
logger.info("Added phpbb user %s" % username_clean)
|
||||||
except:
|
except:
|
||||||
logger.exception("Unable to add phpbb user %s" % username, exc_info=True)
|
logger.exception("Unable to add phpbb user %s" % username_clean, exc_info=True)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return username_clean, password
|
return username_clean, password
|
||||||
@ -168,7 +177,7 @@ class Phpbb3Manager:
|
|||||||
cursor = connections['phpbb3'].cursor()
|
cursor = connections['phpbb3'].cursor()
|
||||||
|
|
||||||
password = Phpbb3Manager.__gen_hash(Phpbb3Manager.__generate_random_pass())
|
password = Phpbb3Manager.__gen_hash(Phpbb3Manager.__generate_random_pass())
|
||||||
revoke_email = "revoked@the99eve.com"
|
revoke_email = "revoked@" + settings.DOMAIN
|
||||||
try:
|
try:
|
||||||
pwhash = Phpbb3Manager.__gen_hash(password)
|
pwhash = Phpbb3Manager.__gen_hash(password)
|
||||||
cursor.execute(Phpbb3Manager.SQL_DIS_USER, [revoke_email, pwhash, username])
|
cursor.execute(Phpbb3Manager.SQL_DIS_USER, [revoke_email, pwhash, username])
|
||||||
@ -187,7 +196,7 @@ class Phpbb3Manager:
|
|||||||
cursor.execute(Phpbb3Manager.SQL_DEL_USER, [username])
|
cursor.execute(Phpbb3Manager.SQL_DEL_USER, [username])
|
||||||
logger.info("Deleted phpbb user %s" % username)
|
logger.info("Deleted phpbb user %s" % username)
|
||||||
return True
|
return True
|
||||||
logger.warn("Unable to delete phpbb user %s - user not found on phpbb." % username)
|
logger.error("Unable to delete phpbb user %s - user not found on phpbb." % username)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -230,7 +239,6 @@ class Phpbb3Manager:
|
|||||||
def check_user(username):
|
def check_user(username):
|
||||||
logger.debug("Checking phpbb username %s" % username)
|
logger.debug("Checking phpbb username %s" % username)
|
||||||
cursor = connections['phpbb3'].cursor()
|
cursor = connections['phpbb3'].cursor()
|
||||||
""" Check if the username exists """
|
|
||||||
cursor.execute(Phpbb3Manager.SQL_USER_ID_FROM_USERNAME, [Phpbb3Manager.__santatize_username(username)])
|
cursor.execute(Phpbb3Manager.SQL_USER_ID_FROM_USERNAME, [Phpbb3Manager.__santatize_username(username)])
|
||||||
row = cursor.fetchone()
|
row = cursor.fetchone()
|
||||||
if row:
|
if row:
|
||||||
|
@ -74,7 +74,7 @@ class Teamspeak3Manager:
|
|||||||
server.send_command('servergroupaddperm',
|
server.send_command('servergroupaddperm',
|
||||||
{'sgid': sgid, 'permsid': 'i_group_needed_member_remove_power', 'permvalue': 100,
|
{'sgid': sgid, 'permsid': 'i_group_needed_member_remove_power', 'permvalue': 100,
|
||||||
'permnegated': 0, 'permskip': 0})
|
'permnegated': 0, 'permskip': 0})
|
||||||
logger.info("Created group on TS3 server with name %s and id %s" % (groupname, sqid))
|
logger.info("Created group on TS3 server with name %s and id %s" % (groupname, sgid))
|
||||||
return sgid
|
return sgid
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -109,7 +109,7 @@ class Teamspeak3Manager:
|
|||||||
logger.debug("Assigning name/id dict: %s = %s" % (group['keys']['name'], group['keys']['sgid']))
|
logger.debug("Assigning name/id dict: %s = %s" % (group['keys']['name'], group['keys']['sgid']))
|
||||||
outlist[group['keys']['name']] = group['keys']['sgid']
|
outlist[group['keys']['name']] = group['keys']['sgid']
|
||||||
else:
|
else:
|
||||||
logger.error("Received empty group cache while retrieving group cache from TS3 server. 1024 error.", exc_info=True)
|
logger.error("Received empty group cache while retrieving group cache from TS3 server. 1024 error.")
|
||||||
logger.debug("Returning name/id pairing: %s" % outlist)
|
logger.debug("Returning name/id pairing: %s" % outlist)
|
||||||
return outlist
|
return outlist
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ class Teamspeak3Manager:
|
|||||||
logger.debug("Local group does not exist for TS group %s. Creating TSgroup model %s" % (remote_groups[key], g))
|
logger.debug("Local group does not exist for TS group %s. Creating TSgroup model %s" % (remote_groups[key], g))
|
||||||
g.save()
|
g.save()
|
||||||
except:
|
except:
|
||||||
logger.debug("An unhandled exception has occured while syncinc TS groups.", exc_info=True)
|
logger.exception("An unhandled exception has occured while syncing TS groups.", exc_info=True)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -189,7 +189,7 @@ class Teamspeak3Manager:
|
|||||||
token = ret['keys']['token']
|
token = ret['keys']['token']
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
logger.info("Created user %s on TS3 server, got token %s" % (username_clean, token))
|
logger.info("Created permission token for user %s on TS3 server" % username_clean)
|
||||||
|
|
||||||
return username_clean, token
|
return username_clean, token
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ class Teamspeak3Manager:
|
|||||||
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
logger.info("Created blue user %s on TS3 server, got token %s" % (username_clean, token))
|
logger.info("Created permission token for blue user %s on TS3 server" % username_clean)
|
||||||
|
|
||||||
return username_clean, token
|
return username_clean, token
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ class Teamspeak3Manager:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def generate_new_permissionkey(uid, username, corpticker):
|
def generate_new_permissionkey(uid, username, corpticker):
|
||||||
logger.debug("Re-issuing permission key for user id %s." % uid)
|
logger.debug("Re-issuing permission key for user id %s" % uid)
|
||||||
Teamspeak3Manager.delete_user(uid)
|
Teamspeak3Manager.delete_user(uid)
|
||||||
return Teamspeak3Manager.add_user(username, corpticker)
|
return Teamspeak3Manager.add_user(username, corpticker)
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ class Teamspeak3Manager:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def update_groups(uid, ts_groups):
|
def update_groups(uid, ts_groups):
|
||||||
logger.debug("Updating uid %s groups %s" % (uid, ts_groups))
|
logger.debug("Updating uid %s TS3 groups %s" % (uid, ts_groups))
|
||||||
userid = Teamspeak3Manager._get_userid(uid)
|
userid = Teamspeak3Manager._get_userid(uid)
|
||||||
addgroups = []
|
addgroups = []
|
||||||
remgroups = []
|
remgroups = []
|
||||||
@ -279,7 +279,7 @@ class Teamspeak3Manager:
|
|||||||
if user_ts_groups[user_ts_group_key] not in ts_groups.values():
|
if user_ts_groups[user_ts_group_key] not in ts_groups.values():
|
||||||
remgroups.append(user_ts_groups[user_ts_group_key])
|
remgroups.append(user_ts_groups[user_ts_group_key])
|
||||||
|
|
||||||
logger.info("Finished checking user id %s groups. Adding %s, removing %s." % (userid, addgroups, remgroups))
|
logger.info("Finished checking user id %s TS3 groups - adding %s, removing %s." % (userid, addgroups, remgroups))
|
||||||
|
|
||||||
for g in addgroups:
|
for g in addgroups:
|
||||||
logger.debug("Issuing add command for group %s" % g)
|
logger.debug("Issuing add command for group %s" % g)
|
||||||
|
@ -35,7 +35,7 @@ def remove_user_from_group(user, groupname):
|
|||||||
user.save()
|
user.save()
|
||||||
logger.info("Removed user %s from group %s" % (user, group))
|
logger.info("Removed user %s from group %s" % (user, group))
|
||||||
else:
|
else:
|
||||||
logger.warn("Unable to remove user %s from groyp %s - user not in group." % (user, group))
|
logger.warn("Unable to remove user %s from group %s - user not in group." % (user, group))
|
||||||
|
|
||||||
|
|
||||||
def deactivate_services(user):
|
def deactivate_services(user):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user