fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fab-user] Function with loop


From: Eldad Cohen
Subject: [Fab-user] Function with loop
Date: Tue, 4 Sep 2018 14:25:57 +0300

Hi,

How Do I run on Host a function that consists of loop and some python commands.
How do I wrap this kind of function to run on Hosts.
Example:
import xml.etree.ElementTree as ET
tree = ET.parse("test.xml")
a = tree.find('parent')
for b in a.findall('child'):
    if b.text.strip() == 'Jay/Doctor':
        break
else:
    ET.SubElement(a,"child").text="Jay/Doctor"
tree.write("test.xml")

reply via email to

[Prev in Thread] Current Thread [Next in Thread]