Saturday, March 18, 2017

How to add auto-update feature in Python

Hello guys!



It is a bit different topic, I am discussing on my blog.

When I was developing BruteXSS, I faced some difficulties, as I am new to GUI development and don't know how to do all these things. During mobile app development, we don't need to worry about Auto-Update and all, because Play Store do this on its own.

During developing BruteXSS, I wanted to add auto-update feature in python but their was no such library or pre-written code, or simply can't find any python tools out to copy and paste their code.

So I did one thing, I added a line in my tools " __version__ = '1.0' " to know which version is this tool running.

Then on my github page I added a simple txt file written "1.0".
Simple
Now whenever I need to send an OTA update to all my users, I simply change the version to "1.1" or so on on my github page and everytime the tool launches it retrives that data from my github page and check whether it is same or changed. If it is changed then show an Update Alert else continue.

Here is a sample code, that I added in my BruteXSS tool :


        versionfile = urllib2.urlopen('https://raw.githubusercontent.com/rajeshmajumdar/BruteXSS  

                                                        /master/version.txt').read()
        if float(versionfile) > float(__version__):
            updatefunc()
        else:
            print 'Already a updated version'
            start()


These five lines of code added an awesome feature in my tool.

Hope these lines will help you in building your new tool.

No comments: