예제 #1
0
    def cmdUpdate(self, pkg, flag):



        if pkg == None:
            # Query for all installed packages
            prog_list = db_wrapper.get_applications(mydb)

        else:
            # Query db for requested package
            prog_list = (True,  pkg )
            #print(prog_list[1])

        print("Checking for updates")
        for p in prog_list[1]:
            print(p + ":")
            result = db_wrapper.get_app_version(mydb, p)


            if flag.keep_going or (result[0] == True and result[1] != []) :

                if result[1] != []:
                    pkg_version = result[1][0]
                else:
                    pkg_version = "N/A"
                    pkg_current = "Not found"

            else:
                print("{0:15s} {1:10s} {2:10s}").format(p, "N/A", "Not found")
                continue


            # Check if new version has been checked "recently"
            # TODO: Define check frequency in settings.py
            if result[1] != []:
                last_checked = date.fromtimestamp(float(result[1][1]))
                today = date.fromtimestamp(time.time())

                # Check for new versions only once a day
#                if flag.force or (today - last_checked ) > timedelta(days=1):
#                    pass
                    # Check if out of date
                        # download new version if available
                        # set out-of-date

                    # Download updates if they are available and !(flag.no_execute)
                if not flag.no_execute:
                    prog = app(p, mydb, appLogFileName)
                    if prog.checkUpdates():
                        prog.dlUpdates()
예제 #2
0
vim_regex = '".*vim.*\.exe"'
vim_version_regex = '\d+.*\d'


appLogFileName = "appLog"

validQuery, applications = db_wrapper.get_applications(mydb)

print 'All Applicaitons:', applications
if validQuery and not vim_name in applications:
    print 'adding vim to the db.'
    db_wrapper.add_app(mydb, vim_name, vim_version, vim_dl_url, vim_url)
    db_wrapper.add_exe_regex(mydb, vim_name, [vim_regex])
    db_wrapper.add_version_regex(mydb, vim_name, [vim_version_regex])

vim = app(vim_name, mydb, appLogFileName)
updatesAvail = vim.checkUpdates()
print 'gvim update available?', updatesAvail

if updatesAvail:
    vim.dlUpdates()

putty_name = 'putty'
putty_url = 'http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html'
putt_dl_url = 'http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html'
putty_version = '1.0'
putty_regex = '".*putty.*\.exe"'
putty_version_regex = '\d+.*\d'

if validQuery and putty_name not in applications:
    print 'adding putty to the db.'
예제 #3
0
    def cmdInfo(self, pkg, flag):

        if pkg == None:
            # Query for all installed packages
            prog_list = db_wrapper.get_applications(mydb)

        else:
            # Query db for requested package
            prog_list = (True,  pkg )
            #print(prog_list[1])

        # Print header to the package table
        print("")
        print("{0:15s} {1:10s} {2:10s}").format("Name", "Version", "Up-to-date?")
        print("{0:15s} {1:10s} {2:10s}").format("----", "-------", "-----------")
        for p in prog_list[1]:
            result = db_wrapper.get_app_version(mydb, p)

            pkg_current = "Y"

            if flag.keep_going or (result[0] == True and result[1] != []) :

                if result[1] != []:
                    pkg_version = result[1][0]
                else:
                    pkg_version = "N/A"
                    pkg_current = "Not found"

            else:
                print("{0:15s} {1:10s} {2:10s}").format(p, "N/A", "Not found")
                continue


            # Check if new version has been checked "recently"
            # TODO: Define check frequency in settings.py
            if result[1] != []:
                last_checked = date.fromtimestamp(float(result[1][1]))
                today = date.fromtimestamp(time.time())

                # Check for new versions only once a day
                if flag.force or (today - last_checked ) > timedelta(days=1):
                    pass
                    # Check if out of date
                        # download new version if available
                        # set out-of-date

                    # Download updates if they are available and !(flag.no_execute)
                    if not flag.no_execute:
                        prog = app(p, mydb, appLogFileName)
                        if prog.checkUpdates():
                            pkg_current = "Y"
                        else:
                            pkg_current = "N"
                        #print(prog.getExeURLs())
                        #prog.dlUpdates()


                else:
                    # If version has been checked already...
                    pkg_current = "N"

                # if out of date and !(flag.no_execute):
                    #prog.dlUpdates()

            # Display installed packages, version and up to date status
            print("{0:15s} {1:10s} {2:10s}").format(p, pkg_version, pkg_current)

        print("")