-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cdd5e29
commit a282c46
Showing
23 changed files
with
121 additions
and
456 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"""Example scripts. | ||
Scripts need to be invoked with the -m flag, e.g.: | ||
python3 -m examples.youtube_example --cast "Kitchen" --show-debug | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Common helpers and utilities shared by examples.""" | ||
|
||
import argparse | ||
import logging | ||
|
||
import zeroconf | ||
|
||
|
||
def add_log_arguments(parser: argparse.ArgumentParser) -> None: | ||
"""Add arguments to control logging to the parser.""" | ||
parser.add_argument("--show-debug", help="Enable debug log", action="store_true") | ||
parser.add_argument( | ||
"--show-discovery-debug", help="Enable discovery debug log", action="store_true" | ||
) | ||
parser.add_argument( | ||
"--show-zeroconf-debug", help="Enable zeroconf debug log", action="store_true" | ||
) | ||
|
||
|
||
def configure_logging(args: argparse.Namespace) -> None: | ||
"""Configure logging according to command line arguments.""" | ||
fmt = "%(asctime)s %(levelname)s (%(threadName)s) [%(name)s] %(message)s" | ||
datefmt = "%Y-%m-%d %H:%M:%S" | ||
logging.basicConfig(format=fmt, datefmt=datefmt, level=logging.INFO) | ||
|
||
if args.show_debug: | ||
logging.getLogger("pychromecast.dial").setLevel(logging.INFO) | ||
logging.getLogger("pychromecast.discovery").setLevel(logging.INFO) | ||
if args.show_discovery_debug: | ||
logging.getLogger("pychromecast.dial").setLevel(logging.DEBUG) | ||
logging.getLogger("pychromecast.discovery").setLevel(logging.DEBUG) | ||
if args.show_zeroconf_debug: | ||
print("Zeroconf version: " + zeroconf.__version__) | ||
logging.getLogger("zeroconf").setLevel(logging.DEBUG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.