Exemple #1
0
 def write(self):
   '''
   Writes the json config file.
   '''
   try:
     with open(self.PATH, 'w') as conf:
       json.dump(self.conf, conf, indent=4)
       error.log('changes written to {}'.format(self.PATH))
   except IOError:
     error.error('error writing to {}; changes not applied'.format(
         self.PATH))
Exemple #2
0
 def _search(self):
   '''
   Searches into path for a net tool able to operate.
   
   > i: position into self.execs
   '''
   for i,x in enumerate(self.execs):
     cmd = shutil.which(x)
     if cmd is not None:
       return i
   error.error('cannot find a suitable command: '
     'install one of this tools {}'.format(self.execs))
Exemple #3
0
 def execute(self, eth):
   '''
   Effectively execute the command with selected tool, using subprocess.
   
   < eth: the chosen eth interface
   '''
   cmd = self._build(eth)
   try:
     sp.check_call(cmd, stdout=sp.DEVNULL, stderr=sp.DEVNULL)
   except sp.CalledProcessError as e:
     if e.returncode == 2:
       error.log('static route for multicast streaming already set')
     else:
       error.error('cannot set static route for multicast streaming')