~ubuntu-branches/ubuntu/saucy/aptoncd/saucy-proposed

« back to all changes in this revision

Viewing changes to restorefiles.py

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2009-08-17 22:04:26 UTC
  • mfrom: (1.1.1 upstream) (0.1.11 jaunty)
  • Revision ID: james.westby@ubuntu.com-20090817220426-bhxr3a21ff6y8edm
Tags: 0.1.98+bzr109-0.1
* Non-maintainer upload
* New upstream release (Closes: #452205, #423480, #433915, #541047, #427003,
  #493647, #484636)
* debian/control: 
  - Changed python build dependencies to Build-Depends-Indep
  - Moved url from Description to Homepage
  - Changed Standards-Version to 3.8.2
  - Changed Maintainer to myself
  - Deleted dependency on deprecated mkisofs 
  - Deleted recommend of nautilus-cd-burner
* debian/copyright: Changed (C) to © to make lintian happy
* debian/rules: 
  - deleted deprecated dh_desktop
  - added get-orig-source target to get the latest source from lp
* data/aptoncd.desktop.in: Fixed error and deprecated values in Desktop file

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
#   thanks to Dave Arter <davea@sucs.org>
 
3
#   Copyright (c) 2005 Dave Arter
 
4
 
 
5
import os
 
6
import sys
 
7
import gtk
 
8
 
 
9
from APTonCD.core.utils import get_icon
 
10
from APTonCD.core import utils
 
11
from APTonCD.widgets.progresswindow import ProgressDialog
 
12
from APTonCD.core.gui import processEvents
 
13
from APTonCD.core import constants
 
14
 
 
15
class Files:
 
16
    
 
17
    def __init__(self, Source = None, Destination = None):
 
18
        self.source = Source
 
19
        self.destination = Destination
 
20
        
 
21
    def set_source(self, filename): self.source = filename
 
22
    def get_source(self): return self.source
 
23
    Source = property(fget = get_source, fset = set_source)
 
24
    
 
25
    def set_destination(self, filename): self.destination = filename
 
26
    def get_destination(self): return self.destination
 
27
    Destination = property(fget = get_destination, fset = set_destination)
 
28
    
 
29
    
 
30
class RestoreFiles:
 
31
 
 
32
    def __init__(self,xid = None, script_location = None ):
 
33
        
 
34
        self.files = []
 
35
        self.window_by_id = gtk.gdk.window_foreign_new(int(xid))
 
36
        self.script = script_location
 
37
        self.process_files()
 
38
        self.progress = ProgressDialog(self.window_by_id)
 
39
        self.progress.can_cancel_progress = False
 
40
        self.progress.title = constants.MESSAGE_0073
 
41
        self.progress.description = constants.MESSAGE_0074
 
42
        self.progress.stop = len(self.files)
 
43
        self.progress.show()
 
44
        self.restore_files()
 
45
        self.progress.destroy()
 
46
        
 
47
    def process_files(self):
 
48
        ifile = open(self.script,'r')
 
49
 
 
50
        for n in ifile.readlines():
 
51
            copy_list = n.split('|')
 
52
            self.files.append(Files(copy_list[0],copy_list[1]))
 
53
        
 
54
    def restore_files(self):
 
55
        index = 0
 
56
        for n in self.files:
 
57
            self.progress.update_progress(index + 1)
 
58
            os.system('cp %s %s' % (n.Source, n.Destination))
 
59
            index += 1
 
60
            processEvents()
 
61
 
 
62
if __name__ == '__main__':
 
63
    
 
64
    restore = RestoreFiles(sys.argv[1], sys.argv[2])
 
65
    sys.exit(1)