I’m a student working on farmbot as a semester project. The idea was to divide the plot of the farmbot up and have different regions according to plant-growth stages. In this context, I wanted to store information about each of these regions and plant emplacements in an xml file.
However, It seems as if it’s impossible to use etree in the farmbot context. Is that so? And if so, is there a work-around?
I was also planning on using pickler to easily be able to store objects, but I think that doesn’t work either does it?
I do import both of them, but it gives me an error, immediately on the first call of xml.etree.ElementTree in the code. I’ve run it in shell on Ubuntu in debug mode and there it works perfectly.
Is there a specific way to import the modules or to pip them onto the bot?
I’ve now tested with python 2.7 (that was pretty stupid of me actually, using python 3.5). The error seems to have been that I was using the requests module, which doesn’t work in python 2.7. I haven’t tested with the robot yet, but I’m optimistic I’ve now changed to urllib2.
I’ll give an update on how it went when I’ve tried on the robot.
def initPlantTypes(self):
log("Present.", message_type='info')
e = xml.etree.ElementTree.parse('./plantTypes.xml').getroot()
log("Accessed plantTypes.xml", message_type='info')
for plantType in e:
name = plantType.attrib["name"]
lightNeeded = int(plantType.attrib["lightNeeded"])
gt0 = int(plantType.attrib["gt0"])
gt1 = int(plantType.attrib["gt1"])
gt2 = int(plantType.attrib["gt2"])
self.plantTypeList.append(PlantType(name, lightNeeded, gt0, gt1, gt2))
log("Loaded plant types.", message_type='info')
This is the function that is giving an error. It logs “Present”, but never logs “Accessed plant types.”
I’m at a loss. Is there a blatantly stupid error somewhere in there?
(Btw there is no path error. I triple checked it. The file does exist and is filled with xml, which on the computer is parsed perfectly.) (With python 2.7 this time)