From 1e604f2408861120d8168a3f88c29f9da3ddf7df Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 19 Jul 2011 20:52:28 +0200 Subject: added initial version of cholerab-live --- cholerab/cholerab-live/cholerab.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 cholerab/cholerab-live/cholerab.py (limited to 'cholerab/cholerab-live/cholerab.py') diff --git a/cholerab/cholerab-live/cholerab.py b/cholerab/cholerab-live/cholerab.py new file mode 100644 index 00000000..4739d9cf --- /dev/null +++ b/cholerab/cholerab-live/cholerab.py @@ -0,0 +1,10 @@ +from view import CursesView + +a = CursesView() +a.start() +a.write_char(5,5,'p') +a.write_char(6,5,'e') +a.write_char(7,5,'n') +a.write_char(8,5,'i') +a.write_char(9,5,'s') +a.join() -- cgit v1.2.3 From 531d9d4309fa09e893a19fdcf8165dc7bf1b3731 Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 24 Jul 2011 02:41:13 +0200 Subject: added curses stuff cholerab-live/view.py: now able to write basic utf-8 on the plane, handles some rudimentary colors handles backspace correctly --- cholerab/cholerab-live/cholerab.py | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) mode change 100644 => 100755 cholerab/cholerab-live/cholerab.py (limited to 'cholerab/cholerab-live/cholerab.py') diff --git a/cholerab/cholerab-live/cholerab.py b/cholerab/cholerab-live/cholerab.py old mode 100644 new mode 100755 index 4739d9cf..0ac44e09 --- a/cholerab/cholerab-live/cholerab.py +++ b/cholerab/cholerab-live/cholerab.py @@ -1,10 +1,23 @@ +#!/usr/bin/python2 +# -*- coding: utf-8 -*- +import curses,time from view import CursesView - -a = CursesView() -a.start() -a.write_char(5,5,'p') -a.write_char(6,5,'e') -a.write_char(7,5,'n') -a.write_char(8,5,'i') -a.write_char(9,5,'s') -a.join() +import logging +logging.basicConfig(filename='here.log',level=logging.DEBUG) +log = logging.getLogger('main') +def main(scr): + log.debug('started main') + a = CursesView(scr=scr) + a.start() + log.debug + a.write_char(5,5,'p') + a.write_char(6,5,'e') + a.write_char(7,5,'n') + a.write_char(8,5,'i') + a.write_char(9,5,'s') + a.write_str(5,6,'¯\(°_o)/¯',user=2) + for i in range(7,11): + time.sleep(2) + a.write_str(5,i,'¯\(°_o)/¯',user=3) + a.join() +curses.wrapper(main) -- cgit v1.2.3 From f1f12489514f47f9154f8e4b6232399e747cfcd8 Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 24 Jul 2011 04:13:44 +0200 Subject: emergency commit --- cholerab/cholerab-live/cholerab.py | 43 +++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'cholerab/cholerab-live/cholerab.py') diff --git a/cholerab/cholerab-live/cholerab.py b/cholerab/cholerab-live/cholerab.py index 0ac44e09..b6b3f84f 100755 --- a/cholerab/cholerab-live/cholerab.py +++ b/cholerab/cholerab-live/cholerab.py @@ -2,22 +2,35 @@ # -*- coding: utf-8 -*- import curses,time from view import CursesView +from chol_net import CholerabMulicastNet import logging logging.basicConfig(filename='here.log',level=logging.DEBUG) log = logging.getLogger('main') -def main(scr): +class Cholerab: + def __init__(self): + self.view = CursesView(cholerab=self) + self.transport = CholerabMulicastNet(cholerab=self) + def send_char(self,x,y,char): + log.info("Sending %s at (%d,%d) to connected peers" %(char,x,y)) + self.transport.send_char(x,y,char) + + def write_char(self,x,y,char,user): + log.info("Writing %s at (%d,%d) from %d to view" %(char,x,y,user)) + self.view.write_char(x,y,char,user) + def stop(self): + self.view.stop() + self.transport.stop() + def main(self): + self.view.start() + self.transport.start() + self.view.join() + #after view dies, kill the transport as well + self.transport.stop() + self.transport.join() +def main(): log.debug('started main') - a = CursesView(scr=scr) - a.start() - log.debug - a.write_char(5,5,'p') - a.write_char(6,5,'e') - a.write_char(7,5,'n') - a.write_char(8,5,'i') - a.write_char(9,5,'s') - a.write_str(5,6,'¯\(°_o)/¯',user=2) - for i in range(7,11): - time.sleep(2) - a.write_str(5,i,'¯\(°_o)/¯',user=3) - a.join() -curses.wrapper(main) + chol = Cholerab() + chol.main() + +if __name__ == "__main__": + main() -- cgit v1.2.3 From 2862f1ad4ef0439721779a1a93e29bc5dc1c84de Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 24 Jul 2011 04:56:05 +0200 Subject: added robustness, removed utf8 support to be able to send special characters over the line the characters are translated into their number value and written as string. this essentially breaks utf-8 support for the clients, needs to be fixed some time later added ignore for own messages, message colorization --- cholerab/cholerab-live/cholerab.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'cholerab/cholerab-live/cholerab.py') diff --git a/cholerab/cholerab-live/cholerab.py b/cholerab/cholerab-live/cholerab.py index b6b3f84f..eb9e66df 100755 --- a/cholerab/cholerab-live/cholerab.py +++ b/cholerab/cholerab-live/cholerab.py @@ -14,9 +14,9 @@ class Cholerab: log.info("Sending %s at (%d,%d) to connected peers" %(char,x,y)) self.transport.send_char(x,y,char) - def write_char(self,x,y,char,user): - log.info("Writing %s at (%d,%d) from %d to view" %(char,x,y,user)) - self.view.write_char(x,y,char,user) + def write_char(self,x,y,char): + log.info("Writing %s at (%d,%d) to view" %(char,x,y)) + self.view.write_char(x,y,char,user=2) def stop(self): self.view.stop() self.transport.stop() -- cgit v1.2.3