Ejemplo n.º 1
0
def main():

    # Setup logging
    setup_logging()

    logger = get_logger(__name__)

    logger.debug(FUNCTION_CALL_MSG)

    # Setup argparse
    parser = argparse.ArgumentParser(description="Random Record Boye")

    parser.add_argument("-a",
                        "--auth-token",
                        type=str,
                        metavar="",
                        help="Discogs auth token")
    parser.add_argument("-t",
                        "--test",
                        action='store_true',
                        dest="is_test",
                        help="Test mode")
    parser.add_argument("-r",
                        "--refresh-collection",
                        action='store_true',
                        help="Update Collection on start")
    parser.add_argument(
        "-s",
        "--shutdown-system",
        action='store_true',
        help=
        "Omit to only exit script on shutdown, pass to shutdown whole system")

    args = parser.parse_args()
    logger.debug(
        f"Args: (-a: {args.auth_token}, -t: {args.is_test}, -r: {args.refresh_collection}, -s: {args.shutdown_system})"
    )
    # If auth-token is missing from args,
    # see if its stored as DISCOGS_TOKEN
    # os environment variable. If neither,
    # Throw exception and exit
    if not args.auth_token:
        logger.debug("Auth-token not in args, trying to find in os.environ")
        try:
            args.auth_token = os.environ["DISCOGS_TOKEN"]
            logger.debug("Auth-token found in os.environ!")
        except KeyError:
            logger.exception(
                "No auth-token arg and environment var DISCOGS_TOKEN not set.")
            logger.debug("Exiting script")
            raise SystemExit

    # Setup Randomboye
    logger.debug("Making randomboye object")
    randomboye = RandomBoye(args.auth_token, args.is_test,
                            args.refresh_collection, args.shutdown_system)
    logger.debug("Starting randomboye object")
    randomboye.start()
    logger.debug("After randomboye.start() call")
Ejemplo n.º 2
0
from definitions import FUNCTION_CALL_MSG
import signal
from threading import Thread
import time
from randomboye.helpers import (
    create_multiple_framebuffers
)
from threading import Lock

from logs.config import get_logger
logger = get_logger(__name__)


class IODevice(Thread):
    def __init__(self, shutdown_system=False, output_rows=2, output_columns=16):
        super().__init__()
        logger.debug(f"{FUNCTION_CALL_MSG}, {__class__}")

        self.shutdown_system = shutdown_system

        self.lock = Lock()

        self.output_rows = output_rows
        self.output_columns = output_columns

        # Override
        self.print_method = self.default_print_method
        self.print_cleanup_method = self.default_print_cleanup

        # self.front_button = None