Skip to content
This repository was archived by the owner on Oct 30, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
a0bf56d
Merge pull request #63 from Syncano/release-v0.7
opalczynski Sep 13, 2016
01025c5
Merge pull request #65 from Syncano/master
opalczynski Sep 13, 2016
b3b2a67
[CORE-1666] add info after hosting publish; add template command in s…
opalczynski Sep 13, 2016
4cc11a4
[skip ci] Info on default instance in login section
MariuszWisniewski Sep 13, 2016
a9c7338
Merge pull request #67 from Syncano/default-instance-readme
opalczynski Sep 15, 2016
f154ee1
[CORE-1670] add possibility to handle endpoint metadatal
opalczynski Sep 15, 2016
eb85275
Merge pull request #66 from Syncano/CORE-1666
opalczynski Sep 15, 2016
bc47380
[CORE-1670] remove exception about call object validation;
opalczynski Sep 15, 2016
d894e87
[CORE-1670] correct metadata creation;
opalczynski Sep 15, 2016
f4bcf88
[CORE-1670] metadata handling;
opalczynski Sep 16, 2016
a1a17d0
[CORE-1670] correct flake and isort issues;
opalczynski Sep 16, 2016
4acb4ab
[CORE-1670] correct example in metadata handling;
opalczynski Sep 16, 2016
2dc972b
[CORE-1670] correct tests - instance name format changed;
opalczynski Sep 16, 2016
a529bdc
[CORE-1670] correct getting metadata (old socket have no such field)
opalczynski Sep 16, 2016
105e66e
[CORE-1670] correct print_result function;
opalczynski Sep 16, 2016
efa8e76
Merge pull request #70 from Syncano/CORE-1670
opalczynski Sep 16, 2016
d884c2d
[CORE-1672] add python3 tests: tox;
opalczynski Sep 16, 2016
6a12502
[CORE-1672] add python3 tests: tox - add env variables;
opalczynski Sep 16, 2016
012e02d
[CORE-1672] add python3 tests: correct yml;
opalczynski Sep 16, 2016
8fb32b5
[CORE-1672] add python3 tests: correct yml;
opalczynski Sep 16, 2016
6498f2a
[CORE-1672] add python3 tests: make run_tests executable;
opalczynski Sep 16, 2016
a8e8f37
[CORE-1672] add python3 tests: skip .tox directory from isort;
opalczynski Sep 16, 2016
0c7c389
[CORE-1672] add python3 tests: correct circle test run;
opalczynski Sep 16, 2016
65f2aac
[CORE-1672] add python3 tests: correct circle test run;
opalczynski Sep 16, 2016
97cc691
[CORE-1672] add python3 tests: correct circle test run;
opalczynski Sep 16, 2016
3309aad
[CORE-1672] Python3 related changes;
opalczynski Sep 16, 2016
04fe313
Improve docstrings
adamwardecki Sep 16, 2016
535ab24
[CORE-1672] flake8 issues;
opalczynski Sep 16, 2016
f10ca76
[CORE-1672] add input to test_configure;
opalczynski Sep 16, 2016
2152ea2
[CORE-1672] add input to test_configure;
opalczynski Sep 16, 2016
a9024b2
[CORE-1672] another bunch of corrects: skip scripts in isort check; c…
opalczynski Sep 16, 2016
8950a63
[CORE-1672] skip scripts;
opalczynski Sep 16, 2016
1da337a
[CORE-1672] correct tests;
opalczynski Sep 19, 2016
60f502a
[CORE-1672] change file read/write to text mode;
opalczynski Sep 19, 2016
fed4562
[CORE-1672] change all iteritems to six.iteritems;
opalczynski Sep 19, 2016
e87bf99
[CORE-1672] change all iteritems to six.iteritems;
opalczynski Sep 19, 2016
9ae9732
[CORE-1672] corrects tests;
opalczynski Sep 19, 2016
07e8322
[CORE-1672] correct file management in hosting, correct parse to sync…
opalczynski Sep 19, 2016
c07123f
[CORE-1672] correct tests asserts;
opalczynski Sep 19, 2016
18bafae
[CORE-1672] change file transfer - to do not change the LIB;
opalczynski Sep 19, 2016
8cd9829
[CORE-1672] correct isort issues;
opalczynski Sep 19, 2016
ea682d9
[CORE-1672] correct configure test;
opalczynski Sep 19, 2016
01ecea2
[CORE-1672] correct attributes ordering;
opalczynski Sep 19, 2016
cb23d80
[CORE-1682] remove custom formatting for examples;
opalczynski Sep 20, 2016
98ae806
Merge pull request #71 from adamwardecki/help-fixes
opalczynski Sep 20, 2016
e51ceb4
Merge pull request #73 from Syncano/CORE-1682
opalczynski Sep 21, 2016
2c7ec60
Merge pull request #72 from Syncano/CORE-1672
opalczynski Sep 21, 2016
47e03b5
[CORE-1684] add support for multiple domains;
opalczynski Sep 21, 2016
39499ae
[CORE-1684] correct README;
opalczynski Sep 21, 2016
88dc5ad
[CORE-1684] correct domain option in tests;
opalczynski Sep 21, 2016
fc6efba
[CORE-1684] add domain to delete file in tests;
opalczynski Sep 21, 2016
3afb6e5
[CORE-1684] correct test assert;
opalczynski Sep 21, 2016
3351638
[CORE-1684] correct test assert;
opalczynski Sep 21, 2016
e75885c
Merge pull request #74 from Syncano/CORE-1684
opalczynski Sep 22, 2016
ae06756
[CORE-1685] add class dependency support, correct config handling;
opalczynski Sep 23, 2016
8f6a6b1
[CORE-1685] update yml file documentation;
opalczynski Sep 23, 2016
e2da2cb
[CORE-1685] add class dependecy to the socket template definition;
opalczynski Sep 23, 2016
8f89cd3
[CORE-1685] BUMP python lib version;
opalczynski Sep 23, 2016
ce9b3cf
[CORE-1685] add possibility to read CustomSocket configuration;
opalczynski Sep 26, 2016
ab3c65a
[CORE-1685] correct test with custom socket config;
opalczynski Sep 26, 2016
f3f93b5
[CORE-1685] re-organize tests; correct template (use proper config now);
opalczynski Sep 26, 2016
4b1fe01
[CORE-1685] correct tests;
opalczynski Sep 26, 2016
87cdf45
[CORE-1685] correct tests;
opalczynski Sep 26, 2016
94afec1
Merge pull request #75 from Syncano/CORE-1685
opalczynski Sep 26, 2016
852769e
[CORE-1687] add syncano init command;
opalczynski Sep 26, 2016
8b2aa01
[CORE-1687] fixes in namings; correct publish info: default or not;
opalczynski Sep 26, 2016
d2d01a5
[CORE-1687] correct README; update docstrings;
opalczynski Sep 26, 2016
352436b
[CORE-1687] correct tests with register;
opalczynski Sep 26, 2016
cabdc8d
Merge pull request #78 from Syncano/CORE-1687
opalczynski Sep 27, 2016
588e83d
[RELEASE v0.8] bump the version;
opalczynski Sep 27, 2016
48070d6
[RELEASE v0.8] bump python lib version;
opalczynski Sep 27, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
line_length=120
multi_line_output=3
default_section=THIRDPARTY
skip=.eggs,egg-info,builds,dist,dev.py
skip=.eggs,egg-info,builds,dist,dev.py,.tox,scripts
57 changes: 49 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,34 @@ The instance name will be set as default and used in all CLI commands.
If you want to override this setting for a specific command, use --instance-name eg::

