def get_vessel_acquisition_counts_by_user(): # Set the log level high enough so that we don't produce a bunch of logging # output due to the logging decorators. initial_log_level = log.loglevel log.set_log_level(log.LOG_LEVEL_INFO) vessel_acquisition_dict = {} for user in GeniUser.objects.all(): acquired_vessels = maindb.get_acquired_vessels(user) if len(acquired_vessels) > 0: vessel_acquisition_dict[user.username] = len(acquired_vessels) # Restore the original log level. log.set_log_level(initial_log_level) return vessel_acquisition_dict
def get_available_vessel_counts_by_port(): # Set the log level high enough so that we don't produce a bunch of logging # output due to the logging decorators. initial_log_level = log.loglevel log.set_log_level(log.LOG_LEVEL_INFO) available_vessels_dict = {} for port in maindb.ALLOWED_USER_PORTS: available_vessels_dict[port] = {} available_vessels_dict[port]["all"] = maindb._get_queryset_of_all_available_vessels_for_a_port_include_nat_nodes(port).count() available_vessels_dict[port]["no_nat"] = maindb._get_queryset_of_all_available_vessels_for_a_port_exclude_nat_nodes(port).count() available_vessels_dict[port]["only_nat"] = maindb._get_queryset_of_all_available_vessels_for_a_port_only_nat_nodes(port).count() # Restore the original log level. log.set_log_level(initial_log_level) return available_vessels_dict
def get_donation_counts_by_user(): # Set the log level high enough so that we don't produce a bunch of logging # output due to the logging decorators. initial_log_level = log.loglevel log.set_log_level(log.LOG_LEVEL_INFO) donation_dict = {} for user in GeniUser.objects.all(): active_donation_count = len(maindb.get_donations_by_user(user)) inactive_donation_count = len(maindb.get_donations_by_user(user, include_inactive_and_broken=True)) - active_donation_count if active_donation_count > 0 or inactive_donation_count > 0: donation_dict[user.username] = (active_donation_count, inactive_donation_count) # Restore the original log level. log.set_log_level(initial_log_level) return donation_dict
# it and set DEBUG = True ALLOWED_HOSTS = ["example.com"] # If DEBUG is True, then error details will be shown on the website and ADMINS # will not receive an email when an error occurs. So, this should be False in # production. DEBUG = True TEMPLATE_DEBUG = DEBUG # The log level used by the clearinghouse log module. All messages at this level # or more severe will be logged. SEATTLECLEARINGHOUSE_LOG_LEVEL = log.LOG_LEVEL_DEBUG # Rather than make the log module have to import this settings file to set the # log level, just set it right here. log.set_log_level(SEATTLECLEARINGHOUSE_LOG_LEVEL) # This is needed to allow xmlrpc requests to work when they don't have a slash # on the end of the url. APPEND_SLASH = False # Required for mod_wsgi (which replaces mod_python), the Apache Python interface WSGI_APPLICATION = "clearinghouse.wsgi.wsgi.application" # The directory the settings.py file is in is what we consider the root of the website. SEATTLECLEARINGHOUSE_WEBSITE_ROOT = os.path.dirname(__file__) # The directory where we keep the public keys of the node state keys. SEATTLECLEARINGHOUSE_STATE_KEYS_DIR = os.path.join( SEATTLECLEARINGHOUSE_WEBSITE_ROOT, '..', 'node_state_transitions', 'statekeys')
""" import sys import time from clearinghouse.common.api import lockserver from clearinghouse.common.api import maindb from clearinghouse.common.util import log from clearinghouse.common.exceptions import * # Set the log level high enough so that we don't produce a bunch of logging # output due to the logging decorators. initial_log_level = log.loglevel log.set_log_level(log.LOG_LEVEL_INFO) def stop_all_vessels_on_node(node_id): try: node = maindb.get_node(node_id) except DoesNotExistError: print "No such node" sys.exit(1) if not node.is_active: print "This node is marked as inactive, thus the backend will not try to clean up vessels." sys.exit(0)
# If DEBUG is True, then error details will be shown on the website and ADMINS # will not receive an email when an error occurs. So, this should be False in # production. DEBUG = True TEMPLATE_DEBUG = DEBUG # The log level used by the clearinghouse log module. All messages at this level # or more severe will be logged. SEATTLECLEARINGHOUSE_LOG_LEVEL = log.LOG_LEVEL_DEBUG # Rather than make the log module have to import this settings file to set the # log level, just set it right here. log.set_log_level(SEATTLECLEARINGHOUSE_LOG_LEVEL) # This is needed to allow xmlrpc requests to work when they don't have a slash # on the end of the url. APPEND_SLASH = False # Required for mod_wsgi (which replaces mod_python), the Apache Python interface WSGI_APPLICATION = "clearinghouse.website.wsgi.application" # The directory the settings.py file is in is what we consider the root of the website. SEATTLECLEARINGHOUSE_WEBSITE_ROOT = os.path.dirname(__file__) # The directory where we keep the public keys of the node state keys. SEATTLECLEARINGHOUSE_STATE_KEYS_DIR = os.path.join(SEATTLECLEARINGHOUSE_WEBSITE_ROOT, '..', 'node_state_transitions', 'statekeys') # The XML-RPC interface to the Custom Installer Builder.
""" import sys import time from clearinghouse.common.api import lockserver from clearinghouse.common.api import maindb from clearinghouse.common.util import log from clearinghouse.website.control import vessels from clearinghouse.common.exceptions import * # Set the log level high enough so that we don't produce a bunch of logging # output due to the logging decorators. initial_log_level = log.loglevel log.set_log_level(log.LOG_LEVEL_INFO) def ban_user_and_remove_vessels(username): try: geniuser = maindb.get_user(username, allow_inactive=True) except DoesNotExistError: print "No such user: %s." % username sys.exit(1) # Lock the user. lockserver_handle = lockserver.create_lockserver_handle() lockserver.lock_user(lockserver_handle, geniuser.username) try: