#!/usr/bin/env python

import sys
import time
from websocket import create_connection

batchSize = int(sys.argv[1]) if len(sys.argv) > 1 else 1


def translate(batch):
    ws = create_connection("ws://localhost:1234/translate")
    #print(batch.rstrip())
    ws.send(batch)
    result = ws.recv()
    print(result.rstrip())
    ws.close()


if __name__ == "__main__":
    batchCount = 0
    batch = ""
    for line in sys.stdin:
        batchCount = batchCount + 1
        batch += line
        if batchCount == batchSize:
            translate(batch)
            batchCount = 0
            batch = ""

    if batchCount:
        translate(batch)

@@ -16,16 +16,83 @@
 python%0A%0A
+from __future__ import print_function, unicode_literals, division%0A%0A
 import s
@@ -106,16 +106,33 @@
 rt time%0A
+import argparse%0A%0A
 from web
@@ -168,66 +168,8 @@
 on%0A%0A
-batchSize = int(sys.argv%5B1%5D) if len(sys.argv) %3E 1 else 1%0A%0A
 %0Adef
@@ -184,16 +184,27 @@
 te(batch
+, port=8080
 ):%0A    w
@@ -245,12 +245,10 @@
 ost:
-1234
+%7B%7D
 /tra
@@ -254,16 +254,29 @@
 anslate%22
+.format(port)
 )%0A    #p
@@ -382,16 +382,237 @@
 ose()%0A%0A%0A
+def parse_args():%0A    parser = argparse.ArgumentParser()%0A    parser.add_argument(%22-b%22, %22--batch-size%22, type=int, default=1)%0A    parser.add_argument(%22-p%22, %22--port%22, type=int, default=8080)%0A    return parser.parse_args()%0A%0A%0A
 if __nam
@@ -630,30 +630,50 @@
 ain__%22:%0A    
-batchC
+args = parse_args()%0A%0A    c
 ount = 0%0A   
@@ -723,33 +723,16 @@
     
-batchC
+c
 ount 
++
 =
- batchCount +
  1%0A 
@@ -767,22 +767,17 @@
  if 
-batchC
+c
 ount == 
 batc
@@ -776,14 +776,20 @@
  == 
+args.
 batch
-S
+_s
 ize:
@@ -812,24 +812,40 @@
 nslate(batch
+, port=args.port
 )%0A          
@@ -846,22 +846,17 @@
         
-batchC
+c
 ount = 0
@@ -891,14 +891,9 @@
  if 
-batchC
+c
 ount
@@ -913,14 +913,30 @@
 nslate(batch
+, port=args.port
 )%0A

Update python client