Search

29 May, 2018

SVN commands you must know as an Test Automation Engineer


In the course of automation and continuous integration , you will someday come across a stage where you have to perform svn operations . And obviously, using command line (forget fancy UIs to do your business) using command line. And then you will have to start digging in,  which will take a substantial amount time ...believe me.

25 May, 2018

How to use argparse module to create command line tools with Python?



Its been decades I have been using sys.argv for simple tasks related to argument parsing. But the thing is, sometimes we don't realize how good something is unless we use it . Like the argparse module.

The official document got me totally confused. So I wrote my own tutorial. Let's get started.

02 May, 2018

Exploring COLLECTIONS module from Python


The 'collections' module has some interesting methods that give us an edge over generic inbuilt tools . I want to explore them here today and show how you can use them .

namedtuple


Tuples are represented as (item1, item2, item2, ...) . They support indexing and one of the ways to use them is :


>>> from collections import namedtuple
>>> Car = namedtuple('Car','Price Mileage Colour Class')
>>> xyz = Car(Price = 100000, Mileage = 30, Colour = 'Cyan', Class = 'Y')
>>> print xyz
Car(Price=100000, Mileage=30, Colour='Cyan', Class='Y')
>>> print xyz.Class
Y

They turn tuples into convenient containers for simple tasks. With namedtuples, you don’t have to use integer indices for accessing members of a tuple.

28 March, 2018

How to import and use a font in your website ?



Most people like to use the default available list of fonts . But what if we liked some other font and we want to use it our own website .

There are free downloadable fonts on the web. When you download a zip of it , you generally would receive files of the format 'ttf', 'otf' etc. You can visit the site https://www.fontsquirrel.com and convert them into a format 'woff' .

16 March, 2018

How to use Docker with Python projects



Docker is the modern way to share ready made machines , so other can use it without the usual hassles of configuration and environment setup. I wanted to try it myself first hand, to see what the fuss is about.  I want to share what I found, so you start your project right now.

Before we start, for the absolute beginners who ABSOLUTELY NO IDEA about DOCKER, let me try to explain what it is:

It is a CONTAINER which CONTAINS ALL that you NEED to run your project. 

Dockers are the new generation Virtual Machines which totally remove the need to install another files on a system just to run or test something . They are just CONTAINERS with all the things necessary for our app to work. That's it .

08 March, 2018

Testing GET and POST calls using Flask


I was trying out Flask. In the process, I made a website that behaves like a server. It can help you test GET and POST calls.

It goes like this .

from flask import Flask, request
    app = Flask(__name__)
    
    @app.route('/method', methods=['GET', 'POST'])
    @app.route('/method/<wish>', methods=['GET', 'POST'])
    def method_used(wish=None):
        if request.method == 'GET':
            if wish:
                if wish in dir(request):
                    ans = None
                    s = "ans = str(request.%s)" % wish
                    exec s
                    return ans
                else:
                    return 'This wish is not available. The following are the available wishes: %s' % [method for method in dir(request) if '_' not in method]
            else:
                return 'This is just a GET method'
        else:
            return "You are using POST"


05 March, 2018

Why should we use Class in Python ?


Lots of people ask me, why should they use classes at all ? Well. I think its about control, and ease . It solves the headache of data sharing and accessibility. I am going to show you an example , which hopefully proves that classes and fundamentals like inheritance  are brilliant. Example: I have  two classes in the below program. Person and Manager . Manager has inherited the Person class (because he is a person too....almost (lol)) .