Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78883 > unrolled thread
| Started by | vijnaana@gmail.com |
|---|---|
| First post | 2014-10-09 05:20 -0700 |
| Last post | 2014-10-15 09:05 -0700 |
| Articles | 11 — 9 participants |
Back to article view | Back to comp.lang.python
CLI framework using python vijnaana@gmail.com - 2014-10-09 05:20 -0700
Re: CLI framework using python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-10-09 09:07 -0400
Re: CLI framework using python Unix SA <d.joshi84@gmail.com> - 2014-10-09 20:55 +0530
Re: CLI framework using python Gelonida N <gelonida@gmail.com> - 2014-10-09 18:00 +0200
Re: CLI framework using python Rustom Mody <rustompmody@gmail.com> - 2014-10-10 01:43 -0700
Re: CLI framework using python Gelonida N <gelonida@gmail.com> - 2014-10-10 13:58 +0200
Re: CLI framework using python Python UL <python@rgbaz.eu> - 2014-10-09 18:08 +0200
Re: CLI framework using python vijnaana bhairava <vijnaana@gmail.com> - 2014-10-14 06:33 -0700
Re: CLI framework using python Chris Angelico <rosuav@gmail.com> - 2014-10-15 00:43 +1100
Re: CLI framework using python "Naoki INADA" <songofacandy@gmail.com> - 2014-10-14 07:15 -0700
Re: CLI framework using python vijnaana bhairava <vijnaana@gmail.com> - 2014-10-15 09:05 -0700
| From | vijnaana@gmail.com |
|---|---|
| Date | 2014-10-09 05:20 -0700 |
| Subject | CLI framework using python |
| Message-ID | <274771d2-4a11-40fe-bc31-ccfaa7d32690@googlegroups.com> |
Hi, I need to develop a python CLI framework. For example if i need to set an ip address in linux: ifconfig eth0 172.16.25.125 I should be able to use python to do the above. 1. The user will execute a python script to which i will pass the params eth0 and ip address (something like ifconf.py eth0 172.16.25.125) 2. Within the script i grab the params and do something to the effect of user executing 'ifconfig eth0 172.16.25.125' from the shell. 3. There are other such commands for which i will be using python scripts. I came across pyCLI, but it doesn't have much documentation, so couldn't figure out how to move forward. 4. The CLI framework needs to reuse code so i didn't want to use pure python and develop a framework from scratch. Rather use something like pyCLI/CLIFF. The problem is lack of documentation with examples on how to use the above. Any guidance would be greatly appreciated. Regards & Thanks, Vij
[toc] | [next] | [standalone]
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2014-10-09 09:07 -0400 |
| Message-ID | <mailman.14714.1412860100.18130.python-list@python.org> |
| In reply to | #78883 |
On Thu, 9 Oct 2014 05:20:34 -0700 (PDT), vijnaana@gmail.com declaimed the
following:
>Hi,
>
>I need to develop a python CLI framework.
>
>For example if i need to set an ip address in linux:
>
>ifconfig eth0 172.16.25.125
>
>I should be able to use python to do the above.
>
>1. The user will execute a python script to which i will pass the params eth0 and ip address (something like ifconf.py eth0 172.16.25.125)
>
>2. Within the script i grab the params and do something to the effect of user executing 'ifconfig eth0 172.16.25.125' from the shell.
>
Which will most likely turn into something like (quick&dirty version)
os.system("ifconfig %s %s" % (userDevice, userIP))
>3. There are other such commands for which i will be using python scripts. I came across pyCLI, but it doesn't have much documentation, so couldn't figure out how to move forward.
>
Unless you intend to implement those commands internally, all you are
creating is a command line parser that spawns out to a hidden shell to
actually execute the native command executable...
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
[toc] | [prev] | [next] | [standalone]
| From | Unix SA <d.joshi84@gmail.com> |
|---|---|
| Date | 2014-10-09 20:55 +0530 |
| Message-ID | <mailman.14717.1412868348.18130.python-list@python.org> |
| In reply to | #78883 |
[Multipart message — attachments visible in raw view] — view raw
Hello, Go for Optparse.. Look at below docs on how to use it. http://pymotw.com/2/optparse/ Regards, DJ On Thu, Oct 9, 2014 at 5:50 PM, <vijnaana@gmail.com> wrote: > Hi, > > I need to develop a python CLI framework. > > For example if i need to set an ip address in linux: > > ifconfig eth0 172.16.25.125 > > I should be able to use python to do the above. > > 1. The user will execute a python script to which i will pass the params > eth0 and ip address (something like ifconf.py eth0 172.16.25.125) > > 2. Within the script i grab the params and do something to the effect of > user executing 'ifconfig eth0 172.16.25.125' from the shell. > > 3. There are other such commands for which i will be using python scripts. > I came across pyCLI, but it doesn't have much documentation, so couldn't > figure out how to move forward. > > 4. The CLI framework needs to reuse code so i didn't want to use pure > python and develop a framework from scratch. Rather use something like > pyCLI/CLIFF. > > The problem is lack of documentation with examples on how to use the above. > > Any guidance would be greatly appreciated. > > Regards & Thanks, > Vij > > -- > https://mail.python.org/mailman/listinfo/python-list >
[toc] | [prev] | [next] | [standalone]
| From | Gelonida N <gelonida@gmail.com> |
|---|---|
| Date | 2014-10-09 18:00 +0200 |
| Message-ID | <mailman.14720.1412870470.18130.python-list@python.org> |
| In reply to | #78883 |
On 10/09/2014 05:25 PM, Unix SA wrote: > Hello, > > Go for Optparse.. Look at below docs on how to use it. > > http://pymotw.com/2/optparse/ > For newer projects I'd suggest argparse (part of Python since 2.7 and can be downloaded / installed for 2.5 / 2.6). https://docs.python.org/2.7/library/argparse.html argparse is very powerfull. you might be interested in looking at subparsers. For calling commands in a slightly nicer way than os.system / sybprocess.Popen you might look at sh or plumbum https://pypi.python.org/pypi/sh https://pypi.python.org/pypi/plumbum > Regards, > DJ > > On Thu, Oct 9, 2014 at 5:50 PM, <vijnaana@gmail.com > <mailto:vijnaana@gmail.com>> wrote: > > Hi, > > I need to develop a python CLI framework. > > For example if i need to set an ip address in linux: > > ifconfig eth0 172.16.25.125 > > I should be able to use python to do the above. > > 1. The user will execute a python script to which i will pass the > params eth0 and ip address (something like ifconf.py eth0 > 172.16.25.125) > > 2. Within the script i grab the params and do something to the > effect of user executing 'ifconfig eth0 172.16.25.125' from the shell. > > 3. There are other such commands for which i will be using python > scripts. I came across pyCLI, but it doesn't have much > documentation, so couldn't figure out how to move forward. > > 4. The CLI framework needs to reuse code so i didn't want to use > pure python and develop a framework from scratch. Rather use > something like pyCLI/CLIFF. > > The problem is lack of documentation with examples on how to use the > above. > > Any guidance would be greatly appreciated. > > Regards & Thanks, > Vij > > -- > https://mail.python.org/mailman/listinfo/python-list > > > >
[toc] | [prev] | [next] | [standalone]
| From | Rustom Mody <rustompmody@gmail.com> |
|---|---|
| Date | 2014-10-10 01:43 -0700 |
| Message-ID | <90907ef5-275d-4f24-bffb-bb97e7c3f051@googlegroups.com> |
| In reply to | #78900 |
On Thursday, October 9, 2014 9:31:39 PM UTC+5:30, gelonida wrote: > For calling commands in a slightly nicer way than os.system / > sybprocess.Popen you might look at sh or plumbum > https://pypi.python.org/pypi/sh > https://pypi.python.org/pypi/plumbum Both of these look quite nice! [Im looking at them from a couple of angles 1. Using python as a scripting language 2. Notion of DSL ] Can you tell me in short whats the difference??
[toc] | [prev] | [next] | [standalone]
| From | Gelonida N <gelonida@gmail.com> |
|---|---|
| Date | 2014-10-10 13:58 +0200 |
| Message-ID | <mailman.14751.1412942303.18130.python-list@python.org> |
| In reply to | #78937 |
On 10/10/2014 10:43 AM, Rustom Mody wrote: > On Thursday, October 9, 2014 9:31:39 PM UTC+5:30, gelonida wrote: > >> For calling commands in a slightly nicer way than os.system / >> sybprocess.Popen you might look at sh or plumbum > >> https://pypi.python.org/pypi/sh > >> https://pypi.python.org/pypi/plumbum > > Both of these look quite nice! > [Im looking at them from a couple of angles > 1. Using python as a scripting language > 2. Notion of DSL > ] > > Can you tell me in short whats the difference?? > Not really, both are quite new to me as well. On a first glanced I prefered sh However: plumbum works also on Windows systems. As I have to write some code for Windows, some code for Linux and some code for both platforms I think plumbum might be nicer as I can stick to one syntax. So far I used both of them just in very tiny scripts. Most of my code still uses subprocess.Popen or my own clumsy wrappers around it.
[toc] | [prev] | [next] | [standalone]
| From | Python UL <python@rgbaz.eu> |
|---|---|
| Date | 2014-10-09 18:08 +0200 |
| Message-ID | <mailman.14722.1412871481.18130.python-list@python.org> |
| In reply to | #78883 |
On 09-10-14 14:20, vijnaana@gmail.com wrote: > Hi, > > I need to develop a python CLI framework. > > For example if i need to set an ip address in linux: > > ifconfig eth0 172.16.25.125 > > I should be able to use python to do the above. > > 1. The user will execute a python script to which i will pass the params eth0 and ip address (something like ifconf.py eth0 172.16.25.125) > > 2. Within the script i grab the params and do something to the effect of user executing 'ifconfig eth0 172.16.25.125' from the shell. > > 3. There are other such commands for which i will be using python scripts. I came across pyCLI, but it doesn't have much documentation, so couldn't figure out how to move forward. > > 4. The CLI framework needs to reuse code so i didn't want to use pure python and develop a framework from scratch. Rather use something like pyCLI/CLIFF. > > The problem is lack of documentation with examples on how to use the above. > > Any guidance would be greatly appreciated. > > Regards & Thanks, > Vij > Hi Vij Maybe you can have a look at iPython: http://ipython.org/ipython-doc/stable/interactive/tutorial.html gr Arno
[toc] | [prev] | [next] | [standalone]
| From | vijnaana bhairava <vijnaana@gmail.com> |
|---|---|
| Date | 2014-10-14 06:33 -0700 |
| Message-ID | <c92a2d2c-d63b-47e5-a059-289f0ad209aa@googlegroups.com> |
| In reply to | #78883 |
Hi Folks, The requirement is to develop a CLI framework in python for a linux router. The suggestions i got is to use PyCli/Cliff. Not sure which would be the right choice! Also, a few APIs are mentioned here: https://pythonhosted.org/pyCLI/#module-cli.app Since i couldn't find any actual implementation which uses pyCli, i can't figure out how to make use of pyCLI. Another question i have is whether it uses argparse? If so, what value add does PYCLI do? Regards, vij On Thursday, October 9, 2014 5:50:51 PM UTC+5:30, vijnaana bhairava wrote: > Hi, > > > > I need to develop a python CLI framework. > > > > For example if i need to set an ip address in linux: > > > > ifconfig eth0 172.16.25.125 > > > > I should be able to use python to do the above. > > > > 1. The user will execute a python script to which i will pass the params eth0 and ip address (something like ifconf.py eth0 172.16.25.125) > > > > 2. Within the script i grab the params and do something to the effect of user executing 'ifconfig eth0 172.16.25.125' from the shell. > > > > 3. There are other such commands for which i will be using python scripts. I came across pyCLI, but it doesn't have much documentation, so couldn't figure out how to move forward. > > > > 4. The CLI framework needs to reuse code so i didn't want to use pure python and develop a framework from scratch. Rather use something like pyCLI/CLIFF. > > > > The problem is lack of documentation with examples on how to use the above. > > > > Any guidance would be greatly appreciated. > > > > Regards & Thanks, > > Vij
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-10-15 00:43 +1100 |
| Message-ID | <mailman.14847.1413294198.18130.python-list@python.org> |
| In reply to | #79091 |
On Wed, Oct 15, 2014 at 12:33 AM, vijnaana bhairava <vijnaana@gmail.com> wrote: > Another question i have is whether it uses argparse? > If so, what value add does PYCLI do? It depends what you mean by "CLI framework". If you simply mean something like hg, where you have subcommands and options and so on, all you really need is argument parsing. Take the simplest possible solution and run with it! ChrisA
[toc] | [prev] | [next] | [standalone]
| From | "Naoki INADA" <songofacandy@gmail.com> |
|---|---|
| Date | 2014-10-14 07:15 -0700 |
| Message-ID | <mailman.14849.1413296144.18130.python-list@python.org> |
| In reply to | #79091 |
[Multipart message — attachments visible in raw view] — view raw
Click_ is another CLI framework. It support multi-level nested command like git and it has some nice utilities. I love it's design. .. _click: http://click.pocoo.org/3/ — Sent from Mailbox On Tue, Oct 14, 2014 at 10:35 PM, vijnaana bhairava <vijnaana@gmail.com> wrote: > Hi Folks, > The requirement is to develop a CLI framework in python for a linux router. > The suggestions i got is to use PyCli/Cliff. Not sure which would be the right choice! Also, a few APIs are mentioned here: > https://pythonhosted.org/pyCLI/#module-cli.app > Since i couldn't find any actual implementation which uses pyCli, > i can't figure out how to make use of pyCLI. > Another question i have is whether it uses argparse? > If so, what value add does PYCLI do? > Regards, > vij > On Thursday, October 9, 2014 5:50:51 PM UTC+5:30, vijnaana bhairava wrote: >> Hi, >> >> >> >> I need to develop a python CLI framework. >> >> >> >> For example if i need to set an ip address in linux: >> >> >> >> ifconfig eth0 172.16.25.125 >> >> >> >> I should be able to use python to do the above. >> >> >> >> 1. The user will execute a python script to which i will pass the params eth0 and ip address (something like ifconf.py eth0 172.16.25.125) >> >> >> >> 2. Within the script i grab the params and do something to the effect of user executing 'ifconfig eth0 172.16.25.125' from the shell. >> >> >> >> 3. There are other such commands for which i will be using python scripts. I came across pyCLI, but it doesn't have much documentation, so couldn't figure out how to move forward. >> >> >> >> 4. The CLI framework needs to reuse code so i didn't want to use pure python and develop a framework from scratch. Rather use something like pyCLI/CLIFF. >> >> >> >> The problem is lack of documentation with examples on how to use the above. >> >> >> >> Any guidance would be greatly appreciated. >> >> >> >> Regards & Thanks, >> >> Vij > -- > https://mail.python.org/mailman/listinfo/python-list
[toc] | [prev] | [next] | [standalone]
| From | vijnaana bhairava <vijnaana@gmail.com> |
|---|---|
| Date | 2014-10-15 09:05 -0700 |
| Message-ID | <dc562725-9779-4042-a72d-bae28e444628@googlegroups.com> |
| In reply to | #79097 |
Hi Naoki, I am new to python programming. Getting used to writing basic scripts to understand python. To understand 'Click' i may need some more guidance. For e.g if i were to do 'ifconfig -a' from Click, how would the program look like. That will help me get started. What i am looking for is a class based approach. For e.g all interface related commands could come under class Interface and 'ifconfig' would probably be a method. I would like to see one working program to get a feel for 'Click' Thank You! vij On Tuesday, October 14, 2014 7:46:44 PM UTC+5:30, INADA Naoki wrote: > Click_ is another CLI framework. > > It support multi-level nested command like git and it has some nice utilities. > > I love it's design. > > > > > > > > .. _click: http://click.pocoo.org/3/ > > > > -- > Sent from Mailbox > > > > > > On Tue, Oct 14, 2014 at 10:35 PM, vijnaana bhairava <vijn...@gmail.com> wrote: > > Hi Folks, > > > The requirement is to develop a CLI framework in python for a linux router. > > The suggestions i got is to use PyCli/Cliff. Not sure which would be the right choice! Also, a few APIs are mentioned here: > > > https://pythonhosted.org/pyCLI/#module-cli.app > > > Since i couldn't find any actual implementation which uses pyCli, > > i can't figure out how to make use of pyCLI. > > > Another question i have is whether it uses argparse? > > If so, what value add does PYCLI do? > > > Regards, > > vij > > > On Thursday, October 9, 2014 5:50:51 PM UTC+5:30, vijnaana bhairava wrote: > > > Hi, > > > > > > > > > > > > I need to develop a python CLI framework. > > > > > > > > > > > > For example if i need to set an ip address in linux: > > > > > > > > > > > > ifconfig eth0 172.16.25.125 > > > > > > > > > > > > I should be able to use python to do the above. > > > > > > > > > > > > 1. The user will execute a python script to which i will pass the params eth0 and ip address (something like ifconf.py eth0 172.16.25.125) > > > > > > > > > > > > 2. Within the script i grab the params and do something to the effect of user executing 'ifconfig eth0 172.16.25.125' from the shell. > > > > > > > > > > > > 3. There are other such commands for which i will be using python scripts. I came across pyCLI, but it doesn't have much documentation, so couldn't figure out how to move forward. > > > > > > > > > > > > 4. The CLI framework needs to reuse code so i didn't want to use pure python and develop a framework from scratch. Rather use something like pyCLI/CLIFF. > > > > > > > > > > > > The problem is lack of documentation with examples on how to use the above. > > > > > > > > > > > > Any guidance would be greatly appreciated. > > > > > > > > > > > > Regards & Thanks, > > > > > > Vij > > -- > > https://mail.python.org/mailman/listinfo/python-list
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web