Re: Problem in writing demands to the xml file

2014-05-20 Thread varun7rs
There is no traceback error. But I want to actually fill the demands with 
certain attributes which I'm not able to do. When I run the program, the xml is 
written but the demands doesn't have any attributes whatsoever. I could give 
you a clear idea of what I expect in the demands. For every node, I have an 
attribute called totaldemands which takes a value between 1 and 5. Now, I need 
the same no. of demands being written onto the xml file below every node which 
is now empty

totaldemands = random.randint(1, 5)
demnum = 0
for demand in range(totaldemands):
demnum = demnum + 1
PoPbdw = random.uniform(2, 2.5)
PoPstor = random.uniform(2, 2.5)
PoPpro = random.uniform(0.5, 1)
MMEbdw = random.uniform(2, 2.5)
MMEstor = random.uniform(2, 3)
MMEpro = random.uniform(0.5, 1)
IMSbdw = random.uniform(2.5, 3)
IMSstor = random.uniform(2.5, 3.5)
IMSpro = random.uniform(0.5, 1)
SGWbdw = random.uniform(3, 3.5)
SGWstor = random.uniform(2.5, 3.5)
SGWpro = random.uniform(0.5, 1)
PGWbdw = random.uniform(2.5, 3.5)
PGWstor = random.uniform(2, 2.5)
PGWpro = random.uniform(0.5, 1)
-- 
https://mail.python.org/mailman/listinfo/python-list


Problem in writing demands to the xml file

2014-05-19 Thread varun7rs
Hello Friends,

I am still working on the script to write data onto the xml file and now I've 
got a problem.

This is how my xml file looks now but I intend to add attributes to demands. I 
am not able to do it properly.
substrate
nodes
node Name=u'Aachen' ProcessingCapacity=20 StorageCapacity=38 
SwitchingCapacity=45 TotalDemands=5 nodenum=1 xCoordinate=u'6.04' 
yCoordinate=u'50.76'
demands/
/node
node Name=u'Augsburg' ProcessingCapacity=21 StorageCapacity=39 
SwitchingCapacity=46 TotalDemands=2 nodenum=2 xCoordinate=u'10.9' 
yCoordinate=u'48.33'
demands/
/node

My class for nodes. I have a class for DEMAND but I don't want to populate the 
post with all of it.
class PHY_NODES:
def __init__(self, nodeID, nodenum, x, y, capacity_proc, capacity_stor, 
capacity_switch, totaldemand, demands):
self.id = nodeID
self.nodenum = nodenum
self.x = x
self.y = y
self.capacity_proc = capacity_proc
self.capacity_stor = capacity_stor
self.capacity_switch = capacity_switch
self.totaldemand = totaldemand
self.demands = demands

def addDemand (self, demand):
self.demands.append( demand )  

The problem I have is in writing the demands. I generate the necessary stuff 
for it but when I try and append it, it doesn't seem to work. I'd be glad to 
share my files if you need them. Could you please help me fix this?

Thank You

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem in writing demands to the xml file

2014-05-19 Thread Rhodri James

On Mon, 19 May 2014 14:42:02 +0100, varun...@gmail.com wrote:

The problem I have is in writing the demands. I generate the necessary  
stuff for it but when I try and append it, it doesn't seem to work. I'd  
be glad to share my files if you need them. Could you please help me fix  
this?


When you say, It doesn't seem to work, what do you mean?  What are you
expecting it to do?  What does it actually do?  Is there a traceback?

--
Rhodri James *-* Wildebeest Herder to the Masses
--
https://mail.python.org/mailman/listinfo/python-list