print("Error: No Cardreader connected? Found no device with vendor ID {} and model ID {}. Exiting.".format(config["reader"]["vendor_id"],config["reader"]["model_id"]),file=sys.stderr)
logging.criticial("Error: No Cardreader connected? Found no device with vendor ID {} and model ID {}. Exiting.".format(config["reader"]["vendor_id"],config["reader"]["model_id"]))
print("Config directory didn't exist, created directory: {}".format(config_dir))
logging.info("Config directory didn't exist, created directory: {}".format(config_dir))
exceptPermissionErrorase:
exceptPermissionErrorase:
print("Error: Not sufficient permissions to create config directory at {} (Running {} as user {})".format(config_dir,application_name,getpass.getuser()),file=sys.stderr)
logging.error("Error: Not sufficient permissions to create config directory at {} (Running {} as user {})".format(config_dir,application_name,getpass.getuser()))
print("Consider creating {} manually with write permissions for {}. After initial write of default config.toml on the first run {} won't write that file ever again".format(config_dir,getpass.getuser(),application_name),file=sys.stderr)
logging.error("Consider creating {} manually with write permissions for {}. After initial write of default config.toml on the first run {} won't write that file ever again".format(config_dir,getpass.getuser(),application_name),file=sys.stderr)
exit(1)
exit(1)
# Create a default config if it does exist
# Create a default config if it does exist
ifnotPath.is_file(Path(config_path)):
ifnotPath.is_file(Path(config_path)):
try:
try:
write_config(config_path,default_strconfig)
write_config(config_path,default_strconfig)
print("Created new default config.toml at:\n{}".format(config_path))
logging.info("Created new default config.toml at:\n{}".format(config_path))
config=read_config(config_path)
config=read_config(config_path)
exceptPermissionErrorase:
exceptPermissionErrorase:
print("Error: Not sufficient permissions to write default config.toml into directory {} (as user {})".format(config_dir,getpass.getuser()),file=sys.stderr)
logging.error("Error: Not sufficient permissions to write default config.toml into directory {} (as user {})".format(config_dir,getpass.getuser()))
print("Consider changing permissions on {} manually so writing is allowed for user {}. After initial write of default config.toml on the first run {} won't write that file ever again. so you can make it read only for {} after that".format(config_dir,getpass.getuser(),application_name,getpass.getuser()),file=sys.stderr)
logging.error("Consider changing permissions on {} manually so writing is allowed for user {}. After initial write of default config.toml on the first run {} won't write that file ever again. so you can make it read only for {} after that".format(config_dir,getpass.getuser(),application_name,getpass.getuser()))
print("Error: there are keys missing in the config. Delete to let {} create a new one, or add the missing keys manually".format(application_name),file=sys.stderr)
logging.error("Error: there are keys missing in the config. Delete to let {} create a new one, or add the missing keys manually".format(application_name))