syncano sync --instance-name new-instance-1234 pull

If you need to change default instance name, used for all future commands, use::

syncano default name_of_new_default_instance


If you do not have an Syncano account use `syncano init` command::

syncano init

And follow the steps. CLI will ask you about `email` and `password`, it will also create an Instance for you.
After `syncano init` you can start with getting the list of your Instances::

syncano instances list


To obtain a help, type::

syncano --help

To display a help for specific command, type::

syncano instances --help

And::

syncano instances list --help


Documentation
=============
Expand Down Expand Up @@ -107,8 +135,8 @@ Will display custom sockets from `my_instance_name` - because it is set to be a

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

syncano instance create my_new_instance
syncano instance default my_new_instance
syncano instances create my_new_instance
syncano instances default my_new_instance

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

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

This command will list files for currently hosted website::
This command will list currently defined hostings in the instance::

syncano hosting list

This command will list files for currently hosted website (for `default` hosting)::

syncano hosting list files

This command will publish all files inside *<base_dir>* to the default Syncano Hosting instance.
When publishing the whole directory, the structure will be mapped on Syncano.::

syncano hosting publish <base_dir>

This command will unpublish currently published hosting::

syncano hosting unpublish


This command will permamently delete the hosting::

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

syncano hosting update hosting/file/path local/file/path

