1 | #!/usr/bin/env python |
---|
2 | # -*- coding: utf-8 -*- |
---|
3 | # |
---|
4 | # Puzzlebox - ThinkGear Emulator - Configuration |
---|
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.22 |
---|
12 | # |
---|
13 | ##################################################################### |
---|
14 | |
---|
15 | import os, sys |
---|
16 | |
---|
17 | ##################################################################### |
---|
18 | # General configuration |
---|
19 | ##################################################################### |
---|
20 | |
---|
21 | DEBUG = 1 |
---|
22 | |
---|
23 | CONFIGURATION_FILE_PATH = 'puzzlebox_thinkgear_emulator_configuration.ini' |
---|
24 | |
---|
25 | |
---|
26 | ##################################################################### |
---|
27 | # Network addresses |
---|
28 | ##################################################################### |
---|
29 | |
---|
30 | SERVER_INTERFACE = '' # listen on all of server's network interfaces |
---|
31 | THINKGEAR_SERVER_HOST = '127.0.0.1' |
---|
32 | THINKGEAR_SERVER_PORT = 13854 |
---|
33 | |
---|
34 | |
---|
35 | ##################################################################### |
---|
36 | # ThinkGear Connect configuration |
---|
37 | ##################################################################### |
---|
38 | |
---|
39 | ENABLE_THINKGEAR_AUTHORIZATION = False |
---|
40 | |
---|
41 | THINKGEAR_AUTHORIZATION_REQUEST = { \ |
---|
42 | "appName": "Puzzlebox Brainstorms", \ |
---|
43 | "appKey": "2e285d7bd5565c0ea73e7e265c73f0691d932408" |
---|
44 | } |
---|
45 | |
---|
46 | |
---|
47 | ##################################################################### |
---|
48 | # Server configuration |
---|
49 | ##################################################################### |
---|
50 | |
---|
51 | MAX_COMPONENTS = 16 |
---|
52 | |
---|
53 | |
---|
54 | ##################################################################### |
---|
55 | # Client configuration |
---|
56 | ##################################################################### |
---|
57 | |
---|
58 | MAX_CONNECTION_ATTEMPTS = 5 |
---|
59 | HEALTH_CHECK_CONNECTION_ATTEMPTS = 5 |
---|
60 | NO_REPLY_WAIT = 10 # how many seconds before considering a component dead |
---|
61 | |
---|
62 | |
---|
63 | ##################################################################### |
---|
64 | # Flash socket policy handling |
---|
65 | ##################################################################### |
---|
66 | |
---|
67 | FLASH_POLICY_FILE_REQUEST = \ |
---|
68 | '<policy-file-request/>%c' % 0 # NULL byte termination |
---|
69 | FLASH_SOCKET_POLICY_FILE = '''<?xml version="1.0"?> |
---|
70 | <!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd"> |
---|
71 | <cross-domain-policy> |
---|
72 | <site-control permitted-cross-domain-policies="all" /> |
---|
73 | <allow-access-from domain="*" to-ports="%i" /> |
---|
74 | </cross-domain-policy>%c''' % (THINKGEAR_SERVER_PORT, 0) |
---|
75 | |
---|
76 | |
---|
77 | ##################################################################### |
---|
78 | # Configuration File Parser |
---|
79 | ##################################################################### |
---|
80 | |
---|
81 | if os.path.exists(CONFIGURATION_FILE_PATH): |
---|
82 | |
---|
83 | file = open(CONFIGURATION_FILE_PATH, 'r') |
---|
84 | |
---|
85 | for line in file.readlines(): |
---|
86 | line = line.strip() |
---|
87 | if len(line) == 0: |
---|
88 | continue |
---|
89 | if line[0] == '#': |
---|
90 | continue |
---|
91 | if line.find('=') == -1: |
---|
92 | continue |
---|
93 | try: |
---|
94 | exec line |
---|
95 | except: |
---|
96 | if DEBUG: |
---|
97 | print "Error recognizing configuration option:", |
---|
98 | print line |
---|
99 | |
---|