Repository: deis/deis

Issue:
`deis info` on invalid app does not return 404
First reported by @piotrb in IRC.

``` console
20:17:24 <piotrb> just hit a weird bug .. when trying to get perms (for example) in a project that doesn't exist and has a capital letter or symbol at its start .. I get a json dump of what looks like the api response from app list or something .. doesn't happen with lowecase or numbers .. perhaps a weird regex match?
20:17:58 <piotrb> on lowercase I get a 404 .. assumingly signifying the project doesn't exist

$ deis info -a Foo                                                                                                           
=== Foo Application
{
  "count": 2,
  "previous": null,
  "results": [
    {
      "updated": "2014-08-26T03:39:32.879Z",
      "uuid": "{removed}",
      "created": "2014-08-26T03:23:58.550Z",
      "url": "{removed}",
      "cluster": "dev",
      "owner": "admin",
      "id": "{removed}",
      "structure": "{\"web\": 1}"
    },
    {
      "updated": "2014-08-26T08:50:37.809Z",
      "uuid": "{removed}",
      "created": "2014-08-26T08:48:31.411Z",
      "url": "{removed}",
      "cluster": "dev",
      "owner": "admin",
      "id": "{removed}",
      "structure": "{\"web\": 1}"
    }
  ],
  "next": null
}

=== Foo Processes
Traceback (most recent call last):
  File "/Users/piotr/.python/bin/deis", line 9, in <module>
    load_entry_point('deis==0.12.0', 'console_scripts', 'deis')()
  File "/Users/piotr/.python/lib/python2.7/site-packages/deis.py", line 2168, in main
    _dispatch_cmd(method, args)
  File "/Users/piotr/.python/lib/python2.7/site-packages/deis.py", line 2122, in _dispatch_cmd
    method(args)
  File "/Users/piotr/.python/lib/python2.7/site-packages/deis.py", line 561, in apps_info
    self.ps_list(args)
  File "/Users/piotr/.python/lib/python2.7/site-packages/deis.py", line 1547, in ps_list
    c_map.setdefault(item['type'], []).append(item)
KeyError: 'type'

20:35:42 <piotrb> neither foo nor Foo exist in actuality
20:35:51 <piotrb> and there is a total of 2 apps in the whole cluster
```



Discussion:
to note, this only occurs with app names capitialized:

```
><> deis info -a test
404 NOT FOUND
Detail:
Not found

><> === Test Application
{
  "count": 2,
[...]
```


Resolving patch:
diff --git a/client/deis.py b/client/deis.py
--- a/client/deis.py
+++ b/client/deis.py
@@ -94,9 +94,9 @@ def __init__(self):
     def app(self):
         """Retrieve the application's name."""
         try:
-            return self._get_name_from_git_remote(self.git_root())
+            return self._get_name_from_git_remote(self.git_root()).lower()
         except EnvironmentError:
-            return os.path.basename(os.getcwd())
+            return os.path.basename(os.getcwd()).lower()
 
     def is_git_app(self):
         """Determines if this app is a git repository. This is important in special cases
@@ -1941,6 +1941,8 @@ def parse_args(cmd):
 
 def _dispatch_cmd(method, args):
     logger = logging.getLogger(__name__)
+    if args.get('--app'):
+        args['--app'] = args['--app'].lower()
     try:
         method(args)
     except requests.exceptions.ConnectionError as err:


Test patch: