Skip to content
This repository was archived by the owner on Oct 30, 2018. It is now read-only.

Commit 5ca110c

Browse files
authored
Merge pull request #80 from Syncano/release-v0.8
[RELEASE v0.8]
2 parents b8440ad + 48070d6 commit 5ca110c

50 files changed

Lines changed: 624 additions & 221 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.isort.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
line_length=120
33
multi_line_output=3
44
default_section=THIRDPARTY
5-
skip=.eggs,egg-info,builds,dist,dev.py
5+
skip=.eggs,egg-info,builds,dist,dev.py,.tox,scripts

README.rst

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,34 @@ The instance name will be set as default and used in all CLI commands.
5353
If you want to override this setting for a specific command, use --instance-name eg::
5454

5555
syncano sync --instance-name new-instance-1234 pull
56+
57+
If you need to change default instance name, used for all future commands, use::
58+
59+
syncano default name_of_new_default_instance
60+
61+
62+
If you do not have an Syncano account use `syncano init` command::
63+
64+
syncano init
65+
66+
And follow the steps. CLI will ask you about `email` and `password`, it will also create an Instance for you.
67+
After `syncano init` you can start with getting the list of your Instances::
68+
69+
syncano instances list
70+
71+
72+
To obtain a help, type::
73+
74+
syncano --help
75+
76+
To display a help for specific command, type::
77+
78+
syncano instances --help
79+
80+
And::
81+
82+
syncano instances list --help
83+
5684

5785
Documentation
5886
=============
@@ -107,8 +135,8 @@ Will display custom sockets from `my_instance_name` - because it is set to be a
107135

108136
After a registration - there's no default instance set. So it's desired to create one and set it as default::
109137

110-
syncano instance create my_new_instance
111-
syncano instance default my_new_instance
138+
syncano instances create my_new_instance
139+
syncano instances default my_new_instance
112140

113141
It's worth to note that `instance_name` must be unique - but you will get appropriate message if you encounter such case.
114142

@@ -259,19 +287,19 @@ Syncano Hosting
259287
Syncano Hosting is a simple way to host your static files on Syncano servers.
260288
The CLI supports it in the following way:
261289

262-
This command will list files for currently hosted website::
290+
This command will list currently defined hostings in the instance::
263291

264292
syncano hosting list
265293

294+
This command will list files for currently hosted website (for `default` hosting)::
295+
296+
syncano hosting list files
297+
266298
This command will publish all files inside *<base_dir>* to the default Syncano Hosting instance.
267299
When publishing the whole directory, the structure will be mapped on Syncano.::
268300

269301
syncano hosting publish <base_dir>
270302

271-
This command will unpublish currently published hosting::
272-
273-
syncano hosting unpublish
274-
275303

276304
This command will permamently delete the hosting::
277305

@@ -285,6 +313,14 @@ This command will update single file::
285313

286314
syncano hosting update hosting/file/path local/file/path
287315

316+
For each of the above command you can specify the domain to change just after hosting command, example::
317+
318+
syncano hosting --domain staging publish <base_dir>
319+
320+
Will create a new hosting which will be available under: `<instance_name>--staging.syncano.site`
321+
If this hosting is also a default one, it will be available under: `<instance_name>.syncano.site`.
322+
323+
288324
Custom Sockets
289325
==============
290326

@@ -311,6 +347,10 @@ Display chosen Custom Socket details::
311347

312348
syncano sockets details socket_name
313349

350+
Display Custom Socket config (with name: `socket_name`)::
351+
352+
syncano sockets config socket_name
353+
314354
Delete a Custom Socket::
315355

316356
syncano sockets delete socket_name
@@ -323,14 +363,15 @@ Create a template from an existing Custom Socket::
323363

324364
syncano sockets template /path/to/out --socket socket_name
325365

326-
Run endpoint defined in Custom Socket::s
366+
Run endpoint defined in Custom Socket::
327367

