# Path: syncano_cli/base/command.py
# class BaseInstanceCommand(BaseCommand):
#     """Command for Instance based commands: fetch data from an instance."""
#     def set_instance(self, instance_name):
#         self._set_instance(instance_name)
# 
#     def _set_instance(self, instance_name):
#         self.instance = get_instance(self.config_path, instance_name)
# 
# Path: syncano_cli/base/data_parser.py
# def parse_input_data(data):
#     data_object = {}
#     for item in data:
#         if '=' not in item:
#             raise DataParseException()
#         key, value = item.split('=')
#         data_object[key.strip()] = value.strip()
#     return data_object
# 
# Path: syncano_cli/base/options.py
# class BottomSpacedOpt(OptionsBase):
#     OPTIONS = ['space_bottom']
# 
#     def __init__(self, space_bottom=True, **kwargs):
#         super(BottomSpacedOpt, self).__init__(space_bottom=space_bottom, **kwargs)
# 
# class DefaultOpt(OptionsBase):
#     color = ColorSchema.INFO
#     indent = 1
#     space_top = False
#     space_bottom = False
# 
# class SpacedOpt(OptionsBase):
#     OPTIONS = ['space_top', 'space_bottom']
# 
#     def __init__(self, space_top=True, space_bottom=True, **kwargs):
#         super(SpacedOpt, self).__init__(space_top=space_top, space_bottom=space_bottom, **kwargs)
# 
# class WarningOpt(OptionsBase):
#     OPTIONS = ['color']
# 
#     def __init__(self, color=ColorSchema.WARNING, **kwargs):
#         super(WarningOpt, self).__init__(color=color, **kwargs)


import json
import six
from syncano_cli.base.command import BaseInstanceCommand
from syncano_cli.base.data_parser import parse_input_data
from syncano_cli.base.options import BottomSpacedOpt, DefaultOpt, SpacedOpt, WarningOpt
# -*- coding: utf-8 -*-



class ExecuteCommand(BaseInstanceCommand):

    def execute(self, script_endpoint_name, data):
        se = self.instance.script_endpoints.get(name=script_endpoint_name)
        data = parse_input_data(data)
        response = se.run(**data)

# Path: syncano_cli/base/command.py
# class BaseInstanceCommand(BaseCommand):
#     """Command for Instance based commands: fetch data from an instance."""
#     def set_instance(self, instance_name):
#         self._set_instance(instance_name)
# 
#     def _set_instance(self, instance_name):
#         self.instance = get_instance(self.config_path, instance_name)
# 
# Path: syncano_cli/base/data_parser.py
# def parse_input_data(data):
#     data_object = {}
#     for item in data:
#         if '=' not in item:
#             raise DataParseException()
#         key, value = item.split('=')
#         data_object[key.strip()] = value.strip()
#     return data_object
# 
# Path: syncano_cli/base/options.py
# class BottomSpacedOpt(OptionsBase):
#     OPTIONS = ['space_bottom']
# 
#     def __init__(self, space_bottom=True, **kwargs):
#         super(BottomSpacedOpt, self).__init__(space_bottom=space_bottom, **kwargs)
# 
# class DefaultOpt(OptionsBase):
#     color = ColorSchema.INFO
#     indent = 1
#     space_top = False
#     space_bottom = False
# 
# class SpacedOpt(OptionsBase):
#     OPTIONS = ['space_top', 'space_bottom']
# 
#     def __init__(self, space_top=True, space_bottom=True, **kwargs):
#         super(SpacedOpt, self).__init__(space_top=space_top, space_bottom=space_bottom, **kwargs)
# 
# class WarningOpt(OptionsBase):
#     OPTIONS = ['color']
# 
#     def __init__(self, color=ColorSchema.WARNING, **kwargs):
#         super(WarningOpt, self).__init__(color=color, **kwargs)


# Path: syncano_cli/execute/command.py
import json
import six
from syncano_cli.base.command import BaseInstanceCommand
from syncano_cli.base.data_parser import parse_input_data
from syncano_cli.base.options import BottomSpacedOpt, DefaultOpt, SpacedOpt, WarningOpt

# -*- coding: utf-8 -*-



class ExecuteCommand(BaseInstanceCommand):

    def execute(self, script_endpoint_name, data):
        se = self.instance.script_endpoints.get(name=script_endpoint_name)
        data = parse_input_data(data)
        response = se.run(**data)

        self.formatter.write('The result of the Script `{}` run is:'.format(script_endpoint_name), SpacedOpt())