71 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			71 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| import click
 | |
| from click_didyoumean import DYMGroup
 | |
| import click_log
 | |
| import logging
 | |
| 
 | |
| from terminaltables import SingleTable
 | |
| 
 | |
| from carom.table import get_tables, cleanup
 | |
| 
 | |
| logger = logging.getLogger('carom.cli')  # hard coded module name to support directly called module
 | |
| root_logger = logging.getLogger('')
 | |
| click_log.basic_config(root_logger)
 | |
| 
 | |
| 
 | |
| @click.group(cls=DYMGroup)
 | |
| @click_log.simple_verbosity_option(root_logger)
 | |
| def cli():
 | |
|     pass
 | |
| 
 | |
| 
 | |
| @cli.command()
 | |
| def get_gpio():
 | |
|     """
 | |
|     Get the current status of all Tables.
 | |
|     """
 | |
|     table_data = [("Table #", "Port", "in use")]
 | |
|     for table in get_tables():
 | |
|         table_data.append((table.num, table.port, table.in_use))
 | |
|     st = SingleTable(table_data)
 | |
|     st.title = "Tables"
 | |
|     click.echo(st.table)
 | |
| 
 | |
| 
 | |
| 
 | |
| @cli.command()
 | |
| def get_uuid():
 | |
|     """
 | |
|     Get the UUID of the Client. This is need to add a new client to the carom server installation.
 | |
|     """
 | |
|     from carom.utils import get_uuid as util_get_uuid
 | |
|     click.echo(util_get_uuid())
 | |
| 
 | |
| 
 | |
| @cli.command()
 | |
| def run():
 | |
|     """
 | |
|     This command runs the carom-client daemon process.
 | |
|     """
 | |
|     pass
 | |
| 
 | |
| 
 | |
| @cli.command()
 | |
| def check_config():
 | |
|     """
 | |
|     This command checks the config for carom client.
 | |
|     """
 | |
|     from carom.config import config, log_config
 | |
|     if config:
 | |
|         logger.info("Configuration OK")
 | |
|     else:
 | |
|         logger.warning("Compiled configuration:")
 | |
|         log_config()
 | |
|         exit(1)
 | |
| 
 | |
| 
 | |
| if __name__ == "__main__":
 | |
|     try:
 | |
|         cli()
 | |
|     finally:
 | |
|         cleanup()
 |