328368
syncano sockets run socket_name/endpoint_name
329369

330370
Run endpoint providing POST data::
331371

332372
syncano sockets run socket_name/my_endpoint_12 POST -d one=1
333373

374+
334375
In all of the above cases you can override the Syncano instance being used::
335376

336377
--instance-name my_instance_name

circle.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
machine:
22
python:
3-
version: 2.7.5
3+
version: 2.7.10
44

55
dependencies:
66
pre:
77
- pip install -U setuptools
8+
- pip install -r requirements-tests.txt
9+
post:
10+
- pyenv local 3.4.3 2.7.10
811

912
test:
1013
override:
11-
- pip install -r requirements-tests.txt
12-
- flake8 .
13-
- isort --recursive --check-only .
1414
- python setup.py check -s --restructuredtext
15-
- python setup.py test
15+
- tox
1616

1717
deployment:
1818
production:

docs/custom_sockets/docs.md

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
author:
88
name: Sebastian
99
email: sebastian@syncano.com
10+
config:
11+
constants:
12+
secret_key: value
13+
prompt:
14+
user_key:
15+
type: string
16+
description: A Syncano user key
1017
icon:
1118
name: icon_name
1219
color: red
@@ -34,6 +41,20 @@
3441
runtime_name: python_library_v5.0
3542
file: scripts/script3.py
3643

44+
classes:
45+
country:
46+
schema:
47+
- name: name
48+
type: string
49+
- name: topLevelDomain
50+
type: string
51+
- name: capital
52+
type: string
53+
- name: alpha2Code
54+
type: string
55+
- name: alpha3Code
56+
type: string
57+
3758
### YAML file structure explanation
3859

3960
* `name` is the name of your new Custom Socket - this should be unique;
@@ -46,6 +67,8 @@
4667
* can be found in `metadata` field on Custom Socket in Syncano Dasboard.
4768
* `icon` is metadata information about your Custom Socket - it stores the icon name used and its color (used in Syncano Dashboard)
4869
* `endpoints` - definition of the endpoints in a Custom Socket; Currently supported endpoints can be only of `script` type.
70+
* `config` - stores the metadata about custom socket configuration; constants are config variables that are passed one-to-one
71+
from yaml file definitions; the `prompt` config section - this variables will be requested from user during installation.
4972

5073
Consider this example:
5174

@@ -76,8 +99,8 @@
7699
The difference is that we now define what happens for the different HTTP methods. When the GET HTTP method is used,
77100
`script_endpoint_3` script endpoint will be run. When the POST HTTP method is used - `script_endpoint_2` endpoint will be executed.
78101

79-
Currently only Script Endpoints are supported, which run scripts under the hood. But don't worry,
80-
we are working on adding more options!
102+
Currently Script Endpoints and Classes are supported, which run scripts under the hood.
103+
We are working on adding more options!
81104

82105
* `dependencies` - the definition of your Custom Socket dependencies. They define all dependency objects
83106
which will be called when the endpoint is requested.
@@ -90,7 +113,7 @@ which will be called when the endpoint is requested.
90113
runtime_name: python_library_v5.0
91114
file: scripts/script1.py
92115

93-
Above YAML snippet defines one dependency:
116+
Above YAML snippet defines four dependencies (three of type `script` and one of type `class`):
94117
* `script` - type of the dependency (defined using `scripts` keyword).
95118
* `script_endpoint_1` - name of the dependency; it's an important element, because that's the place where you connect a dependency to an endpoint.
96119
* `runtime_name` is name of the runtime used in a script;
@@ -99,6 +122,26 @@ which will be called when the endpoint is requested.
99122
It should be noted that when defining Custom Scripts, we suggest following some basic directory structure- for
100123
better work organization. We recommend storing scripts under the `scripts` directory - this is why the filename
101124
is a relative path: `scripts/script1.py`. Of course your can also follow your own rules, e.g. by using a flat file structure.
125+
126+
The class dependency looks as follows:
127+
128+
classes:
129+
country:
130+
schema:
131+
- name: name
132+
type: string
133+
- name: topLevelDomain
134+
type: string
135+
- name: capital
136+
type: string
137+
- name: alpha2Code
138+
type: string
139+
- name: alpha3Code
140+
type: string
141+
142+
This simple mean that Custom Socket requires a class `country` to work properly. Under the hood - Syncano Platform
143+
will check if this class exists (if not - create it) and ensure that all required files defined in `schema` are present.
144+
102145

