Exemplo n.º 1
0
    def update(self):
        uberlist = []
        pwd = dirname(realpath(__file__))
        with open(pwd + '/' + self.ADDON_LIST_FILE, "r") as fin:
            for line in fin:
                current_node = []
                line = line.rstrip('\n')
                if not line or line.startswith('#'):
                    continue
                if '|' in line:
                    ''' Expected input format: "mydomain.com/myzip.zip"
                        or "mydomain.com/myzip.zip|subfolder"
                    '''
                    subfolder = line.split('|')[1]
                    line = line.split('|')[0]
                else:
                    subfolder = ''
                addonName = SiteHandler.getAddonName(line)
                currentVersion = SiteHandler.getCurrentVersion(line)
                if currentVersion is None:
                    currentVersion = 'Not Available'
                current_node.append(addonName)
                current_node.append(currentVersion)
                installedVersion = self.getInstalledVersion(line, subfolder)
                if not currentVersion == installedVersion:
                    if installedVersion == 'version not found':
                        print('Installing {} (version: {})'
                              .format(addonName, currentVersion)
                              )
                    else:
                        print('Updating {} ({} --> {})'
                              .format(addonName,
                                      installedVersion,
                                      currentVersion)
                              )
                    ziploc = SiteHandler.findZiploc(line)
                    install_success = False
                    install_success = self.getAddon(ziploc, subfolder)
                    current_node.append(
                            self.getInstalledVersion(line, subfolder)
                            )
                    if install_success and (currentVersion != ''):
                        self.setInstalledVersion(line,
                                                 subfolder,
                                                 currentVersion)
                else:
                    print('{} version {} is up to date'
                          .format(addonName, currentVersion))

                    current_node.append("Up to date")
                uberlist.append(current_node)
        if self.AUTO_CLOSE == 'False':
            ''' + 2 for padding
            '''
            col_width = max(len(word) for row in uberlist for word in row) + 2
            print("".join(word.ljust(col_width)
                  for word in ("Name", "Iversion", "Cversion")))
            for row in uberlist:
                print("".join(word.ljust(col_width) for word in row), end='\n')
            confirmExit()
 def update(self):
     uberlist = []
     self.threads = []
     with open(self.ADDON_LIST_FILE, "r") as fin:
         if self.USE_GUI:
             self.addText('Checking for updates.' + '\n')
         for line in fin:
             current_node = []
             line = line.strip()
             if not line or line.startswith('#'):
                 continue
             if self.USE_GUI and self.ABORT.is_set():
                 # The GUI thread has asked the update thread to stop.
                 self.addText("Cancelled.")
                 return
             if '|' in line:  # Expected input format: "mydomain.com/myzip.zip" or "mydomain.com/myzip.zip|subfolder"
                 subfolder = line.split('|')[1]
                 line = line.split('|')[0]
             else:
                 subfolder = ''
             addonName = SiteHandler.getAddonName(line)
             currentVersion = SiteHandler.getCurrentVersion(line)
             if currentVersion is None:
                 currentVersion = 'Not Available'
             current_node.append(addonName)
             current_node.append(currentVersion)
             installedVersion = self.getInstalledVersion(line)
             self.addProgress()
             if self.USE_GUI and self.ABORT.is_set():
                 # The GUI thread has asked the update thread to stop.
                 self.addText("Cancelled.")
                 return
             if not currentVersion == installedVersion:
                 self.addText('Installing/updating addon: ' +
                              addonName + ' to version: ' + currentVersion)
                 ziploc = SiteHandler.findZiploc(line)
                 install_success = False
                 install_success = self.getAddon(ziploc, subfolder)
                 current_node.append(self.getInstalledVersion(line))
                 if install_success is True and currentVersion is not '':
                     self.setInstalledVersion(line, currentVersion)
             else:
                 self.addText('Up to date: ' + addonName +
                              ' version ' + currentVersion)
                 current_node.append("Up to date")
             uberlist.append(current_node)
     if self.USE_GUI:
         self.addText('\n' + 'All done!')
         return
     if self.AUTO_CLOSE == 'False':
         col_width = max(len(word)
                         for row in uberlist for word in row) + 2  # padding
         print("".join(word.ljust(col_width)
                       for word in ("Name", "Iversion", "Cversion")))
         for row in uberlist:
             print("".join(word.ljust(col_width) for word in row), end='\n')
         confirmExit()
 def update(self):
     uberlist = []
     with open(self.ADDON_LIST_FILE, "r") as fin:
         for line in fin:
             current_node = []
             line = line.rstrip('\n')
             if not line or line.startswith('#'):
                 continue
             if '|' in line:  # Expected input format: "mydomain.com/myzip.zip" or "mydomain.com/myzip.zip|subfolder"
                 subfolder = line.split('|')[1]
                 line = line.split('|')[0]
             else:
                 subfolder = ''
             addonName = SiteHandler.getAddonName(line)
             #New
             #print('Debug addonName: ' + addonName + '\n')
             currentVersion = SiteHandler.getCurrentVersion(line)
             #print('Debug currentVersion: ' + currentVersion + '\n')
             if currentVersion is None:
                 currentVersion = 'Not Available'
             current_node.append(addonName)
             current_node.append(currentVersion)
             installedVersion = self.getInstalledVersion(line, subfolder)
             if not currentVersion == installedVersion:
                 print('Installing/updating addon: ' + addonName +
                       ' to version: ' + currentVersion + '\n')
                 ziploc = SiteHandler.findZiploc(line)
                 #print('Debug addon ziploc: ' + ziploc + '\n')
                 install_success = False
                 install_success = self.getAddon(ziploc, subfolder)
                 current_node.append(
                     self.getInstalledVersion(line, subfolder))
                 if install_success and (currentVersion != ''):
                     self.setInstalledVersion(line, subfolder,
                                              currentVersion)
             else:
                 print(addonName + ' version ' + currentVersion +
                       ' is up to date.\n')
                 current_node.append("Up to date")
             uberlist.append(current_node)
     if self.AUTO_CLOSE == 'False':
         col_width = max(len(word) for row in uberlist
                         for word in row) + 2  # padding
         print("".join(
             word.ljust(col_width)
             for word in ("Name", "Iversion", "Cversion")))
         for row in uberlist:
             print("".join(word.ljust(col_width) for word in row), end='\n')
         confirmExit()
Exemplo n.º 4
0
 def setInstalledVersion(self, addonpage, currentVersion):
     addonName = SiteHandler.getAddonName(addonpage)
     installedVers = configparser.ConfigParser()
     installedVers.read(self.INSTALLED_VERS_FILE)
     installedVers.set('Installed Versions', addonName, currentVersion)
     with open(self.INSTALLED_VERS_FILE, 'w') as installedVersFile:
         installedVers.write(installedVersFile)
 def update_addon(self, addon, uberlist):
     # TODO better way of handling cancel. Should watch for every thread and close them
     current_node = []
     addon = addon.rstrip('\n')
     if not addon or addon.startswith('#'):
         return
     if self.USE_GUI and self.ABORT.is_set():
         # The GUI thread has asked the update thread to stop.
         self.addText("Cancelled.")
         return
     if '|' in addon:  # Expected input format: "mydomain.com/myzip.zip" or "mydomain.com/myzip.zip|subfolder"
         subfolder = addon.split('|')[1]
         addon = addon.split('|')[0]
     else:
         subfolder = ''
     addonName = SiteHandler.getAddonName(addon)
     currentVersion = SiteHandler.getCurrentVersion(addon, self.VERSION)
     if currentVersion is None:
         currentVersion = 'Not Available'
     current_node.append(addonName)
     current_node.append(currentVersion)
     installedVersion = self.getInstalledVersion(addon, subfolder)
     if self.USE_GUI and self.ABORT.is_set():
         # The GUI thread has asked the update thread to stop.
         self.addText("Cancelled.")
         return
     # TODO should not be checked here anymore
     if not currentVersion == installedVersion:
         self.addText('Installing/updating addon: ' + addonName +
                      ' to version: ' + currentVersion)
         ziploc = SiteHandler.findZiploc(addon, self.VERSION)
         install_success = False
         install_success = self.getAddon(ziploc, subfolder)
         current_node.append(self.getInstalledVersion(addon, subfolder))
         if install_success and (currentVersion is not ''):
             # Update was successfull, we handle the GUI change
             if self.USE_GUI:
                 self.addProgress()
                 self.tree.item(addonName,
                                values=(currentVersion + ' ' +
                                        currentVersion + ' "Up to date"'))
             self.setInstalledVersion(addon, subfolder, currentVersion)
     else:
         self.addText('Up to date: ' + addonName + ' version ' +
                      currentVersion)
         current_node.append("Up to date")
     uberlist.append(current_node)
 def update(self):
     # Main process (yes I formatted the project badly)
     with open(self.ADDON_LIST_FILE, "r") as fin:
         for line in fin:
             line = line.rstrip('\n')
             currentVersion = SiteHandler.getCurrentVersion(line)
             installedVersion = self.getInstalledVersion(line)
             if not currentVersion == installedVersion:
                 print('Installing/updating addon: ' + line + ' to version: ' + currentVersion + '\n')
                 ziploc = SiteHandler.findZiploc(line)
                 self.getAddon(ziploc)
                 if currentVersion is not '':
                     self.setInstalledVersion(line, currentVersion)
             else:
                 print(line + ' version ' + currentVersion + ' is up to date.\n')
     if self.AUTO_CLOSE == 'False':
         confirmExit()
Exemplo n.º 7
0
 def getInstalledVersion(self, addonpage):
     addonName = SiteHandler.getAddonName(addonpage)
     installedVers = configparser.ConfigParser()
     installedVers.read(self.INSTALLED_VERS_FILE)
     try:
         return installedVers['Installed Versions'][addonName]
     except Exception:
         return 'version not found'
Exemplo n.º 8
0
 def setInstalledVersion(self, addonpage, subfolder, currentVersion):
     addonName = SiteHandler.getAddonName(addonpage)
     installedVers = configparser.ConfigParser()
     installedVers.read(self.INSTALLED_VERS_FILE)
     if(subfolder):
         installedVers.set('Installed Versions', addonName + '|' + subfolder, currentVersion) # Keep subfolder info in installed listing
     else:
         installedVers.set('Installed Versions', addonName, currentVersion)
     with open(self.INSTALLED_VERS_FILE, 'w') as installedVersFile:
         installedVers.write(installedVersFile)
Exemplo n.º 9
0
 def getInstalledVersion(self, addonpage, subfolder):
     addonName = SiteHandler.getAddonName(addonpage)
     installedVers = configparser.ConfigParser()
     installedVers.read(self.INSTALLED_VERS_FILE)
     try:
         if(subfolder):
             return installedVers['Installed Versions'][addonName + '|' + subfolder] # Keep subfolder info in installed listing
         else:
             return installedVers['Installed Versions'][addonName]
     except Exception:
         return 'version not found'
 def update_addon(self, addon, uberlist):
     current_node = []
     addon = addon.rstrip('\n')
     if not addon or addon.startswith('#'):
         return
     if self.USE_GUI and self.ABORT.is_set():
         # The GUI thread has asked the update thread to stop.
         self.addText("Cancelled.")
         return
     if '|' in addon:  # Expected input format: "mydomain.com/myzip.zip" or "mydomain.com/myzip.zip|subfolder"
         subfolder = addon.split('|')[1]
         addon = addon.split('|')[0]
     else:
         subfolder = ''
     addonName = SiteHandler.getAddonName(addon)
     currentVersion = SiteHandler.getCurrentVersion(addon)
     if currentVersion is None:
         currentVersion = 'Not Available'
     current_node.append(addonName)
     current_node.append(currentVersion)
     installedVersion = self.getInstalledVersion(addon, subfolder)
     self.addProgress()
     if self.USE_GUI and self.ABORT.is_set():
         # The GUI thread has asked the update thread to stop.
         self.addText("Cancelled.")
         return
     if not currentVersion == installedVersion:
         self.addText('Installing/updating addon: ' +
                      addonName + ' to version: ' + currentVersion)
         ziploc = SiteHandler.findZiploc(addon)
         install_success = False
         install_success = self.getAddon(ziploc, subfolder)
         current_node.append(self.getInstalledVersion(addon, subfolder))
         if install_success and (currentVersion is not ''):
             self.setInstalledVersion(addon, currentVersion, subfolder)
     else:
         self.addText('Up to date: ' + addonName +
                      ' version ' + currentVersion)
         current_node.append("Up to date")
     uberlist.append(current_node)
 def update(self):
     update_results = []
     addon_list = []
     with open("in.txt", "r") as fin:
         for line in fin:
             current_node = []
             line = line.rstrip('\n')
             if not line or line.startswith('#'):
                 continue
             if '|' in line:  # Expected input format: "curse.com/addon.zip" or "curse.com/addon.zip|subfolder"
                 subfolder = line.split('|')[1]
                 line = line.split('|')[0]
             else:
                 subfolder = ''
             addon_name = SiteHandler.get_addon_name(line)
             current_version = SiteHandler.get_current_version(line)
             if current_version is None:
                 current_version = 'Not Available'
             current_node.append(addon_name)
             current_node.append(current_version)
             installed_version = self.get_installed_version(line, subfolder)
             if not current_version == installed_version:
                 update_results.append('Installing/updating addon: ' +
                                       addon_name + ' to version: ' +
                                       current_version)
                 logging.info('Installing/updating addon: ' + addon_name +
                              ' to version: ' + current_version)
                 ziploc = SiteHandler.find_ziploc(line)
                 install_success = self.get_addon(ziploc, subfolder)
                 current_node.append(
                     self.get_installed_version(line, subfolder))
                 if install_success and (current_version is not ''):
                     self.set_installed_version(line, subfolder,
                                                current_version)
             else:
                 update_results.append(addon_name + ' version ' +
                                       current_version + ' is up to date.')
                 current_node.append("Up to date")
             addon_list.append(current_node)
     return update_results
Exemplo n.º 12
0
 def setInstalledVersion(self, addonpage, subfolder, currentVersion):
     pwd = dirname(realpath(__file__))
     addonName = SiteHandler.getAddonName(addonpage)
     installedVers = configparser.ConfigParser()
     installedVers.read(pwd + '/' + self.INSTALLED_VERS_FILE)
     if(subfolder):
         ''' Keep subfolder info in installed listing
         '''
         installedVers.set('Installed Versions', addonName + '|' + subfolder, currentVersion)  # noqa E501
     else:
         installedVers.set('Installed Versions', addonName, currentVersion)
     with open(pwd + '/' + self.INSTALLED_VERS_FILE, 'w') \
             as installedVersFile:
         installedVers.write(installedVersFile)
Exemplo n.º 13
0
 def getInstalledVersion(self, addonpage, subfolder):
     pwd = dirname(realpath(__file__))
     addonName = SiteHandler.getAddonName(addonpage)
     installedVers = configparser.ConfigParser()
     installedVers.read(pwd + '/' + self.INSTALLED_VERS_FILE)
     try:
         if(subfolder):
             ''' Keep subfolder info in installed listing
             '''
             return installedVers['Installed Versions'][addonName + '|' + subfolder]  # noqa E501
         else:
             return installedVers['Installed Versions'][addonName]
     except Exception:
         return 'version not found'
 def set_installed_version(addon_page, subfolder, current_version):
     addon_name = SiteHandler.get_addon_name(addon_page)
     installed_version = configparser.ConfigParser()
     installed_version.read("installed.txt")
     if subfolder:
         installed_version.set('Installed Versions',
                               addon_name + '|' + subfolder,
                               current_version)  # Keep subfolder
         # info in installed listing
     else:
         installed_version.set('Installed Versions', addon_name,
                               current_version)
     with open("installed.txt", 'w') as installed_version_file:
         installed_version.write(installed_version_file)
Exemplo n.º 15
0
 def update(self):
     # Main process (yes I formatted the project badly)
     uberlist = []
     with open(self.ADDON_LIST_FILE, "r") as fin:
         for line in fin:
             current_node = []
             line = line.rstrip('\n')
             if not line or line.startswith('#'):
                 continue
             currentVersion = SiteHandler.getCurrentVersion(line)
             if currentVersion is None:
                 currentVersion = 'Not Available'
             current_node.append(line.split("/")[-1])
             current_node.append(SiteHandler.getCurrentVersion(line))
             installedVersion = self.getInstalledVersion(line)
             if not currentVersion == installedVersion:
                 print('Installing/updating addon: ' + line +
                       ' to version: ' + currentVersion + '\n')
                 ziploc = SiteHandler.findZiploc(line)
                 SiteHandler.installAddon(ziploc, self.WOW_ADDON_LOCATION)
                 current_node.append(self.getInstalledVersion(line))
                 if currentVersion is not '':
                     self.setInstalledVersion(line, currentVersion)
             else:
                 print(line + ' version ' + currentVersion +
                       ' is up to date.\n')
                 current_node.append("Up to date")
             uberlist.append(current_node)
     if self.AUTO_CLOSE == 'False':
         col_width = max(len(word) for row in uberlist
                         for word in row) + 2  # padding
         print("".join(
             word.ljust(col_width)
             for word in ("Name", "Iversion", "Cversion")))
         for row in uberlist:
             print("".join(word.ljust(col_width) for word in row), end='\n')
         confirmExit()
 def get_installed_version(addon_page, subfolder):
     addon_name = SiteHandler.get_addon_name(addon_page)
     installed_version = configparser.ConfigParser()
     installed_version.read("installed.txt")
     try:
         if subfolder:
             return installed_version['Installed Versions'][
                 addon_name + '|' + subfolder]  # Keep subfolder info in
             #  installed listing
         else:
             return installed_version['Installed Versions'][addon_name]
     except configparser.ParsingError:
         return 'version not found'
     except KeyError:
         return 0
 def updateTree(self):
     with open(self.ADDON_LIST_FILE, "r") as fin:
         for line in fin:
             line = line.strip()
             if line and not line.startswith('#'):
                 # Here we populate the Tree
                 line = line.strip()
                 if '|' in line:  # Expected input format: "mydomain.com/myzip.zip" or "mydomain.com/myzip.zip|subfolder"
                     subfolder = line.split('|')[1]
                     line = line.split('|')[0]
                 else:
                     subfolder = ''
                 addonName = SiteHandler.getAddonName(line)
                 installedVersion = self.getInstalledVersion(
                     line, subfolder)
                 newVersion = SiteHandler.getCurrentVersion(
                     line, self.VERSION)
                 if newVersion == installedVersion:
                     state = '"Up to date"'
                 else:
                     state = '"New version available"'
                 self.tree.item(addonName,
                                values=(installedVersion + ' ' +
                                        newVersion + ' ' + state))
Exemplo n.º 18
0
def initiate():
	global count,  search_max_depth
	while(URLProvider.isIncomplete()):
		curr_url = URLProvider.get_URL()
		if(int(curr_url[1]) <= int(search_max_depth) ):
			#Print can be removed
			print curr_url, count
			my_tuple=('00000',{'customError':'NO ACCESS'},None,None,0,0)
			if(SiteHandler.is_Valid(curr_url[0])):
					#Process further
					response_data=URLFetcher.getURL(curr_url[0])
					if(response_data==1):
						my_tuple=('2222',{'customError':'Unable to Fetch Correctly'}, None, None,0, curr_url[1])
					else:
						myMime =response_data.headers.get('Content-Type')
						if(valid_mime_type(myMime)):
							base_url=utils.getBaseUrl(curr_url[0])
							mystring = response_data.read()
							links = AttributeExtraction.extract_Links(base_url,mystring)
							stored_tup = pagestoragehandler.write_log(curr_url[0],mystring)
							my_tuple = (response_data.code, response_data.headers, stored_tup, len(links), len(mystring),curr_url[1])
							#links or None
							for link in set(links):
								if(valid_protocol_request(urlsplit(link)[0])):
									if(infologger.not_in_list(link)):
										URLProvider.add_URL(link)
						else:
							#We need to keep a log of Data-Stored. If a log of data downloaded is required
							#We can put the response object's data to find its size. 
							#Ideally headers do provide the size in headers, but we found some cases
							#it was not provided. So implemented it in this fashion.
							my_tuple=('1111',{'customError':'Unsupported Mime'}, None, None,0, curr_url[1])
						
			infologger.write_summary(curr_url[0], my_tuple )
			count += 1
						
	# Force writes and commits
	pagestoragehandler.store_log()
	infologger.store_log()
    def initGUI(self):
        # We don't need any of this stuff if we're not running the GUI.
        self.textqueue = queue.Queue()
        self.progressqueue = queue.Queue()
        root = Tk()
        root.title("WoW Addon Updater")

        root.minsize(290, 214)
        root.rowconfigure(0, weight=1)
        root.columnconfigure(0, weight=1)
        mainframe = Frame(root, padding="3 3 3 3")
        mainframe.grid(sticky=(N, W, E, S))

        mainframe.rowconfigure(0, weight=0)
        mainframe.columnconfigure(0, weight=1)
        mainframe.rowconfigure(1, weight=1)
        mainframe.columnconfigure(1, weight=1)
        mainframe.rowconfigure(2, weight=0)
        mainframe.columnconfigure(2, weight=1)
        mainframe.rowconfigure(3, weight=0)

        Sizegrip(root).grid(row=0, sticky=(S, E))

        Label(mainframe, text="WoW Addon Updater",
              font=("Helvetica", 20)).grid(column=0,
                                           row=0,
                                           sticky=(N),
                                           columnspan=3)

        # TODO make something with this
        output_text = scrolledtext.ScrolledText(mainframe,
                                                width=110,
                                                height=20,
                                                wrap=WORD)
        output_text.grid(column=0, row=1, sticky=(N, S, E, W), columnspan=3)

        # Implement tree instead of ScrolledText
        self.tree = Treeview(mainframe)
        self.tree.grid(column=0, row=1, sticky=(N, S, E, W), columnspan=3)
        self.tree['columns'] = ('currentVersion', 'newVersion', 'update')
        self.tree.heading('#0', text='Name', anchor=W)
        self.tree.heading('currentVersion', text='Current version', anchor=W)
        self.tree.heading('newVersion', text='Availlable version', anchor=W)
        self.tree.heading('update', text='Update')

        progressbar = Progressbar(mainframe,
                                  orient="horizontal",
                                  mode="determinate")
        progressbar.grid(column=0, row=2, sticky=(E, W), columnspan=3)
        with open(self.ADDON_LIST_FILE, "r") as fin:
            length = 0
            for line in fin:
                line = line.strip()
                if line and not line.startswith('#'):
                    # Here we populate the Tree
                    line = line.strip()
                    if '|' in line:  # Expected input format: "mydomain.com/myzip.zip" or "mydomain.com/myzip.zip|subfolder"
                        subfolder = line.split('|')[1]
                        line = line.split('|')[0]
                    else:
                        subfolder = ''
                    addonName = SiteHandler.getAddonName(line)
                    installedVersion = self.getInstalledVersion(
                        line, subfolder)
                    newVersion = SiteHandler.getCurrentVersion(
                        line, self.VERSION)
                    if newVersion == installedVersion:
                        state = '"Up to date"'
                    else:
                        state = '"New version available"'
                    self.tree.insert('',
                                     'end',
                                     addonName,
                                     text=addonName,
                                     values=(installedVersion + ' ' +
                                             newVersion + ' ' + state))
                    length += 1
            progressbar.configure(value=0, maximum=length)

        self.root = root
        self.output_text = output_text
        self.progressbar = progressbar
        self.ABORT = threading.Event()
        root.protocol("WM_DELETE_WINDOW", self.shutdownGUI)

        self.cancelbutton = Button(mainframe,
                                   text="Cancel",
                                   command=self.abortUpdating,
                                   state=DISABLED)
        self.cancelbutton.grid(column=0, row=3)
        self.configButton = Button(mainframe,
                                   text="Configure",
                                   command=self.editConfig)
        self.configButton.grid(column=1, row=3)
        self.startbutton = Button(mainframe,
                                  text="Update",
                                  command=self.startUpdating)
        self.startbutton.grid(column=2, row=3)

        for child in mainframe.winfo_children():
            child.grid_configure(padx=5, pady=5)
        self.output_text.insert(
            END,
            'Welcome to WoW Addon Updater. If you\'ve already made an addons.txt file, click Start to begin.'
            + '\n')
        self.updateGUI()