-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b21803
commit 5344213
Showing
6 changed files
with
55 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '1.2' | ||
__version__ = '1.3' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import os | ||
import configparser | ||
import sys | ||
import logging | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
def setup(subparsers, parent_parser): | ||
summary = 'Initilize fusion app with creation of aws fusion alias' | ||
parser = subparsers.add_parser('init', description=summary, help=summary, parents=[parent_parser]) | ||
parser.set_defaults(func=run) | ||
|
||
def run(args): | ||
cli_dir = os.path.expanduser(os.path.join('~', '.aws', 'cli')) | ||
|
||
def create_alias(config: configparser.ConfigParser): | ||
LOG.debug('Creating fusion aws alias') | ||
if not config.has_section('toplevel'): | ||
config.add_section('toplevel') | ||
config['toplevel']['fusion'] = f'!{sys.executable} -m aws_fusion.app' | ||
|
||
def update_aws_cli_alias_file(): | ||
if not os.path.isdir(cli_dir): | ||
LOG.debug(f"Path {cli_dir} doesn't exists, creating" ) | ||
os.makedirs(cli_dir) | ||
cli_alias_full_path = os.path.join(cli_dir, 'alias') | ||
config = configparser.ConfigParser() | ||
|
||
if os.path.isfile(cli_alias_full_path): | ||
LOG.debug(f'Found alias file {cli_alias_full_path}') | ||
config.read(cli_alias_full_path) | ||
|
||
create_alias(config) | ||
|
||
with os.fdopen(os.open(cli_alias_full_path, os.O_WRONLY | os.O_CREAT, 0o600), 'w') as f: | ||
f.truncate() | ||
config.write(f) | ||
LOG.debug(f'Updated alias file {cli_alias_full_path}') | ||
|
||
update_aws_cli_alias_file() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters