com.py
changeset 4 4cee17e91d29
parent 3 234fa7eea0df
child 5 5ab3cc2e7851
     1.1 --- a/com.py	Mon Jun 14 14:32:12 2010 +0200
     1.2 +++ b/com.py	Mon Jun 14 23:16:47 2010 +0200
     1.3 @@ -18,11 +18,11 @@
     1.4  def saveModel(socket, client, worker, (name,)):
     1.5  	model = lookupModel(socket, client, name)
     1.6  	if model:
     1.7 -		pickle.dump(model, open(name, "w"))
     1.8 +		pickle.dump(model, open(name + ".model", "w"))
     1.9  		socket.sendto("model %s saved\n" % name, client)
    1.10  		
    1.11  def loadModel(socket, client, worker, (name,)):	
    1.12 -	model.addModel(pickle.load(open(name, "r")))
    1.13 +	model.addModel(pickle.load(open(name + ".model", "r")))
    1.14  	socket.sendto("model %s loaded\n" % name, client)		
    1.15  		
    1.16  def lookupModel(socket, client, name):
    1.17 @@ -72,7 +72,8 @@
    1.18  			print model.range
    1.19  			print model.resolution
    1.20  			dump = pickle.dumps(model)
    1.21 -			socket.sendto("%010i%s%010i" % (len(dump), dump, int(iterations)), w) 
    1.22 +			socket.sendto("%010i%s%010i" % (len(dump), dump, 
    1.23 +				int(iterations)), w) 
    1.24  		socket.sendto("model %s updated with max %s iterations\n" 
    1.25  			% (modelName, iterations), client)
    1.26  		model.range = (complex(begin_x, begin_y), complex(end_x, end_y))