Skip to content

Commit

Permalink
CASMINST-6387 Fix cray Pyinstaller
Browse files Browse the repository at this point in the history
The `pyinstaller` build for `craycli` is producing an invalid binary
that returns nothing (no flags or commands produce any output).

This block of code was removed in #100, and part of it needs to be
returned.

This also cleans up the dual `CONTEXT_SETTING` and `CONTEXT_SETTINGS`.
  • Loading branch information
rustydb committed May 24, 2023
1 parent e0714f3 commit e402bd0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions cray/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import os
import re
import sys
import click

from cray.auth import AuthUsername
Expand All @@ -43,7 +44,7 @@
from cray.formatting import format_result
from cray.utils import get_hostname

CONTEXT_SETTING = {
CONTEXT_SETTINGS = {
'obj': {
'config_dir': '',
'globals': {},
Expand All @@ -55,7 +56,6 @@
'help_option_names': ['-h', '--help'],
}

CONTEXT_SETTINGS = {}

def rsa_required(config):
"""Get the value for 'auth.login.rsa_required' from the CLI
Expand Down Expand Up @@ -83,10 +83,9 @@ def rsa_required(config):
@group(
cls=GeneratedCommands,
base_path=os.path.dirname(__file__),
context_settings=CONTEXT_SETTING
context_settings=CONTEXT_SETTINGS
) # pragma: NO COVER
@click.pass_context
@click.version_option()
def cli(ctx, *args, **kwargs):
""" Cray management and workflow tool"""
pass
Expand Down Expand Up @@ -215,3 +214,11 @@ def cli_cb(ctx, result, **kwargs):
# Use click echo instead of our logging because we always want to echo
# our results
click.echo(format_result(result, ctx.obj['globals'].get('format')))


# Handle the usage of ``cli`` for Pyinstaller.
if getattr(sys, 'frozen', False):
click.version_option()(cli)
cli(sys.argv[1:])
else:
click.version_option()(cli)

0 comments on commit e402bd0

Please sign in to comment.