Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--launched-with-shortcut parameter turns off info logging. KC-290 #529

Merged
merged 1 commit into from
Oct 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 8 additions & 21 deletions keepercommander/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,13 @@ def get_params_from_config(config_filename):
logging.debug("Setting config file from KEEPER_CONFIG_FILE env variable %s" % os.getenv('KEEPER_CONFIG_FILE'))
params.config_filename = os.getenv('KEEPER_CONFIG_FILE')
elif opts.launched_with_shortcut:
current_user_home_path = str(Path.home())
path_sep = os.path.sep
launcher_keeper_folder_path = Path.home().joinpath('.keeper')
launcher_keeper_folder_path.mkdir(parents=True, exist_ok=True)

# unix: /Users/username/.keeper/
# win: C:\\Users\\username\\.keeper\\

laucher_keeper_folder_path = current_user_home_path + path_sep + '.keeper'
logging.debug("Launcher keeper folder: %s" % laucher_keeper_folder_path)

Path(laucher_keeper_folder_path).mkdir(parents=True, exist_ok=True)

params.config_filename = laucher_keeper_folder_path + path_sep + 'config.json'
params.config_filename = str(launcher_keeper_folder_path.joinpath('config.json'))
else:
params.config_filename = config_filename or 'config.json'

Expand Down Expand Up @@ -168,14 +163,13 @@ def main(from_package=False):
opts, flags = parser.parse_known_args(sys.argv[1:])
params = get_params_from_config(opts.config)

if opts.batch_mode:
params.batch_mode = True

if opts.debug:
params.debug = opts.debug
is_debug = logging.getLogger().level <= logging.DEBUG
logging.getLogger().setLevel((logging.WARNING if params.batch_mode else logging.INFO) if is_debug else logging.DEBUG)
logging.info('Debug %s', 'OFF' if is_debug else 'ON')

if opts.batch_mode:
params.batch_mode = True
logging.basicConfig(level=logging.WARNING if params.batch_mode else logging.DEBUG if opts.debug else logging.INFO, format='%(message)s')

if opts.login_v3:
params.login_v3 = 'TRUE'.startswith(str(opts.login_v3).upper())
Expand Down Expand Up @@ -209,8 +203,6 @@ def main(from_package=False):
if opts.command == '?' or not params.commands:
usage('')

logging.basicConfig(level=logging.WARNING if params.batch_mode else logging.INFO, format='%(message)s', force=True)

if params.timedelay >= 1 and params.commands:
cli.runcommands(params)
else:
Expand Down Expand Up @@ -243,12 +235,7 @@ def set_working_dir():
opts, flags = parser.parse_known_args(sys.argv[1:])

if opts.launched_with_shortcut:
current_user_home_path = str(Path.home())

logging.debug("User home: %s" % current_user_home_path)

current_user_home_path = str(Path.home())
os.chdir(current_user_home_path)
os.chdir(Path.home())


if __name__ == '__main__':
Expand Down