Skip to content

Commit fa76408

Browse files
committed
Merge pull request #1767 from mboersma/1749-no-pyyaml
ref(client): remove PyYAML dependency and save to ~/.deis/client.json
2 parents 4d7700e + 230a8c6 commit fa76408

9 files changed

Lines changed: 23 additions & 17 deletions

File tree

client/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ you used to provision the server. You can make a symlink or shell alias for
7878

7979
.. code-block:: console
8080
81-
$ pip install docopt==0.6.2 python-dateutil==2.2 PyYAML==3.11 requests==2.3.0
81+
$ pip install docopt==0.6.2 python-dateutil==2.2 requests==2.3.0 termcolor==1.1.0
8282
$ sudo ln -fs $(pwd)/client/deis.py /usr/local/bin/deis
8383
$ deis
8484
Usage: deis <command> [<args>...]

client/deis.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
from docopt import DocoptExit
6969
import requests
7070
from termcolor import colored
71-
import yaml
7271

7372
__version__ = '0.12.0-dev'
7473

@@ -180,18 +179,30 @@ class Settings(dict):
180179
"""
181180
Settings backed by a file in the user's home directory
182181
183-
On init, settings are loaded from ~/.deis/client.yaml
182+
On init, settings are loaded from ~/.deis/client.json
184183
"""
185184

186185
def __init__(self):
187186
path = os.path.expanduser('~/.deis')
188187
# Create the $HOME/.deis dir if it doesn't exist
189188
if not os.path.isdir(path):
190189
os.mkdir(path, 0700)
191-
self._path = os.path.join(path, 'client.yaml')
190+
self._path = os.path.join(path, 'client.json')
192191
if not os.path.exists(self._path):
192+
settings = {}
193+
# try once to convert the old settings file if it exists
194+
# FIXME: this code can be removed in November 2014 or thereabouts, that's long enough.
195+
old_path = os.path.join(path, 'client.yaml')
196+
if os.path.exists(old_path):
197+
try:
198+
with open(old_path, 'r') as f:
199+
txt = f.read().replace('{', '{"', 1).replace(':', '":', 1).replace("'", '"')
200+
settings = json.loads(txt)
201+
os.remove(old_path)
202+
except:
203+
pass # ignore errors, at least we tried to convert it
193204
with open(self._path, 'w') as f:
194-
f.write(yaml.safe_dump({}))
205+
json.dump(settings, f)
195206
# load initial settings
196207
self.load()
197208

@@ -201,15 +212,15 @@ def load(self):
201212
"""
202213
with open(self._path) as f:
203214
data = f.read()
204-
settings = yaml.safe_load(data)
215+
settings = json.loads(data)
205216
self.update(settings)
206217
return settings
207218

208219
def save(self):
209220
"""
210221
Serialize and save settings to the filesystem
211222
"""
212-
data = yaml.safe_dump(dict(self))
223+
data = json.dumps(dict(self))
213224
with open(self._path, 'w') as f:
214225
f.write(data)
215226
return data

client/setup.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@
5757
],
5858
long_description=LONG_DESCRIPTION,
5959
install_requires=[
60-
'docopt==0.6.2', 'python-dateutil==2.2',
61-
'PyYAML==3.11', 'requests==2.3.0',
62-
'termcolor==1.1.0'
60+
'docopt==0.6.2', 'python-dateutil==2.2', 'requests==2.3.0', 'termcolor==1.1.0'
6361
],
6462
zip_safe=True,
6563
**KWARGS)

controller/dev_requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Deis client requirements
22
docopt==0.6.2
33
python-dateutil==2.2
4-
#PyYAML==3.11
54
requests==2.3.0
65

76
# PyInstaller builds client binaries

docs/docs_requirements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@ docker-py==0.4.0
2020
gunicorn==18.0
2121
psycopg2==2.5.2
2222
python-etcd==0.3.0
23-
PyYAML==3.11
2423
South==1.0
2524

2625
# Deis client requirements
2726
docopt==0.6.2
2827
python-dateutil==2.2
29-
#PyYAML==3.11
3028
requests==2.3.0
3129
termcolor==1.1.0
3230

docs/installing_deis/register-admin-user.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ you used to provision the server. You can make a symlink or shell alias for
1919

2020
.. code-block:: console
2121
22-
$ pip install docopt==0.6.2 python-dateutil==2.2 PyYAML==3.11 requests==2.3.0
22+
$ pip install docopt==0.6.2 python-dateutil==2.2 requests==2.3.0 termcolor==1.1.0
2323
$ sudo ln -fs $(pwd)/client/deis.py /usr/local/bin/deis
2424
$ deis
2525
Usage: deis <command> [<args>...]

docs/using_deis/install-client.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ you used to provision the server. You can make a symlink or shell alias for
1717

1818
.. code-block:: console
1919
20-
$ pip install docopt==0.6.2 python-dateutil==2.2 PyYAML==3.11 requests==2.3.0
20+
$ pip install docopt==0.6.2 python-dateutil==2.2 requests==2.3.0 termcolor==1.1.0
2121
$ sudo ln -fs $(pwd)/client/deis.py /usr/local/bin/deis
2222
$ deis
2323
Usage: deis <command> [<args>...]

tests/bin/build-deis-cli.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55
virtualenv --system-site-packages venv
66
. venv/bin/activate
7-
pip install docopt==0.6.2 python-dateutil==2.2 PyYAML==3.11 requests==2.3.0 pyinstaller==2.1 termcolor==1.1.0
7+
pip install docopt==0.6.2 python-dateutil==2.2 requests==2.3.0 pyinstaller==2.1 termcolor==1.1.0
88
make -C client/ client

tests/bin/test-integration.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ set -e
3131
# Build updated Deis CLI and use it for testing
3232
virtualenv --system-site-packages venv
3333
. venv/bin/activate
34-
pip install docopt==0.6.2 python-dateutil==2.2 PyYAML==3.11 requests==2.3.0 pyinstaller==2.1 termcolor==1.1.0
34+
pip install docopt==0.6.2 python-dateutil==2.2 requests==2.3.0 pyinstaller==2.1 termcolor==1.1.0
3535
make -C client/ client
3636
chmod +x client/dist/deis
3737
export PATH=`pwd`/client/dist:$PATH

0 commit comments

Comments
 (0)