2

I've been tasked with building a command line tool that we will be providing to our enterprise customers so that they can use the API to upload data to our platform. The API works with standard cURL requests, so I can do most of the basic functionality with simple bash scripting, although I would like to provide something that is solid and really makes it easy for them to use and I don't know what I don't know. It's been a good 8 years since I've really done any serious sysadmin work.

Most of the good tools I use these days are written in Ruby or Python and have a standard distribution process (Gems, for example). However, I know rhel and other platforms have their own package managers.

Finally, the question: In today's day and age, what language / distribution method should I consider in order to cover the widest range of platforms without having to build completely different versions for each platform?

I'd also love any general feedback you have about building similar projects, or links to projects that you think do a good job of this now and have open source code that I could read.

Thanks in advance!

Jeremy Baker
  • 131
  • 4
  • Jeremy, your question scope is too broad and solicits architecture and solution design responses which we tend to stay away from because we don't know your requirements well enough. Can you re-phrase your question to discuss a specific idea or problem with a specific tech? – Brent Pabst Nov 12 '12 at 21:10
  • Thanks Brent, I'll try to come up with a more succinct question. In the mean time, should I remove this question or just revise it? – Jeremy Baker Nov 13 '12 at 20:59
  • Jeremy, you can always revise a question. Questions need 5 votes to be closed by the community, yours has 4. It's possible it may be closed as written so the sooner you can revise it the better. If it does get closed you can still edit it and then flag it for a moderator to reopen. If you have any specific questions about the best way to ask a question use meta.serverfault.com or drop into the chat room, I'm not sure you have enough rep for chat yet though. – Brent Pabst Nov 14 '12 at 13:43

1 Answers1

1

Well, your question is quite broad, but I have been writing sysadmin tools in python for the past year. So since you are requesting general feedback, here are some things I encountered.

You can use urllib2 to write your curl request in pure python code. If you only need some basic REST requests, you can look at requests or any other python REST client.

If you need to support rhel 5 (as I do) you will not be able to use anything that's in python > 2.4

For distribution: You can use setuptools All you need to do is create a setup.py script which tells setuptools how to do the installation. You can then upload a tarball to pypi

After this, your customers can install your tools with :

easy_install toolname

or

pip toolname

easy_install or pip will then download the tarball from pypi, and perform the instructions in the setup.py script.

Alternatively, if you want to distribute to enterprise servers, you can now also very easily create rpms:

python setup.py bdist_rpm

This will use yout setup.py and create an rpm out of it, the same should be possible for .deb's (with some extra bdist plugins)

I work at the Ghent University, and we have open sourced some of the python tools/libraries we have written, e.g., you will probably start with parsing command line arguments, we have written generaloption.py which extends the basic python 2.4 optionparser, and gives it a few cool new options. (e.g., allows you to overwrite any command line option with an environment variable by default) Also an extended logger called fancylogger.py

You can look around in that repository to look at some other things that might help writing sysadmin scripts under python 2.4

Jens Timmerman
  • 866
  • 4
  • 10