Hi @nageshkar
We are talking about two different ways to read the time from the DS1307 chip.
The first way that I described above tells the Linux kernel about the reat time clock chip, and after it is set up the Linux kernel takes care of the chip. If you want to get the time from the Linux kernel into your python program there are many ways, discussed here: https://stackoverflow.com/questions/415511/how-to-get-current-time-in-python
The code you have attached assumes that the linux kernel knows nothing about the DS1307 chip, and goes out through the I2C bus and reads the DS1307 chip directly. This will of course fail if you already have the Linux kernel taking care of the DS1307.
You need to select one way or the other, you can’t mix them. I would strongly suggest that you let the Linux kernel take care of time and have your Python program just get the time from the kernel, or from the network. Of course if your board is connected to the network, the Linux kernel doesn’t need the DS1307, it just picks up the current time from the network.
Full disclosure: I am an employee of Qualcomm Canada, any opinions I have expressed in this or any other post may not reflect the opinions of my employer.