Commits

Thejesh GN  committed 69665a1

works with out password too and also added another example

  • Participants
  • Parent commits b72f699

Comments (0)

Files changed (2)

File examples/wordCount.py

+#word count
+# server
+source = {1:"Humpty Dumpty sat on a wall", 2:"Humpty Dumpty had a great fall", 3:"All the King's horses and all the King's men", 4:"Couldn't put Humpty together again" }
+
+def final(key, value):
+    print key, value
+
+# client
+def mapfn(key, value):
+    for w in value.split():
+        yield w, 1
+
+def reducefn(key, value):
+    result = 0
+    for v in value:
+        result += v
+    return result
 
 
     def __init__(self, tasks, taskfile,
-                 host="", port=DEFAULT_CHAT_PORT, password=None, taskretry=False,intermediate=None, final=None):
+                 host="", port=DEFAULT_CHAT_PORT, password="", taskretry=False,intermediate=None, final=None):
         self.logging = logging.getLogger(self.__class__.__name__)
         asyncore.dispatcher.__init__(self)
 
  
     server = taskfile
     taskclient = TaskClient(host=server, **options)
-    is_auth = taskclient.authenticate_client(password=options['password'])
-    print is_auth
+    if options.has_key('password'):
+        pw = options['password']
+    else:
+        pw = ""
+    is_auth = taskclient.authenticate_client(password=pw)
     if is_auth != "sucess":
         print "Wrong Authentication"     
     else: