Example #1
0
    def hashGet(cls, pluginID, pluginHash):
        plugDir = Config.root_dir + "plugs/" + pluginID + "/"
        plugInstallDir = Config.root_dir + "install/" + pluginID + "/"

        if os.path.exists(plugDir) is False:
            if os.path.exists(plugInstallDir) is False:
                Controller.download(pluginID, pluginHash)
            else:
                hashFile = plugInstallDir + "md5"
                try:
                    f = file(hashFile)
                    line = f.readline()
                    f.close()
                except Exception, e:
                    print e
                    #插件不存在,下载插件
                    Controller.download(pluginID, pluginHash)
                    return
                if line != pluginHash:
                    Controller.download(pluginID, pluginHash)
            return
Example #2
0
                if line != pluginHash:
                    Controller.download(pluginID, pluginHash)
            return

        hashFile = plugDir + "md5"
        try:
            f = file(hashFile)
            line = f.readline()
            f.close()
        except Exception, e:
            print e
            return

        if line != pluginHash:
            #插件更新,下载插件
            Controller.download(pluginID, pluginHash)
        return

    @classmethod
    def post(cls, policy_list):
        ret_value = -1
        #print policy_list

        for policy in policy_list:
            plugin_id = policy['pluginId'].encode('utf-8')
            #比较hash,判断插件是否有更新

            pluginHash = policy['pluginHash'].encode('utf-8')
            if len(pluginHash) == 0:
                continue
            cls.hashGet(plugin_id, pluginHash)