103146

104147
## Custom Socket directory structure

requirements-tests.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
tox==2.3.1
12
flake8==2.4.1
23
isort==4.0.0
34
mock==1.3.0

run_tests.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
flake8 .
6+
isort --recursive --check-only .
7+
8+
python setup.py test

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
setup(
88
name='syncano-cli',
9-
version='0.7',
9+
version='0.8',
1010
description='Syncano command line utilities',
1111
long_description=README,
1212
author='Marcin Swiderski, Sebastian Opalczynski',
1313
author_email='marcin.swiderski@syncano.com, sebastian.opalczynski@syncano.com',
1414
url='https://github.com/Syncano/syncano-cli',
1515
packages=find_packages(),
1616
license='MIT',
17-
install_requires=['syncano>=5.4.2', 'PyYaml>=3.11', 'watchdog>=0.8.3', 'click>=6.6'],
17+
install_requires=['syncano>=5.4.4', 'PyYaml>=3.11', 'watchdog>=0.8.3', 'click>=6.6'],
1818
test_suite='tests',
1919
entry_points="""
2020
[console_scripts]

syncano_cli/account/command.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def __init__(self, config_path):
1010
self.connection = syncano.connect()
1111
self.config_path = config_path
1212

13-
def register(self, email, password, first_name, last_name, invitation_key):
13+
def register(self, email, password, first_name=None, last_name=None, invitation_key=None):
1414
api_key = self.connection.connection().register(
1515
email=email,
1616
password=password,
@@ -19,6 +19,6 @@ def register(self, email, password, first_name, last_name, invitation_key):
1919
invitation_key=invitation_key
2020
)
2121

22-
ACCOUNT_CONFIG.set('DEFAULT', 'api_key', api_key)
23-
with open(self.config_path, 'wb') as fp:
22+
ACCOUNT_CONFIG.set('DEFAULT', 'key', api_key)
23+
with open(self.config_path, 'wt') as fp:
2424
ACCOUNT_CONFIG.write(fp)

syncano_cli/account/commands.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ def top_account():
1212
@click.pass_context
1313
@click.option('--config', help=u'Account configuration file.')
1414
def accounts(ctx, config):
15-
"""
16-
Handle Syncano account functionality;
17-
"""
15+
"""Handle Syncano account functionality."""
1816
account_commands = AccountCommands(config_path=config or ACCOUNT_CONFIG_PATH)
1917
ctx.obj['account_commands'] = account_commands
2018

syncano_cli/base/connection.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
# -*- coding: utf-8 -*-
2-
from ConfigParser import NoOptionError, NoSectionError
3-
2+
import six
43
import syncano
54
from syncano.exceptions import SyncanoException
65
from syncano_cli.base.exceptions import BadCredentialsException, InstanceNotFoundException
76
from syncano_cli.config import ACCOUNT_CONFIG, ACCOUNT_CONFIG_PATH
87

8+
if six.PY2:
9+
from ConfigParser import NoOptionError, NoSectionError
10+
elif six.PY3:
11+
from configparser import NoOptionError, NoSectionError
12+
else:
13+
raise ImportError()
14+
915

1016
def get_instance_name(config, instance_name):
1117
ACCOUNT_CONFIG.read(config)

0 commit comments

Comments
 (0)