more logging messages and code cleanup

Removed log messages from config.py
This commit is contained in:
Pranav Jerry 2021-09-06 12:23:07 +05:30
parent 33156e6a8d
commit a3e9b45050
No known key found for this signature in database
GPG Key ID: F1DCDC4FED0A0C5B
4 changed files with 16 additions and 12 deletions

View File

@ -36,4 +36,4 @@ See README.md for documentation.
# #
# In case you forgot to change the version, skip the number # In case you forgot to change the version, skip the number
# and put the next number in the next commit. # and put the next number in the next commit.
__version__ = "0.3.0a2" __version__ = "0.3.0a2.dev1"

View File

@ -46,7 +46,8 @@ from pathlib import Path
from configparser import ConfigParser from configparser import ConfigParser
from argparse import ArgumentParser, Namespace from argparse import ArgumentParser, Namespace
from naxalnet.default import CONFIG, CONFIG_FILES, CONFIG_DIRS from naxalnet.default import CONFIG, CONFIG_FILES, CONFIG_DIRS
from naxalnet.log import logger
# from naxalnet.log import logger
def get_config_files(): def get_config_files():
@ -70,14 +71,14 @@ def parse_config():
Parse all configuration files, with the values in Parse all configuration files, with the values in
default.py as fallback default.py as fallback
""" """
logger.debug("Parsing config files") # logger.debug("Parsing config files")
parser = ConfigParser() parser = ConfigParser()
# encoded defaults # encoded defaults
parser.read_dict(CONFIG) parser.read_dict(CONFIG)
# read config files # read config files
files = get_config_files() files = get_config_files()
for i in files: for i in files:
logger.debug("Reading config file %s", str(i)) # logger.debug("Reading config file %s", str(i))
parser.read_file(i.open()) parser.read_file(i.open())
return parser return parser
@ -145,5 +146,5 @@ def parse_args() -> Namespace:
help="prints the version and exit", help="prints the version and exit",
) )
logger.debug("Parsing arguments") # logger.debug("Parsing arguments")
return parser.parse_args() return parser.parse_args()

View File

@ -310,11 +310,13 @@ class Adapter:
"""power on the adapter""" """power on the adapter"""
self._proxy.Powered = True self._proxy.Powered = True
logger.debug("Powered on adapter %s", self.name) logger.debug("Powered on adapter %s", self.name)
self.reload()
def power_off(self): def power_off(self):
"""power off the adapter""" """power off the adapter"""
self._proxy.Powered = False self._proxy.Powered = False
logger.debug("Powered off adapter %s", self.name) logger.debug("Powered off adapter %s", self.name)
self.reload()
def supports_mode(self, mode: str) -> bool: def supports_mode(self, mode: str) -> bool:
""" """

View File

@ -99,7 +99,6 @@ def setup_devices(args):
if not adhoc_adapter.is_powered_on(): if not adhoc_adapter.is_powered_on():
logger.debug("Adapter %s is off. Turning on", adhoc_adapter.name) logger.debug("Adapter %s is off. Turning on", adhoc_adapter.name)
adhoc_adapter.power_on() adhoc_adapter.power_on()
adhoc_device.reload()
adhoc_device.start_adhoc_open(args.adhoc_name) adhoc_device.start_adhoc_open(args.adhoc_name)
# Start Access point if ap_device is not empty, # Start Access point if ap_device is not empty,
# ie, we have more devices # ie, we have more devices
@ -113,11 +112,13 @@ def setup_devices(args):
if not ap_adapter.is_powered_on(): if not ap_adapter.is_powered_on():
logger.debug("Adapter %s is off. Turning on", ap_adapter.name) logger.debug("Adapter %s is off. Turning on", ap_adapter.name)
ap_adapter.power_on() ap_adapter.power_on()
ap_adapter.reload()
ap_device.start_ap(args.ap_ssid, args.ap_passwd) ap_device.start_ap(args.ap_ssid, args.ap_passwd)
else:
# naxalnet prints Bye if no errors occured logger.info("Not setting up WiFi AP.")
logger.info("Bye") else:
logger.warning(
"No device found to setup mesh. Make sure a WiFi adapter is connected"
)
def print_wifi(args): def print_wifi(args):
@ -161,5 +162,5 @@ def here_be_dragons():
except DBusError: except DBusError:
logger.exception("Error while communicating with iwd") logger.exception("Error while communicating with iwd")
sys.exit(4) sys.exit(4)
# naxalnet prints Bye if no errors occured
logger.debug("Finished.") logger.info("Bye")