1. Adam Lindsay
  2. thrifty-p2p

Commits

Adam Lindsay  committed 6954fb0

sparser output, all to stderr

  • Participants
  • Parent commits 1958ba2
  • Branches default

Comments (0)

Files changed (1)

File location.py

View file
         except NodeNotFound:
             pass
         loc.port += 1
-    print 'No peer autodiscovered.'
+    print >> sys.stderr, 'No peer autodiscovered.'
     return None
 
 def ping_until_found(location, maximum=10):
         except NodeNotFound:
             sleep(wait)
             wait *= 2
-            print wait
+            print >> sys.stderr, wait
     raise NodeNotFound(loc)
 
 class BaseHandler(Base.Iface):
         return services
     
     def ping(self):
-        print 'ping()'
+        print >> sys.stderr, 'ping()'
     
     def die(self):
         raise KeyboardInterrupt
         self.ring = HashRing()
         try:
             ping(self.location)
-            print 'Uh-oh. Our location responded to a ping!'
+            print >> sys.stderr, 'Uh-oh. Our location responded to a ping!'
             raise socket.error(43, 'Address already in use')
         except NodeNotFound:
             pass
                 # enter all nodes as authorities to avoid race conditions
                 # lazy invalidation
                 self.remove(tx.location, map(str2loc, self.ring.nodes))
-        print "removed %s:%d" % (location.address, location.port)
+        print >> sys.stderr, "removed %s:%d" % (location.address, location.port)
     
     def add(self, location, authorities):
         """
                 # lazy invalidation
                 self.remove(tx.location, map(str2loc, self.ring.nodes))
         self.ring.append(loc2str(location))
-        print "added %s:%d" % (location.address, location.port)
+        print >> sys.stderr, "added %s:%d" % (location.address, location.port)
     
     def get_all(self):
         return map(str2loc, self.ring.nodes)
     def debug(self):
         a = "self.location: %r\n" % self.location
         a += "self.ring.nodes:\n%r\n" % self.ring.nodes
-        print a
+        print >> sys.stderr, a
     
     def cleanup(self):
         self.ring.remove(self.here)
         if self.peer:
             self.ring.extend(map(loc2str, remote_call('get_all', self.peer)))
             remote_call('join', self.peer, self.location)
-            print 'Joining the network...'
+            print >> sys.stderr, 'Joining the network...'
         else:
-            print 'Initiating the network...'
+            print >> sys.stderr, 'Initiating the network...'
         
     
 
     
     handler.local_join()
     
-    print 'Starting the server at %s...' % (handler.here)
+    print >> sys.stderr, 'Starting the server at %s...' % (handler.here)
     try:
         server.serve()
     finally:
         handler.cleanup()
-    print 'done.'
+    print >> sys.stderr, 'done.'
 
 if __name__ == '__main__':
     (options, args) = parser.parse_args()