Exemple #1
0
    def createTorrent(self, title, paths):
        #convert QStringList into a normal python list
        title = str(title)
        paths = [str(p) for p in paths]

        torrent_root = os.path.join(self.controller.cache_path, title)

        if os.path.exists(torrent_root):
            self.showMessage("Folder already exists: {}".format(title))
            return
        ''' Create a temp torrent file. the one in the cache folder will be written at program shutdown '''
        fd, torrent_file = tempfile.mkstemp(suffix=".torrent")
        os.close(fd)

        try:
            os.mkdir(torrent_root)
            ''' Copy all file to one location '''
            for path in paths:
                print(u"jsbridge: Copy {} to {}".format(path, torrent_root))
                shutil.copy(path, torrent_root)

            TorrentController.createTorrent(torrent_file, torrent_root,
                                            self.showProgress)
            self.controller.addTorrentFile(torrent_file)
        except:
            e = sys.exc_info()[0]
            print(e)
            self.showMessage(e)

        #some cleanup
        os.remove(torrent_file)
Exemple #2
0
	def createTorrent(self, title, paths):
		#convert QStringList into a normal python list
		title = str(title)
		paths = [str(p) for p in paths]

		torrent_root = os.path.join(self.controller.cache_path, title)

		if os.path.exists(torrent_root):
			self.showMessage("Folder already exists: {}".format(title))
			return

		''' Create a temp torrent file. the one in the cache folder will be written at program shutdown '''
		fd, torrent_file = tempfile.mkstemp(suffix=".torrent")
		os.close(fd)

		try:
			os.mkdir(torrent_root)

			''' Copy all file to one location '''
			for path in paths:
				print(u"jsbridge: Copy {} to {}".format(path, torrent_root))
				shutil.copy(path, torrent_root)

			TorrentController.createTorrent(torrent_file, torrent_root, self.showProgress)
			self.controller.addTorrentFile(torrent_file)
		except:
			e = sys.exc_info()[0]
			print(e)
			self.showMessage(e)

		#some cleanup
		os.remove(torrent_file)