[163] | 1 | #!/usr/bin/env python |
---|
| 2 | # -*- coding: utf-8 -*- |
---|
| 3 | |
---|
[363] | 4 | # Copyright Puzzlebox Productions, LLC (2010-2012) |
---|
[163] | 5 | # |
---|
| 6 | # This code is released under the GNU Pulic License (GPL) version 2 |
---|
| 7 | # For more information please refer to http://www.gnu.org/copyleft/gpl.html |
---|
| 8 | |
---|
[367] | 9 | import Puzzlebox.Synapse.ThinkGear.Server as thinkgear_server |
---|
[363] | 10 | import Puzzlebox.Synapse.Configuration as configuration |
---|
[163] | 11 | |
---|
| 12 | import sys, signal |
---|
| 13 | |
---|
| 14 | try: |
---|
| 15 | import PySide as PyQt4 |
---|
| 16 | from PySide import QtCore |
---|
| 17 | except: |
---|
| 18 | print "Using PyQt4 module" |
---|
| 19 | from PyQt4 import QtCore |
---|
| 20 | else: |
---|
| 21 | print "Using PySide module" |
---|
| 22 | |
---|
[271] | 23 | DEBUG = 1 |
---|
| 24 | |
---|
[163] | 25 | # Perform correct KeyboardInterrupt handling |
---|
| 26 | signal.signal(signal.SIGINT, signal.SIG_DFL) |
---|
| 27 | log = None |
---|
| 28 | |
---|
[363] | 29 | server_interface = configuration.THINKGEAR_SERVER_INTERFACE |
---|
| 30 | server_port = configuration.THINKGEAR_SERVER_PORT |
---|
| 31 | device_address = configuration.THINKGEAR_DEVICE_SERIAL_PORT |
---|
| 32 | #device_id = configuration.THINKGEAR_DEVICE_ID |
---|
[163] | 33 | |
---|
| 34 | for each in sys.argv: |
---|
| 35 | if each.startswith("--interface="): |
---|
| 36 | server_interface = each[ len("--interface="): ] |
---|
| 37 | if each.startswith("--port="): |
---|
| 38 | server_port = each[ len("--port="): ] |
---|
| 39 | if each.startswith("--device="): |
---|
| 40 | device_address = each[ len("--device="): ] |
---|
[271] | 41 | if each.startswith("--debug="): |
---|
| 42 | DEBUG = int (each[ len("--debug="): ] ) |
---|
[272] | 43 | if each.startswith("--id="): |
---|
| 44 | device_id = int (each[ len("--id="): ] ) |
---|
[163] | 45 | |
---|
| 46 | app = QtCore.QCoreApplication(sys.argv) |
---|
[367] | 47 | server = thinkgear_server.puzzlebox_synapse_server_thinkgear(log, \ |
---|
[363] | 48 | server_interface, \ |
---|
| 49 | server_port, \ |
---|
| 50 | device_address, \ |
---|
| 51 | #device_id, \ |
---|
| 52 | emulate_headset_data = configuration.THINKGEAR_ENABLE_SIMULATE_HEADSET_DATA, \ |
---|
| 53 | DEBUG=DEBUG) |
---|
[163] | 54 | server.start() |
---|
[367] | 55 | sys.exit(app.exec_()) |
---|