Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main(config_path_str: str = None, verbosity: int = 20) -> None:
"""Run the main fauxmo process.
Spawns a UDP server to handle the Echo's UPnP / SSDP device discovery
process as well as multiple TCP servers to respond to the Echo's device
setup requests and handle its process for turning devices on and off.
Args:
config_path_str: Path to config file. If not given will search for
`config.json` in cwd, `~/.fauxmo/`, and
`/etc/fauxmo/`.
verbosity: Logging verbosity, defaults to 20
"""
logger.setLevel(verbosity)
logger.info(f"Fauxmo {__version__}")
logger.debug(sys.version)
if config_path_str:
config_path = pathlib.Path(config_path_str)
else:
for config_dir in (".", "~/.fauxmo", "/etc/fauxmo"):
config_path = pathlib.Path(config_dir).expanduser() / "config.json"
if config_path.is_file():
logger.info(f"Using config: {config_path}")
break
try:
config = json.loads(config_path.read_text())
except FileNotFoundError:
logger.error(
"Could not find config file in default search path. Try "
# The encoding of source files.
# source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = "index"
# General information about the project.
project = "fauxmo"
copyright = ", Nathan Henrie"
# The version info for the project you're documenting, acts as replacement
# for |version| and |release|, also used in various other places throughout
# the built documents.
#
# The short X.Y version.
version = fauxmo.__version__
# The full version, including alpha/beta/rc tags.
release = fauxmo.__version__
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
# language = None
# There are two options for replacing |today|: either, you set today to
# some non-false value, then it is used:
# today = ''
# Else, today_fmt is used as the format for a strftime call.
# today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ["_build"]
def cli() -> None:
"""Parse command line options, provide entry point for console scripts."""
arguments = sys.argv[1:]
parser = argparse.ArgumentParser(
description="Emulate Belkin Wemo devices for use with Amaazon Echo"
)
parser.add_argument(
"-v",
"--verbose",
help="increase verbosity (may repeat up to -vvv)",
action="count",
default=0,
)
parser.add_argument("-c", "--config", help="specify alternate config file")
parser.add_argument(
"-V", "--version", action="version", version=__version__
)
args = parser.parse_args(arguments)
# args.verbose defaults to 0
# 40 - 10 * 0 = 40 == logging.ERROR
verbosity = max(40 - 10 * args.verbose, 10)
logger.setLevel(verbosity)
main(config_path_str=args.config, verbosity=verbosity)
# The master toctree document.
master_doc = "index"
# General information about the project.
project = "fauxmo"
copyright = ", Nathan Henrie"
# The version info for the project you're documenting, acts as replacement
# for |version| and |release|, also used in various other places throughout
# the built documents.
#
# The short X.Y version.
version = fauxmo.__version__
# The full version, including alpha/beta/rc tags.
release = fauxmo.__version__
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
# language = None
# There are two options for replacing |today|: either, you set today to
# some non-false value, then it is used:
# today = ''
# Else, today_fmt is used as the format for a strftime call.
# today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ["_build"]
# The reST default role (used for this markup: `text`) to use for all