Exemplo n.º 1
0
 def InitializeInfo(self, info = None):
     if info is not None:
         torrentName = self.info['name']
         self.rawinfo = info
         self.info = self.metainfo['info'] = bdecode(info)
         
     # Meta data fixing: valid names, unicode names
     self.info['name'] = fixInvalidName(self.metainfo['info']['name'])              
     if 'files' in self.info:
         for index in range(len(self.info['files'])):
             temppath = self.info['files'][index]['path']
             self.info['files'][index]['path'] = [fixInvalidName(part) for part in temppath]
     self.metainfo = self.makeunicode(dict(self.metainfo))        
               
     # Torrent Parameters
     self.addedTime = 0
     self.completedTime = 0
     if info is None:    # only apply once
         self.files = TorrentFiles(self)
         self.private = bool(self.info.get('private'))
         self.title = None
         self.prio = 2
         self.message = ""
         self.totalpeers = "?"
         self.totalseeds = "?"
     else:
         self.files.__init__(self)
         self.private = bool(self.info.get('private'))
         self.writeSrc(torrentName)
         self.hasMetadata = True
         self.torrentconfig.writeSrc()
         self.updateColumns(force = True)
         self.files.updateRealSize()
Exemplo n.º 2
0
    def _onApply(self, event = None):
        newdowndestloc = self.downdestloctext.GetValue().rstrip()
        newdowndestname = self.downdestnametext.GetValue().rstrip()
        
        # Values haven't changed -- no need to do anything here
        if ((newdowndestloc == self.currentvalues['destloc']) and
            (newdowndestname == self.currentvalues['destname'])):
            return True
        
        # Check if file and folder names are valid ones in Windows
        if sys.platform == 'win32':
            # We erase the final '\' except for a path like 'X:\'
            newdowndestloc_orig = newdowndestloc
            if newdowndestloc and newdowndestloc[-1] == '\\' and (len(newdowndestloc) < 2 or newdowndestloc[-2] != ':'):
                newdowndestloc = newdowndestloc[:-1]
            if not utility.checkWinPath(self, newdowndestloc_orig):
                return False
            fixedname = fixInvalidName(newdowndestname)
            if fixedname != newdowndestname:
                dlg = wx.MessageDialog(self, 
                                       newdowndestname + '\n' + \
                                       _('This name cannot be used as a Windows file or folder name.') + '\n'+ \
                                       _('Suggested corrected name :') + '\n\n' + \
                                       fixedname, 
                                       _('Error'), wx.ICON_ERROR)
                dlg.ShowModal()
                dlg.Destroy()
                return False

        self.newdest = path.join(newdowndestloc, newdowndestname)
        # Change the destination
        
        renamewithdest = self.rentorwithdest.GetValue()
        
        if self.movedata.GetValue():
            self.torrent.files.move(newdowndestloc, newdowndestname, renamewithdest)
        else:
            self.torrent.files.changeProcDest(self._getPath(), renamewithdest)

        # Keep track of the current values that we've saved
        self.currentvalues['destloc'] = newdowndestloc
        self.currentvalues['destname'] = newdowndestname

        return True