For each of the above command you can specify the domain to change just after hosting command, example::

syncano hosting --domain staging publish <base_dir>

Will create a new hosting which will be available under: `<instance_name>--staging.syncano.site`
If this hosting is also a default one, it will be available under: `<instance_name>.syncano.site`.


Custom Sockets
==============

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

syncano sockets details socket_name

Display Custom Socket config (with name: `socket_name`)::

syncano sockets config socket_name

Delete a Custom Socket::

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

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

Run endpoint defined in Custom Socket::s
Run endpoint defined in Custom Socket::

syncano sockets run socket_name/endpoint_name

Run endpoint providing POST data::

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


In all of the above cases you can override the Syncano instance being used::

--instance-name my_instance_name
Expand Down
10 changes: 5 additions & 5 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
machine:
python:
version: 2.7.5
version: 2.7.10

dependencies:
pre:
- pip install -U setuptools
- pip install -r requirements-tests.txt
post:
- pyenv local 3.4.3 2.7.10

test:
override:
- pip install -r requirements-tests.txt
- flake8 .
- isort --recursive --check-only .
- python setup.py check -s --restructuredtext
- python setup.py test
- tox

deployment:
production:
Expand Down
49 changes: 46 additions & 3 deletions docs/custom_sockets/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
author:
name: Sebastian
email: sebastian@syncano.com
config:
constants:
secret_key: value
prompt:
user_key:
type: string
description: A Syncano user key
icon:
name: icon_name
color: red
Expand Down Expand Up @@ -34,6 +41,20 @@
runtime_name: python_library_v5.0
file: scripts/script3.py

classes:
country:
schema:
- name: name
type: string
- name: topLevelDomain
type: string
- name: capital
type: string
- name: alpha2Code
type: string
- name: alpha3Code
type: string

### YAML file structure explanation

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

Consider this example:

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

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

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

