Tag Archives: Python

chef knife tricks: Add a node in an environment

  Sometime during automation of a large deployment process, we have to bootstrap a node , create environment and add the node in that particular environment on the fly.   Bootstraping : 2. Create environment dynamically from inside the programme:(python … Continue reading

Posted in ARTICLES, Configurtion management, DevOps, HOWTO, Programming | Tagged , , , | Leave a comment

Python : Inplace update json and maintain proper order

Some time we have to read one existing json property file and  update some values inplace. If we don’t use proper approach, the update may lead to breaking the json structure in the file. We have to hook the json … Continue reading

Posted in ARTICLES, DevOps, Programming, SCRIPTING, TIPS & T RICS | Tagged , , , | Leave a comment

Using optparse in python

Sometimes we have to create tools that takes input as argument with certain options. We can create such tool with optparse module of python. Here is a small example of using this.   For help, type: ( This will display all … Continue reading

Posted in ARTICLES, DevOps, HOWTO, Programming, TIPS & T RICS | Tagged , , | Leave a comment

Send mail using Python’s smtplib module

Python has a built in module to send mail to recipient[s] as to,cc,bcc. Here assumption is that : the smtp is configured in localhost (where the script will run).      

Posted in ARTICLES, DevOps, HOWTO, Programming, SCRIPTING, TIPS & T RICS | Tagged , , , | Leave a comment

Change tab width in vim

By default, inside vim the tab width is 8 spaces, we can reduce it using below steps. Create a .vimrc file in ~(home dir) and add below content.  Save it and now try. filetype plugin indent on ” show existing … Continue reading

Posted in SCRIPTING, TIPS & T RICS, Uncategorized | Tagged , , | Leave a comment

Creating simple progress bar in shell / Python

Progressbar indicates if certain tasks are getting executed and when they completed. In bash oneliner: printf “Starting [“;for num in $(seq 50);do printf “#”;sleep 0.5;done;printf “] Successfull” In Python: sys.stdout.write(“Starting Operation[“) for d in range(60): sys.stdout.write(‘#’) sys.stdout.flush() time.sleep(0.50) sys.stdout.write(“]Stoping Operation”) … Continue reading

Posted in HOWTO, Programming, SCRIPTING, TIPS & T RICS, TUTORIALS, Uncategorized | Tagged , , | Leave a comment

Read and write json in python

In todays  world json is one of the easiest method of communication to exchange data. Its used everywhere Cloud APIs, Databases, Configuration files, REST Call. So below are the steps how to read and write back to a json file … Continue reading

Posted in ARTICLES, HOWTO, Programming, SCRIPTING, TIPS & T RICS, TUTORIALS, Uncategorized | Tagged , , | Leave a comment