Auto plugin updater / Version checker

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
942
113
Australia
I see only 2 problems with this;
1- Getting a plugins version you'd have to search the plugins website page (1900ish lines)
2- Downloading a newer version would require a logged in account or it can not download it.

Has anyone tried this?
I guess the fixes would be;
1- Another website page that is callable (E.G http://fougerite.com/resourcesINFO/PluginName/) and displays plugin name & version
2- Maybe on the same page there is a link?

To download a file I think you'd use:
Python:
System.Net.WebRequestMethods.File.DownloadFile(http://fougerite.com/lol/lol.py
Python:
__title__ = 'Check'
__author__ = 'Jakkee'
__version__ = '1.0'

import clr
clr.AddReferenceByPartialName("Fougerite")
import Fougerite


class Check:
    def On_PluginInit(self):
        self.versioncheck("http://fougerite.com/resources/98/")

    def versioncheck(self, website):
        Util.Log("Checking: " + website + " ...")
        if not Plugin.IniExists("Log"):
            Plugin.CreateIni("Log")
            log = Plugin.GetIni("Log")
            log.Save()
        s = Web.GET(website)
        """version = FindVersion in s (Line 1300ish)
        if self.__version__ < version:
            for Player in Server.Players:
                if not Player.Admin
                    Continue
                 else:
                   Player.Message(self.__title__ + " has new update, Downloading version: " + version)
               file = System.Net.WebRequestMethods.File.DownloadFile(http://fougerite.com/lol/lol.py
               for Player in Server.Players:
                   if not Player.Admin
                       Continue
                   else:
                       Player.Message(self.__title__ + " Downloaded! Reload to take effect!")"""
        log = Plugin.GetIni("Log")
        log.AddSetting("Log", Plugin.GetDate() + "|" + Plugin.GetTime(), "Website Response: " + s)
        log.Save()
        Util.Log("Saved log file")
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,098
4,863
113
At your house.
github.com
I see only 2 problems with this;
1- Getting a plugins version you'd have to search the plugins website page (1900ish lines)
2- Downloading a newer version would require a logged in account or it can not download it.

Has anyone tried this?
I guess the fixes would be;
1- Another website page that is callable (E.G http://fougerite.com/resourcesINFO/PluginName/) and displays plugin name & version
2- Maybe on the same page there is a link?

To download a file I think you'd use:
Python:
System.Net.WebRequestMethods.File.DownloadFile(http://fougerite.com/lol/lol.py
Python:
__title__ = 'Check'
__author__ = 'Jakkee'
__version__ = '1.0'

import clr
clr.AddReferenceByPartialName("Fougerite")
import Fougerite


class Check:
    def On_PluginInit(self):
        self.versioncheck("http://fougerite.com/resources/98/")

    def versioncheck(self, website):
        Util.Log("Checking: " + website + " ...")
        if not Plugin.IniExists("Log"):
            Plugin.CreateIni("Log")
            log = Plugin.GetIni("Log")
            log.Save()
        s = Web.GET(website)
        """version = FindVersion in s (Line 1300ish)
        if self.__version__ < version:
            for Player in Server.Players:
                if not Player.Admin
                    Continue
                 else:
                   Player.Message(self.__title__ + " has new update, Downloading version: " + version)
               file = System.Net.WebRequestMethods.File.DownloadFile(http://fougerite.com/lol/lol.py
               for Player in Server.Players:
                   if not Player.Admin
                       Continue
                   else:
                       Player.Message(self.__title__ + " Downloaded! Reload to take effect!")"""
        log = Plugin.GetIni("Log")
        log.AddSetting("Log", Plugin.GetDate() + "|" + Plugin.GetTime(), "Website Response: " + s)
        log.Save()
        Util.Log("Saved log file")
Well well. I will need to create a user with a password, and give no access to It, just to download resources, and view them.

Maybe there is a link that gives the versions in RSS

http://fougerite.com/resources/rss?author=15

If I would check for python plugin updates, I would use this: https://github.com/balu92/IronPythonModule/blob/master/IronPythonModule/IPModule.cs#L15

After that I would import the plugin by It's name, and get the required variables.
Python:
name = "we got the module name from the for cycle"
plugin = __import__(name)