Skip to content

Adds Shell / Moves fixtures#596

Merged
underscorephil merged 15 commits into
masterfrom
shell
Aug 11, 2015
Merged

Adds Shell / Moves fixtures#596
underscorephil merged 15 commits into
masterfrom
shell

Conversation

@sudorandom

Copy link
Copy Markdown
Contributor

This commit adds a shell that can be started by simply calling 'slcli' with no command. The shell can be exited using ctrl + d. The shell has autocomplete. The shell probably needs a way to set global options (--fixtures, --debug, --proxy, --config, --timings, etc). In the future, this mode can be used to prompt for user input.

Fixtures were moved to a higher level to avoid needing test dependencies (nosetests, testtools, etc) to use fixtures.

This is still a bit of a WiP.

This commit adds a shell that can be started by simply calling 'slcli' with no
command. The shell can be exited using ctrl + d. The shell has autocomplete.
The shell probably needs a way to set global options (--fixtures, --debug, --proxy,
--config, --timings, etc). In the future, this mode can be used to prompt for user
input.

Fixtures were moved to a higher level to avoid needing test dependencies to use fixtures.
@landscape-bot

Copy link
Copy Markdown

Code Health
Repository health decreased by 0.00% when pulling 9acd37b on shell into 751b3d4 on master.

@landscape-bot

Copy link
Copy Markdown

Code Health
Code quality remained the same when pulling be69869 on softlayer:shell into 751b3d4 on softlayer:master.

@sudorandom

Copy link
Copy Markdown
Contributor Author

Example Usage:

slcli shell
(0)> vs list
....
(0)>

Currently, the global options passed in when using slcli shell are maintained in every command in the shell. Those options can be overridden on a per-command basis. For example

slcli --fixtures shell
(0)> vs list
:.....:..........:..............:.............:............:........:
:  id : hostname :  primary_ip  :  backend_ip : datacenter : action :
:.....:..........:..............:.............:............:........:
: 100 : vs-test1 : 172.16.240.2 : 10.45.19.37 :   TEST00   :   -    :
: 104 : vs-test2 : 172.16.240.7 : 10.45.19.35 :   TEST00   :   -    :
:.....:..........:..............:.............:............:........:
(0)> --no-fixtures vs list
... (non-fixture data)...

The only place where this doesn't work as expected is the verbosity/debug level.

@landscape-bot

Copy link
Copy Markdown

Code Health
Repository health decreased by 0.03% when pulling d315b35 on shell into 751b3d4 on master.

@landscape-bot

Copy link
Copy Markdown

Code Health
Repository health decreased by 0.03% when pulling c7e10a8 on shell into 751b3d4 on master.

Comment thread SoftLayer/shell/core.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be

    os.makedirs(app_path)

On mac I get the following.
os.path.dirname: /Users/christopher/Library/Application Support
app_path: /Users/christopher/Library/Application Support/softlayer

~/Code/softlayer-python  $ ./slcli shell
Traceback (most recent call last):
  File "./slcli", line 7, in <module>
    load_entry_point('SoftLayer', 'console_scripts', 'slcli')()
  File "/Users/christopher/Code/softlayer-python/SoftLayer/CLI/core.py", line 178, in main
    cli.main(**kwargs)
  File "/Library/Python/2.7/site-packages/click-3.3-py2.7.egg/click/core.py", line 590, in main
    rv = self.invoke(ctx)
  File "/Library/Python/2.7/site-packages/click-3.3-py2.7.egg/click/core.py", line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Library/Python/2.7/site-packages/click-3.3-py2.7.egg/click/core.py", line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Library/Python/2.7/site-packages/click-3.3-py2.7.egg/click/core.py", line 416, in invoke
    return callback(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/click-3.3-py2.7.egg/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/Library/Python/2.7/site-packages/click-3.3-py2.7.egg/click/core.py", line 416, in invoke
    return callback(*args, **kwargs)
  File "/Users/christopher/Code/softlayer-python/SoftLayer/shell/core.py", line 54, in cli
    os.makedirs(os.path.dirname(app_path))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 17] File exists: '/Users/christopher/Library/Application Support'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed now, thanks!

@allmightyspiff

Copy link
Copy Markdown
Member

Spot checked my favorite slcli calls and they all work great.

underscorephil added a commit that referenced this pull request Aug 11, 2015
Adds Shell / Moves fixtures
@underscorephil underscorephil merged commit fe02ab9 into master Aug 11, 2015
@sudorandom sudorandom deleted the shell branch August 11, 2015 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants