Snip from a previous project (3 yrs ago) where I used configparser:
import Configparser
# taken out of a class somewhere, adapt as needed, the config will be loaded in
self.cfg_hardware
# somewhere setup_ini() is called, which does the actual loading
# in the instance:
self.cfg_hardware = ConfigParser.ConfigParser()
def setup_ini(self):
self.read_hardware_config()
for key, (field, joint) in enumerate(self.joints.iteritems()):
for (key, val) in self.cfg_hardware.items(joint.name):
joint.add_hardware_setting(key, val)
def read_hardware_config(self):
os.chdir(os.path.dirname(os.path.realpath(__file__)))
directory = os.getcwd() + '/config'
configfile = directory + '/hardware.ini'
self.cfg_hardware.read(configfile)
instead of the for loop for (key, val) in self.cfg_hardware.items(joint.name):
you would get a value something like so: myval=cfg_hardware[‘SPINDLE’][‘MAXRPM’]
then use myval to set the pin
--
website: http://www.machinekit.io blog: http://blog.machinekit.io github:
https://github.com/machinekit
---
You received this message because you are subscribed to the Google Groups
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/machinekit/028301d62dee%2457a66f80%2406f34e80%24%40basdebruijn.com.