Above YAML snippet defines one dependency:
Above YAML snippet defines four dependencies (three of type `script` and one of type `class`):
* `script` - type of the dependency (defined using `scripts` keyword).
* `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.
* `runtime_name` is name of the runtime used in a script;
Expand All @@ -99,6 +122,26 @@ which will be called when the endpoint is requested.
It should be noted that when defining Custom Scripts, we suggest following some basic directory structure- for
better work organization. We recommend storing scripts under the `scripts` directory - this is why the filename
is a relative path: `scripts/script1.py`. Of course your can also follow your own rules, e.g. by using a flat file structure.

The class dependency looks as follows:

classes:
country:
schema:
- name: name
type: string
- name: topLevelDomain
type: string
- name: capital
type: string
- name: alpha2Code
type: string
- name: alpha3Code
type: string

This simple mean that Custom Socket requires a class `country` to work properly. Under the hood - Syncano Platform
will check if this class exists (if not - create it) and ensure that all required files defined in `schema` are present.



## Custom Socket directory structure
Expand Down
1 change: 1 addition & 0 deletions requirements-tests.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
tox==2.3.1
flake8==2.4.1
isort==4.0.0
mock==1.3.0
Expand Down
8 changes: 8 additions & 0 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -e

flake8 .
isort --recursive --check-only .

python setup.py test
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

setup(
name='syncano-cli',
version='0.7',
version='0.8',
description='Syncano command line utilities',
long_description=README,
author='Marcin Swiderski, Sebastian Opalczynski',
author_email='marcin.swiderski@syncano.com, sebastian.opalczynski@syncano.com',
url='https://github.com/Syncano/syncano-cli',
packages=find_packages(),
license='MIT',
install_requires=['syncano>=5.4.2', 'PyYaml>=3.11', 'watchdog>=0.8.3', 'click>=6.6'],
install_requires=['syncano>=5.4.4', 'PyYaml>=3.11', 'watchdog>=0.8.3', 'click>=6.6'],
test_suite='tests',
entry_points="""
[console_scripts]
Expand Down
6 changes: 3 additions & 3 deletions syncano_cli/account/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def __init__(self, config_path):
self.connection = syncano.connect()
self.config_path = config_path

def register(self, email, password, first_name, last_name, invitation_key):
def register(self, email, password, first_name=None, last_name=None, invitation_key=None):
api_key = self.connection.connection().register(
email=email,
password=password,
Expand All @@ -19,6 +19,6 @@ def register(self, email, password, first_name, last_name, invitation_key):
invitation_key=invitation_key
)

ACCOUNT_CONFIG.set('DEFAULT', 'api_key', api_key)
with open(self.config_path, 'wb') as fp:
ACCOUNT_CONFIG.set('DEFAULT', 'key', api_key)
with open(self.config_path, 'wt') as fp:
ACCOUNT_CONFIG.write(fp)
4 changes: 1 addition & 3 deletions syncano_cli/account/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ def top_account():
@click.pass_context
@click.option('--config', help=u'Account configuration file.')
def accounts(ctx, config):
"""
Handle Syncano account functionality;
"""
"""Handle Syncano account functionality."""
account_commands = AccountCommands(config_path=config or ACCOUNT_CONFIG_PATH)
ctx.obj['account_commands'] = account_commands

Expand Down
10 changes: 8 additions & 2 deletions syncano_cli/base/connection.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# -*- coding: utf-8 -*-
from ConfigParser import NoOptionError, NoSectionError

import six
import syncano
from syncano.exceptions import SyncanoException
from syncano_cli.base.exceptions import BadCredentialsException, InstanceNotFoundException
from syncano_cli.config import ACCOUNT_CONFIG, ACCOUNT_CONFIG_PATH

if six.PY2:
from ConfigParser import NoOptionError, NoSectionError
elif six.PY3:
from configparser import NoOptionError, NoSectionError
else:
raise ImportError()


def get_instance_name(config, instance_name):
ACCOUNT_CONFIG.read(config)
Expand Down
4 changes: 2 additions & 2 deletions syncano_cli/base/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ class JSONParseException(CLIBaseException):


class BadCredentialsException(CLIBaseException):
default_message = u'Wrong credential provided when login.'
default_message = u'Wrong login credentials provided.'


class NotLoggedInException(CLIBaseException):
default_message = u'Do a login first: `syncano login`.'
default_message = u'Please log in to your account: `syncano login`.'


class InstanceNotFoundException(CLIBaseException):
Expand Down
5 changes: 2 additions & 3 deletions syncano_cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ def top_level():
@click.option('--instance-name', help=u'Default instance name.')
def login(context, config, instance_name):
"""
Log in to syncano using email and password and store ACCOUNT_KEY
in configuration file.
Log in to syncano using email and password.
"""
config = config or ACCOUNT_CONFIG_PATH
context.obj['config'] = config
Expand All @@ -33,7 +32,7 @@ def login(context, config, instance_name):
ACCOUNT_CONFIG.set('DEFAULT', 'key', ACCOUNT_KEY)
if instance_name:
ACCOUNT_CONFIG.set('DEFAULT', 'instance_name', instance_name)
with open(context.obj['config'], 'wb') as fp:
with open(context.obj['config'], 'wt') as fp:
ACCOUNT_CONFIG.write(fp)
click.echo("INFO: Login successful.")
except SyncanoException:
Expand Down
10 changes: 9 additions & 1 deletion syncano_cli/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# -*- coding: UTF=8 -*-

import os
from ConfigParser import ConfigParser

import six

if six.PY2:
from ConfigParser import ConfigParser
elif six.PY3:
from configparser import ConfigParser
else:
raise ImportError()

ACCOUNT_CONFIG_PATH = os.path.join(os.path.expanduser('~'), '.syncano')
ACCOUNT_CONFIG = ConfigParser()
4 changes: 4 additions & 0 deletions syncano_cli/config_commands/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def top_config():
@click.option('--config', help=u'Account configuration file.')
@click.option('--instance-name', help=u'Instance name.')
def config(ctx, config, instance_name):
"""Allow to manage global instance config."""
instance = get_instance(config, instance_name)
config_command = ConfigCommand(instance=instance)
ctx.obj['config_command'] = config_command
Expand All @@ -27,6 +28,7 @@ def config(ctx, config, instance_name):
@click.argument('name')
@click.argument('value')
def add(ctx, name, value):
"""Add config variable to global instance config."""
config_command = ctx.obj['config_command']
config_command.add(name, value)

Expand All @@ -36,6 +38,7 @@ def add(ctx, name, value):
@click.argument('name')
@click.argument('value')
def modify(ctx, name, value):
"""Modify config value in global instance config."""
config_command = ctx.obj['config_command']
config_command.modify(name, value)

Expand All @@ -44,5 +47,6 @@ def modify(ctx, name, value):
@click.pass_context
@click.argument('name')
def delete(ctx, name):
"""Removes config value from global instance config."""
config_command = ctx.obj['config_command']
config_command.delete(name)
Loading