def downloadManga(self):
		print("Parsing XML File...")
		dom = minidom.parse(self.xmlfile_path)
		
		threadPool = []
		self.options.auto = True
		
		SetOutputPathToName_Flag = False
		# Default OutputDir is the ./MangaName
		if (self.options.outputDir == 'DEFAULT_VALUE'):
			SetOutputPathToName_Flag = True
			
		for node in dom.getElementsByTagName("MangaSeries"):
			name = getText(node.getElementsByTagName('name')[0])
			site = getText(node.getElementsByTagName('HostSite')[0])
			
			try:
				lastDownloaded = getText(node.getElementsByTagName('LastChapterDownloaded')[0])
			except IndexError:
				lastDownloaded = ""
			
			try:
				download_path =	getText(node.getElementsByTagName('downloadPath')[0])
			except IndexError:
				download_path = ('./' + fixFormatting(name))
			
			self.options.site = site
			self.options.manga = name
			self.options.downloadPath = download_path
			self.options.lastDownloaded = lastDownloaded
			if SetOutputPathToName_Flag:
				self.options.outputDir = download_path
			
			# Because the SiteParserThread constructor parses the site to retrieve which chapters to 
			# download the following code would be faster
			
			# thread = SiteParserThread(self.options, dom, node)
			# thread.start()
			# threadPool.append(thread)
			
			# Need to remove the loop which starts the thread's downloading. The disadvantage is that the 
			# the print statement would intermingle with the progress bar. It would be very difficult to 
			# understand what was happening. Do not believe this change is worth it.
			
			threadPool.append(SiteParserThread(self.options, dom, node))
		
		for thread in threadPool: 
			thread.start()
			thread.join()

		#print (dom.toxml())		
		f = open(self.xmlfile_path, 'w')
		f.write(dom.toxml()) 
Beispiel #2
0
    def stopNclients(self, args):
        id = self.getProducingId()
        if not id:
            self.newStatusMessage('there is no streams running')
            return
        elif len(id) == 1:
            id = id[0][1]
        else:
            sid = int(
                getChoice('select which id to stop clients',
                          [i[1] for i in id], None, None))
            id = [i for i in id if i[1] == sid][0][1]

        clients = len(self.getRunningClients(id))

        ret = getText("Clients:", "Insert number of clients to stop:",
                      "Maximum number is <b>%d</b>" % clients)
        try:
            num = int(ret)
        except:
            self.newStatusMessage(
                'number of client to stop should be an integer')
            return

        self._stopNclients(num, id)
Beispiel #3
0
 def _setUploadBW(self, args, iters):
     bw = getText("", "Upload bandwidth", "Insert new upload bandwidth:")
     try:
         bw = float(bw)
     except:
         self.newStatusMessage('bandwidth must be a double')
         return
     for iterator in iters:
         c = self.treemodel.get_value(iterator, 7)
         c.sendNewBW(bw / 8)
Beispiel #4
0
    def startNclients(self, args):
        id = self.getProducingId()
        if not id:
            self.newStatusMessage('there is no available streams to subscribe')
            return
        elif len(id) == 1:
            id = id[0]
        else:
            sid = int(
                getChoice('select which id to subscribe', [i[1] for i in id],
                          None, None))
            id = [i for i in id if i[1] == sid][0]

        clients = self.getAvailableClients()
        ret = getText("Clients:", "Insert number of clients to start:",
                      "Maximum number is <b>%d</b>" % len(clients))
        try:
            num = int(ret)
        except:
            self.newStatusMessage(
                'number of client to start should be an integer')
            return

        self._startNclients(num, id)
