Hi,

I came up with this structure after studying the needs.

Main.py, CLI.py and Stratos.py would be same as of our previous
discussions.

Configs.py would hold configurations, etc. It would be like
the CliConstants.java and  holds the default Stratos directory, Stratos
prompt string, etc. And it is reading the environment variables, like
username, password, etc.

Logging.py would handle everything about logging. Setting the logging file,
creating the logging file's directory if not exists, and setting logging
level etc.

Utils.py would hold the utility methods. Currently it holds codes for
pretty printing of tables and trees.

[image: Inline image 1]


I pushed my commits to my fork. (
https://github.com/agentmilindu/stratos/tree/python-cli/components/org.apache.stratos.python.cli/src/main/python/cli
 )

I have some questions,

All the requests sent to Stratos needs an username and a password for
authentications, right? I was thinking if I can create a python decorator (
maybe as @auth ) to check if the username  and password  is known before
sending the request.

@auth
def do_deploy_service(self, line , opts=None):
  #codes of the deploy_service def

where @auth checks either,
if the opts list contains username and password,
else if environment variables are set for username and password.

Reason is, if we have to do a change in the username and password checking
logic, then we have to change only one place.
What you think about this approach?
Is there any way keeping a session like, if one successfully authenticated
request got a response, the subsequent requests need not to have to reenter
the username/password ?

I have to add a POM to the Python CLI component. What I should include in
it?

I think our foundation parts are done now. We have to start coding the each
actions.
I will send my first pull request once we are done with the above :)


On Sun, May 10, 2015 at 10:32 PM, Chamila De Alwis <chami...@wso2.com>
wrote:

> Hi Milindu,
>
> We should always log enough information to a log file. In fact,* .stratos*
> folder in the Java CLI is used to store the *stratos-cli.log* file. INFO
> level logs should be used to log important messages, while DEBUG level
> should be verbose enough to pinpoint an error.
>
> The other use of the* .stratos* folder is to store the command history.
> You can verify this by checking the files in ~/.stratos folder.
>
>
>
>
> Regards,
> Chamila de Alwis
> Software Engineer | WSO2 | +94772207163
> Blog: code.chamiladealwis.com
>
>
>
> On Sun, May 10, 2015 at 9:26 PM, Milindu Sanoj Kumarage <
> agentmili...@gmail.com> wrote:
>
>> Hi,
>>
>> Thanks Chamila, I will update the setup.py with these info.
>> I too taught of using 'stratos-cli' first, but doubted you wouldn't like
>> that because the user has to type this when working with Single Command
>> Line Mode. But if you think that would not be a problem, then let's change
>> that as 'stratos-cli' :)
>>
>> Thanks Imesh, I will update the name as StratosApiClient then.
>>
>> I have few more questions,
>>
>> 1. We have to do logging, right? Log important events always ( to a file?
>> ) or log only in debug mode ( directly to the cmd? )?
>> 2. I saw Java CLI  creating a  dir named '.stratos', for what that dir
>> is used to?
>>
>>
>>
>> On Sat, May 9, 2015 at 10:16 PM, Imesh Gunaratne <im...@apache.org>
>> wrote:
>>
>>> Hi Milindu,
>>>
>>> On Sat, May 9, 2015 at 9:37 PM, Milindu Sanoj Kumarage <
>>> agentmili...@gmail.com> wrote:
>>>>
>>>>
>>>> 1. Main.py - This contains the entry point, it does the initializing
>>>> parts, creates a CLI instance and runs the loop and other stuffs.
>>>>
>>> +1
>>>
>>>>
>>>> 2. CLI.py - This is the actual CLI that extends Cmd2. This contains the
>>>> command to def mappings, argument and flag handling, printing outputs, etc.
>>>>
>>> +1
>>>
>>>>
>>>> 3. Stratos.py - This contains the actual business logic, that is, which
>>>> REST end point to call, and do what with the response, what to show, what
>>>> not, etc. At the end, this would be like a Python API for Stratos in a way.
>>>>
>>>> IMO Stratos is too generic for a class name. Shall we rename this to
>>> something like StratosApiClient?
>>>
>>> Thanks
>>>
>>> --
>>> Imesh Gunaratne
>>>
>>> Senior Technical Lead, WSO2
>>> Committer & PMC Member, Apache Stratos
>>>
>>
>>
>

Reply via email to