Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: zparmley/YHCodeCompanion
base: 1ae1fa1960
...
head fork: zparmley/YHCodeCompanion
compare: edc965866d
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 20 additions and 10 deletions.
  1. +20 −10 python/code_companion_message_server.py
View
30 python/code_companion_message_server.py
@@ -1,9 +1,18 @@
+import json
+import sqlite3
+
from twisted.protocols.basic import LineReceiver
from twisted.internet.protocol import Factory
from twisted.internet.endpoints import TCP4ServerEndpoint
from twisted.internet import reactor
-from code_companion import CodeCompanion
+
+APP_APPID_MAP = {
+ 'TESTIFY': 1,
+ # 2: 'gitprecommit',
+ # 3: 'trac',
+ # 4: 'happymaker'
+}
class MessageReceiver(LineReceiver):
@@ -11,22 +20,23 @@ def lineReceived(self, line):
print "Got a line:", line
app, message = line.split(' ', 1)
+
if message == "FAIL":
- self.factory.code_companion.set_led_color("red")
+ data = {'pass': True, 'success': True}
elif message == "PASS":
- self.factory.code_companion.set_led_color("green")
+ data = {'pass': False, 'success': True}
else:
- self.factory.code_companion.set_led_color("blue")
+ data = {'success': False}
+
+ appid = APP_APPID_MAP[app]
+ dbcon = sqlite3.connect('cc_messages.db')
+ dbcon.execute('insert into cc_messages (appid, created, data_blob) values (%s, %s, %s)' % (appid, int(time.time()), json.dumps(data)))
class MessageReceiverFactory(Factory):
-
- protocol = MessageReceiver
- def startFactory(self):
- self.code_companion = CodeCompanion()
+ protocol = MessageReceiver
endpoint = TCP4ServerEndpoint(reactor, 8080)
endpoint.listen(MessageReceiverFactory())
-reactor.run()
-
+reactor.run()

No commit comments for this range

Something went wrong with that request. Please try again.