source: remote_control/puzzlebox_brainstorms_client_local.py @ 63

Last change on this file since 63 was 45, checked in by sc, 11 years ago

client_interface:

  • converted to a standalone object

client_local:

  • intitial checkin
  • launches both server and client interface

client_network:

  • initial checkin
  • launches network-connected version of client interface

configuration.ini

  • initial checkin
  • overrides default settings found in configuration.py

configuration.py

  • function added to import settings from configuration.ini file

setup.py:

  • fully working py2exe script
File size: 3.7 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#
4# Puzzlebox - Brainstorms - Client Interface - Local
5#
6# Copyright Puzzlebox Productions, LLC (2010)
7#
8# This code is released under the GNU Pulic License (GPL) version 2
9# For more information please refer to http://www.gnu.org/copyleft/gpl.html
10#
11# Last Update: 2010.06.10
12#
13#####################################################################
14
15import os, sys
16
17import pygame
18#import pygame.font
19import pygame.image
20import pygame.locals
21
22from twisted.internet import reactor, protocol, defer
23
24import puzzlebox_brainstorms_configuration as configuration
25import puzzlebox_brainstorms_client_interface as client_interface
26import puzzlebox_brainstorms_server as server
27#import puzzlebox_logger
28
29#####################################################################
30# Globals
31#####################################################################
32
33DEBUG = 1
34
35SERVER_INTERFACE = configuration.SERVER_INTERFACE
36SERVER_HOST = configuration.SERVER_HOST
37SERVER_PORT = configuration.SERVER_PORT
38
39DISPLAY_WINDOW_X_COORDINATE = configuration.DISPLAY_WINDOW_X_COORDINATE
40DISPLAY_WINDOW_Y_COORDINATE = configuration.DISPLAY_WINDOW_Y_COORDINATE
41DISPLAY_WINDOW_X_DIMENSION = configuration.DISPLAY_WINDOW_X_DIMENSION
42DISPLAY_WINDOW_Y_DIMENSION = configuration.DISPLAY_WINDOW_Y_DIMENSION
43
44WINDOW_BACKGROUND_COLOR = configuration.WINDOW_BACKGROUND_COLOR
45
46#####################################################################
47# Classes
48#####################################################################
49
50#####################################################################
51# Functions
52#####################################################################
53
54#####################################################################
55# Main
56#####################################################################
57
58if __name__ == '__main__':
59       
60        #log = puzzlebox_logger.puzzlebox_logger(logfile='puzzlebox')
61        log = None
62       
63       
64        # Collect default settings and command line parameters
65        server_interface = SERVER_INTERFACE
66        server_host = SERVER_HOST
67        server_port = SERVER_PORT
68        display_window_x_coordinate = DISPLAY_WINDOW_X_COORDINATE
69        display_window_y_coordinate = DISPLAY_WINDOW_Y_COORDINATE
70        display_window_x_dimension = DISPLAY_WINDOW_X_DIMENSION
71        display_window_y_dimension = DISPLAY_WINDOW_Y_DIMENSION
72        window_background_color = WINDOW_BACKGROUND_COLOR
73       
74       
75        for each in sys.argv:
76               
77                if each.startswith("--interface="):
78                        server_interface = each[ len("--interface="): ]
79                if each.startswith("--host="):
80                        server_host = each[ len("--host="): ]
81                if each.startswith("--port="):
82                        server_port = each[ len("--port="): ]
83       
84       
85        # Window Defaults
86        try:
87                display_window_x_coordinate = string.atoi(sys.argv[-4])
88                display_window_y_coordinate = string.atoi(sys.argv[-3])
89                display_window_x_dimension = string.atoi(sys.argv[-2])
90                display_window_y_dimension = string.atoi(sys.argv[-1])
91        except:
92                if DEBUG > 1:
93                        print "Using default display coordinates"
94       
95               
96        embedded_server = server.puzzlebox_brainstorms_server(log, DEBUG=DEBUG)
97       
98        if DEBUG:
99                print "--> [Server] Initializing server on %s:%i" % \
100                        (server_interface, server_port)
101       
102        reactor.listenTCP(interface=server_interface, port=server_port, factory=embedded_server)
103       
104
105        interface = client_interface.puzzlebox_brainstorms_client_interface( \
106                                             log, \
107                                             display_window_x_coordinate, \
108                                             display_window_y_coordinate, \
109                                             display_window_x_dimension, \
110                                             display_window_y_dimension, \
111                                             window_background_color, \
112                                             DEBUG=DEBUG)
113       
114        reactor.callWhenRunning(interface.check_events)
115
116       
117        reactor.run()
118
Note: See TracBrowser for help on using the repository browser.