Beispiel #5
0
    def downloadManga(self):
        print("Parsing XML File...")
        if (self.verbose_FLAG):
            print("XML Path = %s" % self.xmlfile_path)

        dom = minidom.parse(self.xmlfile_path)

        threadPool = []
        self.options.auto = True

        SetOutputPathToName_Flag = False
        # Default OutputDir is the ./MangaName
        if (self.options.outputDir == 'DEFAULT_VALUE'):
            SetOutputPathToName_Flag = True

        for node in dom.getElementsByTagName("MangaSeries"):
            seriesOptions = copy.copy(self.options)
            seriesOptions.manga = getText(node.getElementsByTagName('name')[0])
            seriesOptions.site = getText(
                node.getElementsByTagName('HostSite')[0])

            try:
                lastDownloaded = getText(
                    node.getElementsByTagName('LastChapterDownloaded')[0])
            except IndexError:
                lastDownloaded = ""

            try:
                download_path = getText(
                    node.getElementsByTagName('downloadPath')[0])
            except IndexError:
                download_path = ('./' + fixFormatting(
                    seriesOptions.manga, seriesOptions.spaceToken))

            if self.options.downloadPath != 'DEFAULT_VALUE' and not os.path.isabs(
                    download_path):
                download_path = os.path.join(self.options.downloadPath,
                                             download_path)

            seriesOptions.downloadPath = download_path
            seriesOptions.lastDownloaded = lastDownloaded
            if SetOutputPathToName_Flag:
                seriesOptions.outputDir = download_path

            # Because the SiteParserThread constructor parses the site to retrieve which chapters to
            # download the following code would be faster

            # thread = SiteParserThread(self.options, dom, node)
            # thread.start()
            # threadPool.append(thread)

            # Need to remove the loop which starts the thread's downloading. The disadvantage is that the
            # the print statement would intermingle with the progress bar. It would be very difficult to
            # understand what was happening. Do not believe this change is worth it.

            threadPool.append(SiteParserThread(seriesOptions, dom, node))

        for thread in threadPool:
            thread.start()
            thread.join()

        #Backs up file
        backupFileName = self.xmlfile_path + "_bak"
        os.rename(self.xmlfile_path, backupFileName)
        f = open(self.xmlfile_path, 'w')

        outputStr = '\n'.join(
            [line for line in dom.toprettyxml().split('\n') if line.strip()])
        outputStr = outputStr.encode('utf-8')
        f.write(outputStr)

        # The file was succesfully saved and now remove backup
        os.remove(backupFileName)
Beispiel #6
0
	def downloadManga(self):
		print("Parsing XML File...")
		if (self.verbose_FLAG):
			print("XML Path = %s" % self.xmlfile_path)

		dom = minidom.parse(self.xmlfile_path)

		threadPool = []
		self.options.auto = True

		SetOutputPathToName_Flag = False
		# Default OutputDir is the ./MangaName
		if (self.options.outputDir == 'DEFAULT_VALUE'):
			SetOutputPathToName_Flag = True

		for node in dom.getElementsByTagName("MangaSeries"):
			seriesOptions = self.options
			seriesOptions.manga = getText(node.getElementsByTagName('name')[0])
			seriesOptions.site = getText(node.getElementsByTagName('HostSite')[0])

			try:
				lastDownloaded = getText(node.getElementsByTagName('LastChapterDownloaded')[0])
			except IndexError:
				lastDownloaded = ""

			try:
				download_path =	getText(node.getElementsByTagName('downloadPath')[0])
			except IndexError:
				download_path = ('./' + fixFormatting(seriesOptions.manga, seriesOptions.spaceToken))

			if self.options.downloadPath != 'DEFAULT_VALUE' and not os.path.isabs(download_path):
				download_path = os.path.join(self.options.downloadPath, download_path)

			seriesOptions.downloadPath = download_path
			seriesOptions.lastDownloaded = lastDownloaded
			if SetOutputPathToName_Flag:
				seriesOptions.outputDir = download_path

			# Because the SiteParserThread constructor parses the site to retrieve which chapters to
			# download the following code would be faster

			# thread = SiteParserThread(self.options, dom, node)
			# thread.start()
			# threadPool.append(thread)

			# Need to remove the loop which starts the thread's downloading. The disadvantage is that the
			# the print statement would intermingle with the progress bar. It would be very difficult to
			# understand what was happening. Do not believe this change is worth it.

			threadPool.append(SiteParserThread(seriesOptions, dom, node))

		for thread in threadPool:
			thread.start()
			thread.join()

		#Backs up file
		backupFileName = self.xmlfile_path + "_bak"
		os.rename(self.xmlfile_path, backupFileName)
		f = open(self.xmlfile_path, 'w')

		outputStr = '\n'.join([line for line in dom.toprettyxml().split('\n') if line.strip()])
		outputStr = outputStr.encode('utf-8')
		f.write(outputStr)

		# The file was succesfully saved and now remove backup
		os.remove(backupFileName)