~ubuntu-branches/ubuntu/feisty/aptoncd/feisty

« back to all changes in this revision

Viewing changes to RepDownload.py

  • Committer: Bazaar Package Importer
  • Author(s): Rafael Proença
  • Date: 2007-03-13 17:29:35 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313172935-o9bsldf7qbau69o0
Tags: 0.1~rc-0ubuntu1
* Improvements in performance of the create treeview (+60% faster while mounting the list of packages);
* Added a call method for Download Repository (--download, just like --create) calling frmDownload without shown frmMainWindow;
* Now shows the number of downloaded files/to download in the Download Repository window;
* Placed a window when download susessful finished, asking if user want do remove the temp files;
* Improved the auto-select dependencies recursively, it's smarter now;
* locking unsuported characters to aptoncd iso fileaname;
* Hidding Cancel button while reading packages (we doesn't need this anymore, sice it's a faster process);
* Hidding the main window when using parameters (such --download, -i, --restore, etc);
* Moving the way APTonCD handle the destination of .iso images - Closes LP#89320;
* Do not close the window when user hasn't enought right in the destination folder - Closes LP#89325;
* Avoiding the user to select a destination folder that doesn't have writting permissions;
* Do not permit the user to restore an aptoncd media created in a version that differs from your running system;
* Correcting some grammar mistakes, applying Bruce's patch. Closes LP#89733;
* Now old packages in the Create list has a different pango markup to differ from the new ones;
* Changing the window type of frmCreate and frmRestore to show minimize and maximize buttons;
* Fixed bug while cancel the creation of APTonCD copy/iso
* Auto-select dependencies in create actived by default;
* Now we have a README.diskdefines inside the media, to make APT happy;
* Documentation update

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
        self.totalsize = 0
48
48
        self.speed = 0
49
49
        self.totalread = 0
 
50
        self.filecount = 0
 
51
        self.downloadedFiles = 0
50
52
        self.treeline = -1
51
53
        self.DownloadResult = gtk.RESPONSE_NONE
52
54
    
87
89
        self.frmFetchRepo = self.progressgui.get_widget("frmFetchRepo")
88
90
        self.frmFetchRepo.set_position(gtk.WIN_POS_CENTER)
89
91
        self.frmFetchRepo.set_modal(True)
90
 
        self.frmFetchRepo.show()
 
92
        
91
93
        self.frmFetchRepo.connect("delete-event", self.close_fetchwindow)
92
94
        
93
95
        self.labeltotalsize = self.progressgui.get_widget("lblTotalSize")
94
96
        self.labeltotalsize.set_text(utils.fileSizeFormat(self.totalsize))
95
 
        
 
97
            
96
98
        self.labelnumfiles = self.progressgui.get_widget("lblNumberFiles")
97
 
        self.labelnumfiles.set_text(str(len(self.PackFiles)))
 
99
        self.labelnumfiles.set_text( str(self.downloadedFiles) + '/' + str(self.filecount) )
98
100
        
99
101
        self.labelestimatedtime = self.progressgui.get_widget("lblEstimatedTime")
100
102
        self.labelestimatedtime.set_text(str("%0.2f" % (self.totaltime))) 
140
142
        self.treeprogress.append_column(column1)
141
143
        self.treeprogress.append_column(column2)
142
144
        self.treeprogress.append_column(column3)
 
145
        
 
146
        self.frmFetchRepo.show()
143
147
 
144
148
    def close_fetchwindow(self, widget, data = None):
145
149
        self.DownloadResult = gtk.RESPONSE_CANCEL
214
218
            #self.labelsection.set_text(nfiles[download.SECTION])
215
219
            self.mgrade.append([nfiles[download.PACKAGE] , utils.fileSizeFormat(nfiles[download.SIZE]) , 0])
216
220
            self.treeline+= 1
 
221
            self.labelnumfiles.set_text('%s/%s' % (self.treeline + 1 ,self.filecount))
217
222
            self.scrollToPath(self.treeline)
218
223
            
219
224
            mainPath = os.path.join(self.conf[xmlfile.PATH],self.conf[xmlfile.DISTRIBUTION],  nfiles[download.REMOTEFILEPATH])
221
226
            utils.mkdir(mainPath)
222
227
            
223
228
            filePath = os.path.join(mainPath,nfiles[download.DEBFILENAME] )
224
 
    
 
229
 
225
230
            if not utils.fileExist(filePath):
226
231
                remotePath = self.conf[xmlfile.METHOD] + '://' + self.conf[xmlfile.HOST] + '/' + self.conf[xmlfile.DISTRIBUTION]  + '/' + nfiles[download.FILENAME]
