fix boxtools for rpi
- remove to_cm4 - create replace_in_file
This commit is contained in:
9
utils.py
9
utils.py
@ -39,7 +39,6 @@ class BoxInfo:
|
||||
if ifname.startswith('enp'):
|
||||
self.change_if_names = True
|
||||
ifname = f'eth{int(ifname[3]) - 1}'
|
||||
print(ifname)
|
||||
with open(ifdev) as f:
|
||||
self.macaddr[ifname] = addr = f.read().strip().lower()
|
||||
if ifname in ('eth0', 'enp1s0'):
|
||||
@ -50,7 +49,7 @@ class BoxInfo:
|
||||
def get_macaddr(self):
|
||||
return self.macaddr.get(self.main_if)
|
||||
|
||||
def read_config(self):
|
||||
def read_config(self, section=None):
|
||||
cfgfiles = glob(self.CFGPATH % ('*', self.id))
|
||||
if len(cfgfiles) != 1:
|
||||
raise ValueError('there must be one and only one single cfgfile %r' % cfgfiles)
|
||||
@ -58,6 +57,10 @@ class BoxInfo:
|
||||
self.cfgfile = cfgfiles[0]
|
||||
parser = ConfigParser()
|
||||
parser.read(self.cfgfile)
|
||||
if section:
|
||||
if section in parser.sections():
|
||||
return dict(parser[section])
|
||||
return None
|
||||
return {k: dict(parser[k]) for k in parser.sections()}
|
||||
|
||||
|
||||
@ -78,7 +81,7 @@ class MainIf:
|
||||
prev_ip = None
|
||||
|
||||
def __init__(self):
|
||||
netcfg = get_config('NETWORK')
|
||||
netcfg = BoxInfo().read_config('NETWORK')
|
||||
for name, key in netcfg.items():
|
||||
if key.startswith(('dhcp', 'wan')):
|
||||
self.name = name
|
||||
|
Reference in New Issue
Block a user