Skip to content

Commit

Permalink
some options are not available under windows -> added check in cli
Browse files Browse the repository at this point in the history
  • Loading branch information
avollkopf committed Nov 15, 2023
1 parent beb3509 commit 35e83cd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cbpi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "4.2.0.a9"
__version__ = "4.2.0.rc1"
__codename__ = "Indian Summer"

32 changes: 23 additions & 9 deletions cbpi/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import sys
from pathlib import Path
import requests
from cbpi import __version__, __codename__
Expand Down Expand Up @@ -267,7 +268,8 @@ def main(context, config_folder_path, logs_folder_path, debug_log_level):
if logs_folder_path == "":
logs_folder_path = os.path.join(Path(config_folder_path).absolute().parent, 'logs')
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(name)s - %(message)s')
static_config = load_config(ConfigFolder(config_folder_path, logs_folder_path).get_file_path("config.yaml"))
config=ConfigFolder(config_folder_path, logs_folder_path)
static_config = load_config(config.get_file_path("config.yaml"))
try:
if debug_log_level == 99:
debug_log_level=static_config['debug-log-level']
Expand All @@ -277,7 +279,7 @@ def main(context, config_folder_path, logs_folder_path, debug_log_level):
logging.basicConfig(format=formatter, stream=logging.StreamHandler())
logger = logging.getLogger()
print("*******************************")
print("Set Debug-log-level to {}".format(debug_log_level))
print("Debug-log-level is {}".format(debug_log_level))
print("*******************************")
logger.setLevel(debug_log_level)
try:
Expand All @@ -289,7 +291,7 @@ def main(context, config_folder_path, logs_folder_path, debug_log_level):
except Exception as e:
logger.warning("log folder or log file could not be created or accessed. check folder and file permissions or create the logs folder somewhere you have access with a start option like '--log-folder-path=./logs'")
logging.critical(e, exc_info=True)
cbpi_cli = CraftBeerPiCli(ConfigFolder(config_folder_path, logs_folder_path))
cbpi_cli = CraftBeerPiCli(config)
context.obj = cbpi_cli

@main.command()
Expand All @@ -304,10 +306,14 @@ def setup(context):
@click.option('--setup', is_flag=True, help="Setup 1Wire on Raspberry Pi")
def onewire(context, list, setup):
'''(--setup | --list) Setup 1wire on Raspberry Pi or list sensors'''
if setup is True:
context.obj.setup_one_wire()
if list is True:
context.obj.list_one_wire()
operationsystem= sys.platform
if not operationsystem.startswith('win'):
if setup is True:
context.obj.setup_one_wire()
if list is True:
context.obj.list_one_wire()
else:
print("Onewire options NOT available under Windows")

@main.command()
@click.pass_context
Expand Down Expand Up @@ -337,12 +343,20 @@ def create(context, pluginname=[]):
@click.argument('name')
def autostart(context, name):
'''(on|off|status) Enable or disable autostart'''
context.obj.autostart(name)
operationsystem= sys.platform
if not operationsystem.startswith('win'):
context.obj.autostart(name)
else:
print("Autostart option NOT available under Windows")


@main.command()
@click.pass_context
@click.argument('name')
def chromium(context, name):
'''(on|off|status) Enable or disable Kiosk mode'''
context.obj.chromium(name)
operationsystem= sys.platform
if not operationsystem.startswith('win'):
context.obj.chromium(name)
else:
print("Chromium option NOT available under Windows")

0 comments on commit 35e83cd

Please sign in to comment.