227
232
                self.Packages = download.Download(remotePath, mainPath)
228
233
                self.Packages.connect('download_status',self.on_downloadStatus)
229
234
                self.Packages.download(True)
 
235
                self.downloadedFiles += 1
230
236
            else:
231
237
                fraction = float((100 * float(nfiles[download.SIZE])) / self.totalsize)
232
238
                self.on_downloadStatus(self.frmFetchRepo, nfiles[download.SIZE],float(nfiles[download.SIZE]), float(nfiles[download.SIZE]), float(fraction))
297
303
        for tar in validTars:
298
304
            s = parsegz.openGZ(tar[1] + '/Packages.gz'  )
299
305
            self.PackFiles.extend(parsegz.ParseFile(s).Parse())
300
 
            
 
306
         
 
307
        self.filecount = str(len(self.PackFiles))
 
308
        
301
309
        for nfiles in self.PackFiles:
302
310
            if nfiles[3] != '':
303
311
                self.totalsize+= float(nfiles[3])
306
314
        if self.DownloadResult != gtk.RESPONSE_CANCEL:
307
315
            self.show_progress()
308
316
            self.donwload_files()
 
317
           
309
318
        self.frmFetchRepo.hide()
310
 
     
311
 
        self.DownloadResult = gtk.RESPONSE_OK
312
319
 
313
320
        if self.DownloadResult != gtk.RESPONSE_CANCEL:
314
321
            if self.conf[xmlfile.MEDIA] == 'DVD':
352
359
                   pkgzdir = "dists/%s/%s/binary-%s/" % ( self.conf[xmlfile.VERSION],sec,self.conf[xmlfile.ARCHITECTURE])   
353
360
                   if utils.pathExists(os.path.join(mediadir,pkgzdir)):
354
361
                       os.system('apt-ftparchive packages  pool/ > ' + pkgzdir + 'Packages')
355
 
                       #make a .gz file
 
362
                       #make a .gz file
356
363
                       PackagesFile = os.path.join(mediadir,pkgzdir +'Packages')
357
364
                       fileObj = gzip.GzipFile(PackagesFile + '.gz', 'wb');
358
365
                       fileObj.write(file(PackagesFile, 'rb').read())
359
 
                       fileObj.close()
360
 
                       utils.compress(PackagesFile, PackagesFile)
 
366
                       fileObj.close()
 
367
                       utils.compress(PackagesFile, PackagesFile)
361
368
                       
362
 
                       os.system('apt-ftparchive release  dists/' + self.conf[xmlfile.VERSION] + ' > dists/' + self.conf[xmlfile.VERSION] + '/Release')
363
 
                       
364
 
                       cds[medianame].append(sec)
365
 
 
 
369
                       os.system('apt-ftparchive release  dists/' + self.conf[xmlfile.VERSION] + ' > dists/' + self.conf[xmlfile.VERSION] + '/Release')
 
370
                       
 
371
                       cds[medianame].append(sec)
 
372
 
366
373
                os.system('ln -s . ' + self.conf[xmlfile.DISTRIBUTION])
367
374
                os.chdir(curdir)
368
375
            
376
383
                isoname = self.conf[xmlfile.DISTRIBUTION] + '-' + self.conf[xmlfile.VERSION] + '-' 
377
384
                isoname += section + '-' + self.conf[xmlfile.ARCHITECTURE] +'-' + x
378
385
                os.system('mkisofs -quiet -iso-level 4 -pad -l -r -J -joliet-long -v -V "aptoncd-'+ x  +'" -hide-rr-moved -o ' + os.path.join(config.WORK_DIR ,isoname +'.iso') + ' ' + mediadir + ' 2> /dev/null')
379
 
            
380
 
            utils.removePath(os.path.join(config.WORK_DIR,'repository'))    
381
 
            self.wProgress.destroy()
 
386
        
 
387
        self.wProgress.destroy()
 
388
        
 
389
        if self.DownloadResult != gtk.RESPONSE_CANCEL :
 
390
            checked = MessageBox().ShowFinished(self.gladeFile, config.WORK_DIR )  
 
391
        else:
 
392
            checked = False
 
393
 
 
394
        if checked and self.DownloadResult != gtk.RESPONSE_CANCEL :
 
395
            utils.removePath(os.path.join(config.WORK_DIR,'repository'))
 
396
            utils.removePath(self.conf[xmlfile.PATH])
 
397
        
382
398
        #the comment below must be removed when code is ok
383
399
        #self.close_fetchwindow(self)