Esempio n. 1
0
def test_del_option():
    """ Test the del_option function """
    instance = Template()
    instance.del_option('foo', 'bar')
    instance.add_option('foo', 'bar2')
    instance.del_option('foo', 'bar2')
    instance.del_option('foo', 'bar2')
Esempio n. 2
0
 def host_config(self):
     """ Ensure the host configuration file exists """
     if platform.system() == 'Darwin':
         default_file_dir = os.path.join(os.path.expanduser('~'),
                                         'vent_files')
     else:
         default_file_dir = '/opt/vent_files'
     status = self.ensure_dir(default_file_dir)
     config = Template(template=self.cfg_file)
     sections = {
         'main': {
             'files': default_file_dir
         },
         'network-mapping': {},
         'nvidia-docker-plugin': {
             'port': '3476'
         }
     }
     for s in sections:
         if sections[s]:
             for option in sections[s]:
                 config.add_option(s, option, sections[s][option])
         else:
             config.add_section(s)
     config.write_config()
     return status
Esempio n. 3
0
 def host_config(self):
     """ Ensure the host configuration file exists """
     default_file_dir = "/tmp/vent_files"
     config = Template(template=os.path.join(self.base_dir, "vent.cfg"))
     resp = config.section("main")
     if resp[0]:
         resp = config.option("main", "files")
         if not resp[0]:
             config.add_option("main", "files", default_file_dir)
             self.ensure_dir(default_file_dir)
     else:
         config.add_option("main", "files", default_file_dir)
         self.ensure_dir(default_file_dir)
     config.write_config()
     return
Esempio n. 4
0
def test_add_option():
    """ Test the add_option function """
    instance = Template()
    instance.add_option('foo', 'bar')
    instance.add_option('foo', 'bar')
    instance.add_option('bad', 'x')
Esempio n. 5
0
def test_add_option():
    """ Test the add_option function """
    instance = Template()
    instance.add_option('foo', 'bar')