Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #71758 > unrolled thread

Problem in writing demands to the xml file

Started byvarun7rs@gmail.com
First post2014-05-19 06:42 -0700
Last post2014-05-20 01:06 -0700
Articles 3 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Problem in writing demands to the xml file varun7rs@gmail.com - 2014-05-19 06:42 -0700
    Re: Problem in writing demands to the xml file "Rhodri James" <rhodri@wildebst.org.uk> - 2014-05-19 22:30 +0100
    Re: Problem in writing demands to the xml file varun7rs@gmail.com - 2014-05-20 01:06 -0700

#71758 — Problem in writing demands to the xml file

Fromvarun7rs@gmail.com
Date2014-05-19 06:42 -0700
SubjectProblem in writing demands to the xml file
Message-ID<94945828-0caf-4534-bdaa-5371bdda6dbe@googlegroups.com>
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

[toc] | [next] | [standalone]


#71777

From"Rhodri James" <rhodri@wildebst.org.uk>
Date2014-05-19 22:30 +0100
Message-ID<op.xf4l1ahe5079vu@gnudebeest>
In reply to#71758
On Mon, 19 May 2014 14:42:02 +0100, <varun7rs@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

[toc] | [prev] | [next] | [standalone]


#71792

Fromvarun7rs@gmail.com
Date2014-05-20 01:06 -0700
Message-ID<98ea99c4-fcd7-421b-88ba-b90f947afede@googlegroups.com>
In reply to#71758
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)

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web