Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 1 file changed
  • 0 comments
  • 1 contributor

Showing 1 changed file with 20 additions and 10 deletions. Show diff stats Hide diff stats

  1. +20 10 python/code_companion_message_server.py
30 python/code_companion_message_server.py
... ... @@ -1,9 +1,18 @@
  1 +import json
  2 +import sqlite3
  3 +
1 4 from twisted.protocols.basic import LineReceiver
2 5 from twisted.internet.protocol import Factory
3 6 from twisted.internet.endpoints import TCP4ServerEndpoint
4 7 from twisted.internet import reactor
5 8
6   -from code_companion import CodeCompanion
  9 +
  10 +APP_APPID_MAP = {
  11 + 'TESTIFY': 1,
  12 + # 2: 'gitprecommit',
  13 + # 3: 'trac',
  14 + # 4: 'happymaker'
  15 +}
7 16
8 17 class MessageReceiver(LineReceiver):
9 18
@@ -11,22 +20,23 @@ def lineReceived(self, line):
11 20 print "Got a line:", line
12 21 app, message = line.split(' ', 1)
13 22
  23 +
14 24 if message == "FAIL":
15   - self.factory.code_companion.set_led_color("red")
  25 + data = {'pass': True, 'success': True}
16 26 elif message == "PASS":
17   - self.factory.code_companion.set_led_color("green")
  27 + data = {'pass': False, 'success': True}
18 28 else:
19   - self.factory.code_companion.set_led_color("blue")
  29 + data = {'success': False}
  30 +
  31 + appid = APP_APPID_MAP[app]
  32 + dbcon = sqlite3.connect('cc_messages.db')
  33 + dbcon.execute('insert into cc_messages (appid, created, data_blob) values (%s, %s, %s)' % (appid, int(time.time()), json.dumps(data)))
20 34
21 35
22 36 class MessageReceiverFactory(Factory):
23   -
24   - protocol = MessageReceiver
25 37
26   - def startFactory(self):
27   - self.code_companion = CodeCompanion()
  38 + protocol = MessageReceiver
28 39
29 40 endpoint = TCP4ServerEndpoint(reactor, 8080)
30 41 endpoint.listen(MessageReceiverFactory())
31   -reactor.run()
32   -
  42 +reactor.run()

No commit comments for this range

Something went wrong with that request. Please try again.