예제 #1
0
    def test_server_upload_across_batches(self, mock_upload_comments,
                                          mock_upload_messages,
                                          mock_fill_message_directory):
        archive_index = ArchiveMessageIndex(MessageDao())
        messages = archive_index.update('test_data')
        first_batch = messages[0:6]
        second_batch = messages[6:]
        mock_fill_message_directory.return_value = ''

        # declaring mock objects here because I want to use the ArchiveMessageIndex functionality to build the test data
        with mock.patch.object(ArchiveMessageIndex,
                               'update') as mock_update, mock.patch.object(
                                   MessageDao, 'get') as mock_get:
            mock_update.side_effect = [first_batch, second_batch]
            mock_get.side_effect = [None, None, messages[6], messages[7]]
            server = Server()
            server.update_convert_upload()
            mock_upload_messages.assert_called_with(
                [messages[2].id, messages[3].id])
            mock_upload_comments.assert_called_with(set())

            server.update_convert_upload()
            mock_upload_messages.assert_called_with(
                [messages[6].id, messages[7].id])
            mock_upload_comments.assert_called_with(set())
예제 #2
0
import os
from main import Server

conf = os.path.join(os.path.dirname(__file__), "settings.conf")

if __name__ == '__main__':
    import cherrypy
    cherrypy.quickstart(Server(), config=conf)
예제 #3
0
 def setUp(self):
     args = parse_args()
     self.server = Server((args.a, args.p))
예제 #4
0
def create_app(loop):
    return Server(loop=loop)
from main import Server
from handlers.config import read_config

if __name__ == '__main__':
    server = Server(read_config("/etc/httpd.conf"))
    server.server_init()
예제 #6
0
 async def get_application(self, loop):
     self.server = Server(loop=loop)
     return self.server.app
예제 #7
0
from main import Server

server = Server()

while (True):
    server.send(raw_input())
    def server_start_stop_command(self):
        """
        Start the server
        :return: None
        """
        if self.ui.server.server_is_on:
            if not self.player_2_is_connected or tkinter.messagebox.askquestion(
                    self.ui.translation.get_translation(
                        "server_dialog_server_stop_title"),
                    self.ui.translation.get_translation(
                        "server_dialog_server_stop_message")
            ) == tkinter.messagebox.YES:
                if self.ui.server.stop_server():
                    self.server_port_spin_box.configure(
                        state=tkinter.tix.NORMAL, increment=1)
                    self.server_start_stop.configure(
                        text=self.ui.translation.get_translation(
                            "server_configuration_start"))

                    self.server_state_label.configure(
                        text=self.ui.translation.get_translation(
                            "server_state_stopped"),
                        fg="#ee2e31")
        else:
            try:
                port = int(self.server_port_spin_box.get())
            except ValueError:
                tkinter.messagebox.showerror(
                    self.ui.translation.get_translation(
                        "server_configuration_dialog_port_error_title"),
                    self.ui.translation.get_translation(
                        "server_configuration_dialog_port_error_message"))

            else:
                if 3000 <= port <= 3020:
                    self.ui.server = Server.Server(
                        port=port,
                        max_clients_connected=1,
                        on_message_function=self.server_on_message,
                        on_client_connect_function=self.
                        server_on_client_connect_function,
                        on_client_disconnect_function=self.
                        server_on_client_disconnect_function)
                    result = self.ui.server.start_server()
                    if result[0]:
                        self.server_port_spin_box.configure(state="readonly",
                                                            increment=0)
                        self.server_start_stop.configure(
                            text=self.ui.translation.get_translation(
                                "server_configuration_stop"))

                        self.server_state_label.configure(
                            text=self.ui.translation.get_translation(
                                "server_state_started"),
                            fg="#78bc61")
                    else:
                        error_name = errno.errorcode[result[1]]
                        if self.ui.translation.translation_exist(
                                SERVER_ERROR_DIALOG_KEY_FORMAT.format(
                                    error_name)):
                            tkinter.messagebox.showerror(
                                self.ui.translation.get_translation(
                                    "server_start_error_dialog_title").format(
                                        result[1]),
                                self.ui.translation.get_translation(
                                    SERVER_ERROR_DIALOG_KEY_FORMAT.format(
                                        error_name)))
                        else:
                            tkinter.messagebox.showerror(
                                self.ui.translation.get_translation(
                                    "server_start_error_dialog_title").format(
                                        result[1]),
                                self.ui.translation.get_translation(
                                    "server_start_error_unknown_dialog_message"
                                ).format(result[1], error_name,
                                         result[2].strerror))

                else:
                    tkinter.messagebox.showerror(
                        self.ui.translation.get_translation(
                            "server_configuration_dialog_port_error_title"),
                        self.ui.translation.get_translation(
                            "server_configuration_dialog_port_error_message"))
예제 #9
0
from main import Server
from dotenv import load_dotenv

load_dotenv()
app = Server().config_app()