예제 #1
0
    def __init__(self, db='mongodb'):
        """
        Initiates the current game mode.

        Args:
            db: The database to run the game with. One of Mode.possible_dbs
        """
        self.ui = ConsoleUI()
        self.db = self.possible_dbs[db]()
예제 #2
0
def ui():
    updating_libs()
    console_ui = ConsoleUI()
    default_msg = "Comment posted by AutolikeBot\n======CODED BY PFUB======="
    returned = console_ui.main_menu()
    message = input("Input message (if not, bot will use default message): ")
    group = int(input("Input group id: "))
    if not group:
        while not group:
            group = int(input("Input group id: "))
    data = returned
    if message:
        main(data, message, group)
    else:
        main(data, default_msg, group)
예제 #3
0
    def __init__(self, configuration_files=None):
        super(Controller, self).__init__()

        for configuration_file in configuration_files:
            if not os.path.exists(configuration_file):
                print >> sys.stderr, "Could not file configuration file", configuration_file
                sys.exit(1)

            execfile(configuration_file, globals(), globals())

        global_vars = globals()

        self.db_host = get_variable(global_vars, configuration_doc.DB_HOST)
        self.db_engine = get_variable(global_vars, configuration_doc.DB_ENGINE)
        self.db_name = get_variable(global_vars, configuration_doc.DB_DATABASE)
        self.db_user = get_variable(global_vars,
                                    configuration_doc.WEBLAB_DB_USERNAME)
        self.db_pass = get_variable(global_vars,
                                    configuration_doc.WEBLAB_DB_PASSWORD)

        self.smtp_host = globals().get(configuration_doc.MAIL_SERVER_HOST)
        self.smtp_helo = globals().get(configuration_doc.MAIL_SERVER_HELO)

        self.default_db_name = self.db_name
        self.default_db_user = self.db_user
        self.default_db_pass = self.db_pass

        self.default_ldap_users_file = 'USERS'
        self.default_openid_users_file = 'USERSOID'
        self.default_db_users_file = 'USERSDB'

        self.default_notification_from = globals().get(
            configuration_doc.MAIL_NOTIFICATION_SENDER)
        self.default_notification_bcc = globals().get(
            configuration_doc.SERVER_ADMIN)
        self.default_notification_subject = 'WebLab-Deusto notification'

        self.default_notification_text_file = 'NOTIFICATION'
        self.default_notification_with_password_text_file = 'NOTIFICATION_WITH_PASSWORD'

        self.ui = ConsoleUI()
        self.init()
        self.menu()
예제 #4
0
# from test import test_service, test_service2
# test_service2()
from console_ui import ConsoleUI
from service import Service

if __name__ == '__main__':
    service = Service()
    console_ui = ConsoleUI(service)
    console_ui.run()
예제 #5
0
def encode_data(file_name, new_file_name):
    coords = []
    with open('tests/' + file_name, 'r') as file:
        for line in file.readlines():
            _, lat, lon = line.split(' ')
            lat = float(lat)
            lon = float(lon)
            coords.append([lat, lon])
    distance_matrix = []

    def euclidean(A, B):
        return math.sqrt((A[0] - B[0]) ** 2 + (A[1] - B[1]) ** 2)

    for i in range(len(coords)):
        row = []
        for j in range(len(coords)):
            row.append(round(euclidean(coords[i], coords[j])))
        distance_matrix.append(row)

    with open('tests/' + new_file_name, "w") as file:
        file.write(str(len(distance_matrix)) + '\n')
        for row in distance_matrix:
            file.write(','.join(map(lambda x: str(x), row)) + '\n')

    print("Finished encoding", file_name, '....')

from timeit import default_timer as timer

if __name__ == '__main__':
   ui = ConsoleUI()
   ui.run()
예제 #6
0
from console_ui import ConsoleUI
import platform
import sys

if __name__ == "__main__":
    ui = ConsoleUI(platform.system())
    ui.run()
    sys.exit()