[Uludag-commits] r15324 - in trunk/staj-projeleri/migration: . migration migration/gui migration/utility po

uludag-commits at pardus.org.tr uludag-commits at pardus.org.tr
5 Eyl 2007 Çar 17:20:41 EEST


Author: muratongan
Date: Wed Sep  5 17:20:40 2007
New Revision: 15324

Modified:
   trunk/staj-projeleri/migration/TODO
   trunk/staj-projeleri/migration/migration/applythread.py
   trunk/staj-projeleri/migration/migration/gui/optionspage.py
   trunk/staj-projeleri/migration/migration/gui/progresspage.py
   trunk/staj-projeleri/migration/migration/gui/userpage.py
   trunk/staj-projeleri/migration/migration/utility/account.py
   trunk/staj-projeleri/migration/migration/utility/bookmark.py
   trunk/staj-projeleri/migration/migration/wizard.py
   trunk/staj-projeleri/migration/po/migration.pot
   trunk/staj-projeleri/migration/po/tr.po
   trunk/staj-projeleri/migration/setup.py
Log:
Copy E-Mail Messages
Rewrite Progress Page and Apply Thread
Feature Freeze



Modified: trunk/staj-projeleri/migration/TODO
=================================================================
--- trunk/staj-projeleri/migration/TODO	(original)
+++ trunk/staj-projeleri/migration/TODO	Wed Sep  5 17:20:40 2007
@@ -10,7 +10,11 @@
     ? migrate identities to kmail
     + Find a way to migrate e-mails (copy mbox file, use python mailbox module, use kmail dcop interface) -> get messages by hand and add them with dcop
     + Check SMTP Authentication Type (Thunderbird, OE, KMail)
-    - Find a pretty application name :)
+    + Copy e-mail messages
+    - Make package (where should i put archive file?)
+    - Remove bugs
+    - Update help file
+    - Find an application name and logo
 
 General:
     + User help pages
@@ -27,7 +31,10 @@
 
 Possible New Modules:
     + IM Accounts
-    / E-Mail Accounts, Address Book, Messages, Filters
+    + E-Mail Accounts
+    + E-Mail Messages
+    - E-Mail Filters
+    - Address Books
     - RSS Feeds
     - Opera and Konqueror support with kbookmarks
     - Browser history, cookies and settings

Modified: trunk/staj-projeleri/migration/migration/applythread.py
=================================================================
Suppressed!
	Too long (more than 250 lines) diff output suppressed...
Modified: trunk/staj-projeleri/migration/migration/gui/optionspage.py
=================================================================
--- trunk/staj-projeleri/migration/migration/gui/optionspage.py	(original)
+++ trunk/staj-projeleri/migration/migration/gui/optionspage.py	Wed Sep  5 17:20:40 2007
@@ -83,37 +83,49 @@
                 self.IEBookmarks.setText(i18n("Internet Explorer favorites"))
                 self.IEBookmarks.setChecked(True)
                 self.BookmarksLayout.addWidget(self.IEBookmarks)
-        # Accounts:
-        if sources.has_key("Windows Mail Path") or sources.has_key("Thunderbird Profile Path") or sources.has_key("Contacts Path") or sources.has_key("GTalk Key"):
-            self.Accounts = QGroupBox(self, "Accounts")
-            self.Accounts.setTitle(i18n("Accounts"))
-            self.Accounts.setColumnLayout(0, Qt.Vertical)
-            self.AccountsLayout = QVBoxLayout(self.Accounts.layout())
-            self.lay.addWidget(self.Accounts)
+        # Mail Accounts:
+        if sources.has_key("Windows Mail Path") or sources.has_key("Thunderbird Profile Path"):
+            self.MailAccounts = QGroupBox(self, "MailAccounts")
+            self.MailAccounts.setTitle(i18n("E-Mail and News Accounts"))
+            self.MailAccounts.setColumnLayout(0, Qt.Vertical)
+            self.MailAccountsLayout = QVBoxLayout(self.MailAccounts.layout())
+            self.lay.addWidget(self.MailAccounts)
             # Windows Mail Accounts:
             if sources.has_key("Windows Mail Path"):
-                self.WinMail = QCheckBox(self.Accounts, "WinMail")
-                self.WinMail.setText(i18n("Windows Mail Accounts"))
+                self.WinMail = QCheckBox(self.MailAccounts, "WinMail")
+                self.WinMail.setText(i18n("Windows Mail accounts"))
                 self.WinMail.setChecked(True)
-                self.AccountsLayout.addWidget(self.WinMail)
+                self.MailAccountsLayout.addWidget(self.WinMail)
             # Thunderbird Accounts:
             if sources.has_key("Thunderbird Profile Path"):
-                self.TB = QCheckBox(self.Accounts, "TB")
-                self.TB.setText(i18n("Thunderbird Accounts"))
+                self.TB = QCheckBox(self.MailAccounts, "TB")
+                self.TB.setText(i18n("Thunderbird accounts"))
                 self.TB.setChecked(True)
-                self.AccountsLayout.addWidget(self.TB)
+                self.MailAccountsLayout.addWidget(self.TB)
+            # E-Mails:
+            self.mail = QCheckBox(self.MailAccounts, "mail")
+            self.mail.setText(i18n("Copy e-mail messages from e-mail accounts"))
+            self.mail.setChecked(True)
+            self.MailAccountsLayout.addWidget(self.mail)
+        # IM Accounts:
+        if sources.has_key("Contacts Path") or sources.has_key("GTalk Key"):
+            self.IMAccounts = QGroupBox(self, "IMAccounts")
+            self.IMAccounts.setTitle(i18n("Instant Messenger Accounts"))
+            self.IMAccounts.setColumnLayout(0, Qt.Vertical)
+            self.IMAccountsLayout = QVBoxLayout(self.IMAccounts.layout())
+            self.lay.addWidget(self.IMAccounts)
             # MSN Accounts:
             if sources.has_key("Contacts Path"):
-                self.MSN = QCheckBox(self.Accounts, "MSN")
-                self.MSN.setText(i18n("MSN Accounts"))
+                self.MSN = QCheckBox(self.IMAccounts, "MSN")
+                self.MSN.setText(i18n("MSN accounts"))
                 self.MSN.setChecked(True)
-                self.AccountsLayout.addWidget(self.MSN)
+                self.IMAccountsLayout.addWidget(self.MSN)
             # GTalk Accounts:
             if sources.has_key("GTalk Key"):
-                self.GTalk = QCheckBox(self.Accounts, "GTalk")
-                self.GTalk.setText(i18n("GTalk Accounts"))
+                self.GTalk = QCheckBox(self.IMAccounts, "GTalk")
+                self.GTalk.setText(i18n("GTalk accounts"))
                 self.GTalk.setChecked(True)
-                self.AccountsLayout.addWidget(self.GTalk)
+                self.IMAccountsLayout.addWidget(self.GTalk)
         # Spacer:
         spacer = QSpacerItem(1,1,QSizePolicy.Minimum,QSizePolicy.Expanding)
         self.lay.addItem(spacer)
@@ -121,6 +133,7 @@
     def getOptions(self):
         "Returns a dictionary consists of selected options"
         options = {}
+        self.sources["Copy E-Mails"] = True
         # Add fundamental items:
         for item in ["Partition", "OS Type", "User Name", "Home Path"]:
             options[item] = self.sources[item]
@@ -128,9 +141,10 @@
         items = [("IEBookmarks", "Favorites Path"),
                  ("FFBookmarks", "Firefox Profile Path"),
                  ("oldRadio", "Wallpaper Path"),
-                 ("GTalk", "GTalk Key"),
                  ("WinMail", "Windows Mail Path"),
                  ("TB", "Thunderbird Profile Path"),
+                 ("mail", "Copy E-Mails"),
+                 ("GTalk", "GTalk Key"),
                  ("MSN", "Contacts Path")]
         for widgetname, dictname in items:
             item = self.child(widgetname)

Modified: trunk/staj-projeleri/migration/migration/gui/progresspage.py
=================================================================
--- trunk/staj-projeleri/migration/migration/gui/progresspage.py	(original)
+++ trunk/staj-projeleri/migration/migration/gui/progresspage.py	Wed Sep  5 17:20:40 2007
@@ -19,70 +19,99 @@
     OK, WARNING, ERROR = xrange(3)
     def __init__(self, parent):
         QWidget.__init__(self, parent)
-        self.lay = QVBoxLayout(self, 11, 6, "lay")
-        
+        lay = QVBoxLayout(self, 11, 6, "lay")
+        # Top Label:
         self.label = QLabel(self, "label")
         self.label.setText(i18n("Please wait while applying changes..."))
         self.label.setAlignment(self.label.alignment() | Qt.WordBreak)
-        self.lay.addWidget(self.label)
-        
-        self.progress = 0
-        self.steps = 0
-        self.progressbar = QProgressBar(self)
-        self.progressbar.setProgress(0)
-        self.lay.addWidget(self.progressbar)
-        
-        #self.progresslist = QListBox(self)
-        #self.lay.addWidget(self.progresslist)
-        #self.progresslist.setSelectionMode(QListBox.NoSelection)
-        
+        lay.addWidget(self.label)
+        # Progress Bar Grid Layout:
+        progresslay = QGridLayout(None, 1, 1, 15, 5, "progresslay")
+        lay.addLayout(progresslay)
+        # Progress 1:
+        self.label1 = QLabel(self, "label1")
+        self.label1.setText(i18n("Prepare: "))
+        progresslay.addWidget(self.label1, 0, 0)
+        self.progressbar1 = QProgressBar(self, "progressbar1")
+        progresslay.addWidget(self.progressbar1, 0, 1)
+        # Progress 2:
+        self.label2 = QLabel(self, "label2")
+        self.label2.setText(i18n("Apply: "))
+        progresslay.addWidget(self.label2, 1, 0)
+        self.progressbar2 = QProgressBar(self, "progressbar2")
+        progresslay.addWidget(self.progressbar2, 1, 1)
+        ## Status Label:
+        #self.statuslabel = QLabel(self, "statuslabel")
+        #self.statuslabel.setText(i18n("Status: "))
+        #self.statuslabel.setAlignment(self.label.alignment() | Qt.WordBreak)
+        #lay.addWidget(self.statuslabel)
+        # Operation Lines:
+        self.oplines = QVBoxLayout(None, 0, 0, "oplines")
+        lay.addLayout(self.oplines)
+        # Spacer:
+        spacer = QSpacerItem(5, 5, QSizePolicy.Minimum, QSizePolicy.Expanding)
+        lay.addItem(spacer)
+        # Progress Variables:
+        self.steps1 = 0
+        self.steps2 = 0
+        self.progress1 = 0
+        self.progress2 = 0
+        self.active = 0
         self.operations = []
-        self.warning = False
-        self.log = []
-        self.active = -1
-        self.oplay = QVBoxLayout(None)
-        self.lay.addLayout(self.oplay)
-        
-        self.spacer = QSpacerItem(1,1,QSizePolicy.Minimum,QSizePolicy.Expanding)
-        self.lay.addItem(self.spacer)
-        self.log = QTextEdit(self,"log")
-        self.log.setTextFormat(QTextEdit.LogText)
-        self.log.hide()
-        self.lay.addWidget(self.log)
-        self.detailsButton = QCheckBox(i18n("Click here to see details..."), self, "deneme")
-        self.detailsButton.hide()
-        self.lay.addWidget(self.detailsButton)
-        self.connect(self.detailsButton, SIGNAL("toggled(bool)"), self.log, SLOT("setShown(bool)"))
+        self.updateProgress()
+    
+    def updateProgress(self):
+        "Updates status of progress bars"
+        if self.steps1 == 0:
+            self.progressbar1.setProgress(0)
+        else:
+            self.progressbar1.setProgress(100 * self.progress1 / self.steps1)
+        if self.steps2 == 0:
+            self.progressbar2.setProgress(0)
+        else:
+            self.progressbar2.setProgress(100 * self.progress2 / self.steps2)
+    
+    def addProgress(self, number, bar=1):
+        "Adds steps to progress bars"
+        if bar == 1:
+            self.steps1 += number
+        else:
+            self.steps2 += number
+        self.updateProgress()
+    
+    def makeProgress(self, number, bar=1):
+        "Makes progress bar step"
+        if bar == 1:
+            self.progress1 += number
+        else:
+            self.progress2 += number
+        self.updateProgress()
     
     def addOperation(self, name, steps):
-        "adds a new operation to the process page"
+        "Adds a new operation to the progress page"
         op = Operation(self, name, steps)
-        self.oplay.addLayout(op)
+        self.oplines.addLayout(op)
         self.operations.append(op)
-        self.operations[0].start()
-        self.steps += steps
-        self.active = 0
+        self.steps2 += steps
+    
+    def customEvent(self, event):
+        # Show Warning Box:
+        if event.type() == 65456:
+            self.warning = QMessageBox.warning(self, i18n("Warning!"), event.message, QMessageBox.Ok, QMessageBox.Cancel, QMessageBox.NoButton)
     
     def go(self, log, stat, steps):
         "increments progressbar, logs changes and modify icons"
-        self.progress += steps
-        if self.steps:
-            self.progressbar.setProgress(100 * self.progress / self.steps)
-        if stat == ProgressPage.WARNING:
-            self.warning = True
         activeop = self.operations[self.active]
-        if stat == ProgressPage.OK:
-            self.log.append(log)
-        elif stat == ProgressPage.WARNING:
-            self.log.append(unicode(i18n("<b>WARNING: %s</b>")) % log)
-        elif stat == ProgressPage.ERROR:
-            self.log.append(unicode(i18n("<b>ERROR: %s</b>")) % log)
+        if activeop.progress + steps > activeop.steps:
+            self.makeProgress(activeop.steps - activeop.progress, 2)
+        else:
+            self.makeProgress(steps, 2)
         if activeop.go(log, stat, steps):
             self.active += 1
             if self.active < len(self.operations):
                 self.operations[self.active].start()
             else:
-                self.detailsButton.show()
+                self.active -= 1
 
 
 class Operation(QHBoxLayout):
@@ -112,10 +141,16 @@
     def go(self, log, stat, steps):
         self.progress += steps
         if stat == ProgressPage.OK:
+            if log:
+                print i18n("OK:"), log
             self.OKs += 1
         elif stat == ProgressPage.WARNING:
+            if log:
+                print i18n("WARNING:"), log
             self.warnings += 1
         elif stat == ProgressPage.ERROR:
+            if log:
+                print i18n("ERROR:"), log.__class__, "(", log.__doc__, ") :", log
             self.errors += 1
         if self.progress >= self.steps:
             if self.errors > 0:
@@ -124,8 +159,10 @@
                 pix = KGlobal.iconLoader().loadIcon("messagebox_warning", KIcon.Toolbar)
             else:
                 pix = KGlobal.iconLoader().loadIcon("apply", KIcon.Toolbar)
-                #self.detailsButton.setText("deneme")
             self.icon.setPixmap(pix)
             return True
         else:
             return False
+
+
+

Modified: trunk/staj-projeleri/migration/migration/gui/userpage.py
=================================================================
--- trunk/staj-projeleri/migration/migration/gui/userpage.py	(original)
+++ trunk/staj-projeleri/migration/migration/gui/userpage.py	Wed Sep  5 17:20:40 2007
@@ -27,7 +27,7 @@
         lay.addWidget(self.paragraph1)
         # Paragraph 2:
         self.paragraph2 = QLabel(self,"paragraph2")
-        self.paragraph2.setText(i18n("After selecting user, you will be able to copy e-mail accounts, address books, e-mails, instant messenger accounts, bookmarks, cookies, background images and files to Pardus. Please choose the user and click \"next\" to continue..."))
+        self.paragraph2.setText(i18n("After selecting user, you will be able to copy wallpaper, bookmarks, e-mail accounts, e-mail messages, news accounts, instant messenger accounts and files to Pardus. Please choose the user and click \"next\" to continue..."))
         self.paragraph2.setAlignment(QLabel.WordBreak | QLabel.AlignVCenter)
         lay.addWidget(self.paragraph2)
         # Users Box:

Modified: trunk/staj-projeleri/migration/migration/utility/account.py
=================================================================
--- trunk/staj-projeleri/migration/migration/utility/account.py	(original)
+++ trunk/staj-projeleri/migration/migration/utility/account.py	Wed Sep  5 17:20:40 2007
@@ -54,6 +54,8 @@
                 folderpath = os.path.join(path, prefs["mail.server." + realserver + ".directory-rel"].replace("[ProfD]", ""))
                 # Add message boxes in this account:
                 def addFolders(name, path):
+                    if not os.path.isdir(path):
+                        return
                     for itemname in os.listdir(path):
                         itempath = os.path.join(path, itemname)
                         if os.path.splitext(itemname)[1] == ".msf" and os.path.isfile(itempath):
@@ -134,29 +136,6 @@
             if accountdict:
                 self.accounts.append(accountdict)
     
-    def getSize(self):
-        totalsize = 0
-        for (name, path) in self.folders:
-            # is empty folder?
-            if not path:
-                continue
-            # is mbox file?
-            if os.path.isfile(path):
-                totalsize += os.path.getsize(path)
-            elif os.path.isdir(path):
-                # is OE folder?
-                if os.path.isfile(os.path.join(path, "winmail.fol")):
-                    for item in os.listdir(path):
-                        if os.path.splitext(item)[1] == ".eml":
-                            totalsize += os.path.getsize(os.path.join(path, item))
-                # is maildir folder?
-                elif os.path.isdir(os.path.join(path, "new")) and os.path.isdir(os.path.join(path, "cur")):
-                    for item in os.listdir(os.path.join(path, "new")):
-                        totalsize += os.path.getsize(os.path.join(path, "new", item))
-                    for item in os.listdir(os.path.join(path, "new")):
-                        totalsize += os.path.getsize(os.path.join(path, "new", item))
-        return totalsize
-    
     def getMSNAccounts(self, path):
         "Imports MSN accounts using windows users's 'Contacts' directory"
         files = os.listdir(path)
@@ -202,6 +181,7 @@
                             value = getData(dom, fields[key])
                             if value:
                                 accountdict[key] = value
+                        accountdict["inbox"] = os.path.join(accountdict["name"], "Inbox")
                         # Add Account:
                         if accountdict:
                             self.accounts.append(accountdict)
@@ -292,10 +272,20 @@
                 config.writeEntry("login", account["user"])
                 
                 # Set Inbox Folder:
-                #inbox = account.get("inbox", "inbox")
-                #inbox = KMailFolderName(inbox)
-                inbox = "inbox"
-                config.writeEntry("Folder", inbox)
+                inbox = account.get("inbox", "inbox")
+                folder = KMailFolderName(inbox)
+                config.writeEntry("Folder", folder)
+                # Create inbox if not exists:
+                folders = inbox.split("/")
+                for i in xrange(len(folders)):
+                    foldername = "/".join(folders[:(i + 1)])
+                    foldername = KMailFolderName(foldername)
+                    folderpath = os.path.expanduser("~/.kde/share/apps/kmail/mail/" + foldername)
+                    if not os.path.exists(folderpath):
+                        os.makedirs(folderpath)
+                        os.makedirs(os.path.join(folderpath, "cur"))
+                        os.makedirs(os.path.join(folderpath, "new"))
+                        os.makedirs(os.path.join(folderpath, "tmp"))
                 
                 if account.has_key("SSL") and account["SSL"]:
                     config.writeEntry("use-ssl", "true")
@@ -351,46 +341,62 @@
                     config.writeEntry("port", account["port"])
             config.sync()
     
-    def addKMailMessages(self):
+    def addKMailMessages(self, progress=None):
         # Information message:
         infomessagepath = os.path.join(tempfile.gettempdir(), "temp_kmail_info.eml")
         message = "From:pardus at localhost\r\nSubject:%s\r\n\r\n%s" % (i18n("Migrated Folder"), i18n("This messagebox is migrated using Pardus Migration Tool"))
         messagefile = open(infomessagepath, "w")
         messagefile.write(message)
         messagefile.close()
-        # Create a dcop object:
-        client = DCOPClient()
-        if not client.attach():
-            raise Exception, "Message cannot be added"
-        kmail = DCOPObj("kmail", client, "KMailIface")
+        kmail = ConnectKMail()
         # Loop over folders:
         for (name, path) in self.folders[2:]:
-            print name
             # Add Info Message:
             #addMessage(name, infomessagepath, kmail)
             # Chech Message Box Type
             if os.path.isfile(path):
                 # Copy mbox:
                 box = mbox(path)
+                boxsize = os.path.getsize(path)
+                totalsize = 0
                 messagepath = box.next()
                 while messagepath:
                     try:
                         addMessage(name, messagepath, kmail)
-                    except Exception, text:
-                        print "Message '%s' cannot be migrated to '%s'\n  %s" % (messagepath, name, text)
+                    except DuplicateMessage, text:
+                        totalsize += os.path.getsize(messagepath)
+                        progress.go(None, progress.OK, os.path.getsize(messagepath))
+                    except DCOPError, text:
+                        progress.go(text, progress.WARNING, 0)
+                        kmail = ConnectKMail()
+                        continue
+                    except MailError, text:
+                        totalsize += os.path.getsize(messagepath)
+                        progress.go(text, progress.WARNING, os.path.getsize(messagepath))
+                    else:
+                        totalsize += os.path.getsize(messagepath)
+                        progress.go(None, progress.OK, os.path.getsize(messagepath))
                     messagepath = box.next()
-                    #break
+                progress.go(unicode(i18n("Message Box %s copied")) % name, progress.OK, boxsize - totalsize)
             elif os.path.isdir(path) and os.path.isfile(os.path.join(path, "winmail.fol")):
                 # Copy OE messagebox
                 box = oebox(path)
                 messagepath = box.next()
                 while messagepath:
                     try:
-                        print "mail.metu.edu.tr/Inbox", name, name == "mail.metu.edu.tr/Inbox"
                         addMessage(name, messagepath, kmail)
-                    except Exception, text:
-                        print "Message '%s' cannot be migrated to '%s'\n  %s" % (messagepath, name, text)
+                    except DuplicateMessage, text:
+                        progress.go(None, progress.OK, os.path.getsize(messagepath))
+                    except DCOPError, text:
+                        progress.go(text, progress.WARNING, 0)
+                        kmail = ConnectKMail()
+                        continue
+                    except MailError, text:
+                        progress.go(text, progress.WARNING, os.path.getsize(messagepath))
+                    else:
+                        progress.go(None, progress.OK, os.path.getsize(messagepath))
                     messagepath = box.next()
+                progress.go(unicode(i18n("Message Box %s copied")) % name, progress.OK, 0)
 
     
     def setKNodeAccounts(self):
@@ -420,6 +426,40 @@
                     print "%15s : %s" % (key, account[key])
         for folder in self.folders:
             print "%30s : %s" % folder
+    
+    def accountSize(self, accounttypes=None):
+        "Size of accounts"
+        if not accounttypes:
+            return len(self.accounts) * 500
+        else:
+            number = 0
+            for account in self.accounts:
+                if account.get("type", None) in accounttypes:
+                    number += 1
+            return number * 500
+    
+    def mailSize(self):
+        totalsize = 0
+        for (name, path) in self.folders:
+            # is empty folder?
+            if not path:
+                continue
+            # is mbox file?
+            if os.path.isfile(path):
+                totalsize += os.path.getsize(path)
+            elif os.path.isdir(path):
+                # is OE folder?
+                if os.path.isfile(os.path.join(path, "winmail.fol")):
+                    for item in os.listdir(path):
+                        if os.path.splitext(item)[1] == ".eml":
+                            totalsize += os.path.getsize(os.path.join(path, item))
+                # is maildir folder?
+                elif os.path.isdir(os.path.join(path, "new")) and os.path.isdir(os.path.join(path, "cur")):
+                    for item in os.listdir(os.path.join(path, "new")):
+                        totalsize += os.path.getsize(os.path.join(path, "new", item))
+                    for item in os.listdir(os.path.join(path, "new")):
+                        totalsize += os.path.getsize(os.path.join(path, "new", item))
+        return totalsize
 
 
 def parsePrefs(filepath):
@@ -577,6 +617,18 @@
         return messagepath
 
 
+def ConnectKMail():
+    # Run KMail:
+    if not os.system("kmail") == 0:
+        raise Exception, "KMail cannot be started"
+    # Create a dcop object:
+    client = DCOPClient()
+    if not client.attach():
+        raise Exception, "Message cannot be added"
+    kmail = DCOPObj("kmail", client, "KMailIface")
+    return kmail
+
+
 def addMessage(folder, message, kmail=None):
     "Adds a message to kmail with dcop interface"
     if not kmail:
@@ -588,16 +640,27 @@
     # Add Message:
     ok, status = kmail.dcopAddMessage(str(folder), message, "")
     if not ok:
-        raise Exception, "Message cannot be added"
+        raise DCOPError, "Can not connect to kmail with DCOP"
     elif status == -4:
-        raise Exception, "Message cannot be added: duplicate message"
+        raise DuplicateMessage, "Message in %s cannot be added: duplicate message" % folder
     elif status == -2:
-        raise Exception, "Message cannot be added: cannot add message to folder"
+        raise MailError, "Message in %s cannot be added: cannot add message to folder" % folder
     elif status == -1:
-        raise Exception, "Message cannot be added: cannot make folder"
+        raise MailError, "Message in %s cannot be added: cannot make folder" % folder
     elif status == 0:
-        raise Exception, "Message cannot be added: error while adding message"
+        raise MailError, "Message in %s cannot be added: error while adding message" % folder
     elif status != 1:
-        raise Exception, "Message cannot be added, status: %d" % status
-    return True
+        raise MailError, "Message in %s cannot be added, status: %d" % (folder, status)
+    else:
+        return True
+
+
+class DCOPError(Exception):
+    pass
+
+class MailError(Exception):
+    pass
+
+class DuplicateMessage(Exception):
+    pass
 

Modified: trunk/staj-projeleri/migration/migration/utility/bookmark.py
=================================================================
--- trunk/staj-projeleri/migration/migration/utility/bookmark.py	(original)
+++ trunk/staj-projeleri/migration/migration/utility/bookmark.py	Wed Sep  5 17:20:40 2007
@@ -117,6 +117,9 @@
         data = self.document.toprettyxml()
         xmlfile.write(data)
         xmlfile.close()
+    
+    def size(self):
+        return len(self.document.getElementsByTagName("bookmark")) * 200
         
 class FFBookmarkParser(HTMLParser.HTMLParser):
     def __init__(self, document):

Modified: trunk/staj-projeleri/migration/migration/wizard.py
=================================================================
--- trunk/staj-projeleri/migration/migration/wizard.py	(original)
+++ trunk/staj-projeleri/migration/migration/wizard.py	Wed Sep  5 17:20:40 2007
@@ -27,7 +27,7 @@
 
 # Utility Modules
 from utility import partition, info, files
-from applythread import ApplyThread
+import applythread
 
 class MigrationWizard(KWizard):
     "Modified KWizard for migration tool"
@@ -55,7 +55,7 @@
         self.filespage = QWidget(self)
         self.addPage(self.filespage, i18n("Selecting Files"))
         # Progress page:
-        self.progresspage = ProgressPage(self)
+        self.progresspage = QWidget(self)
         self.addPage(self.progresspage, i18n("Applying Changes"))
         # Connections:
         self.connect(self.helpButton(), SIGNAL("clicked()"), self.slotHelp)
@@ -159,47 +159,11 @@
             self.options = self.optionspage.getOptions()
             KWizard.next(self)
         elif self.currentPage() == self.filespage:
-            # Control if firefox is open:
-            KApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
-            if self.options.has_key("Firefox Profile Path") or self.options.has_key("Favorites Path"):
-                lockfile = os.path.join(self.destinations["Firefox Profile Path"], "lock")
-                if os.path.lexists(lockfile):
-                    KApplication.restoreOverrideCursor()
-                    QMessageBox.warning(self, i18n("Warning!"), i18n("Firefox is open. Please close it first to continue..."),
-                                        QMessageBox.Ok, QMessageBox.NoButton, QMessageBox.NoButton)
-                    return
-            # Control files:
-            self.options.update(self.filespage.getOptions())
-            if self.options.has_key("folders"):
-                # Existance of directory:
-                if not os.path.isdir(self.options["copy destination"]):
-                    try:
-                        os.makedirs(self.options["copy destination"])
-                    except:
-                        KApplication.restoreOverrideCursor()
-                        QMessageBox.warning(self, i18n("Warning!"), unicode(i18n("Folder '%s' cannot be created, please choose another folder!")) % self.options["copy destination"], QMessageBox.Ok, QMessageBox.NoButton, QMessageBox.NoButton)
-                        return
-                # Write access:
-                if not os.access(self.options["copy destination"], os.W_OK):
-                    KApplication.restoreOverrideCursor()
-                    QMessageBox.warning(self, i18n("Warning!"), unicode(i18n("You don't have permission to write to folder '%s', please choose another folder!")) % self.options["copy destination"], QMessageBox.Ok, QMessageBox.NoButton, QMessageBox.NoButton)
-                    return
-                # File size:
-                totalsize = 0
-                for folder in self.options["folders"]:
-                    size = files.totalSize(folder["files"])
-                    folder["size"] = size
-                    totalsize += size
-                if totalsize:
-                    free = files.freeSpace(self.options["copy destination"])
-                    if totalsize >= free:
-                        KApplication.restoreOverrideCursor()
-                        arguments = {"size":totalsize / 1024 / 1024, "free":free / 1024 / 1024}
-                        QMessageBox.warning(self, i18n("Warning!"), unicode(i18n("Total size of files you've chosen is %(size)d MB, but you have only %(free)d MB of free space!")) % arguments, QMessageBox.Ok, QMessageBox.NoButton, QMessageBox.NoButton)
-                        return
-            KApplication.restoreOverrideCursor()
+            # Update old progress page with the new one:
+            self.removePage(self.progresspage)
+            self.progresspage = ProgressPage(self)
+            self.insertPage(self.progresspage, i18n("Applying Changes"), 3)
             # Apply:
-            self.applythread = ApplyThread(self)
-            thread.start_new_thread(self.applythread.run, ())
             self.setBackEnabled(self.progresspage, False)
+            thread.start_new_thread(applythread.run, (self,))
             KWizard.next(self)

Modified: trunk/staj-projeleri/migration/po/migration.pot
=================================================================
Suppressed!
	Too long (more than 250 lines) diff output suppressed...
Modified: trunk/staj-projeleri/migration/po/tr.po
=================================================================
Suppressed!
	Too long (more than 250 lines) diff output suppressed...
Modified: trunk/staj-projeleri/migration/setup.py
=================================================================
--- trunk/staj-projeleri/migration/setup.py	(original)
+++ trunk/staj-projeleri/migration/setup.py	Wed Sep  5 17:20:40 2007
@@ -15,27 +15,34 @@
 import shutil
 import kdedistutils
 
-version = "0.5"
+version = "1.0_alpha"
 
 distfiles = """
     README
     AUTHORS
     COPYING
-    *.py
-    migration/gui/*.ui
+    migration/migration.png
+    migration/*.py
     migration/gui/*.py
     migration/utility/*.py
-    migration/*.py
-    migration/migration.png
+    help/help.css
+    help/*/main_help.html
     po/*.po
     po/*.pot
 """
 
+app_data = [
+("migration", ["migration/migration.py", "migration/wizard.py", "migration/applythread.py", "migration/migration.png"]),
+("migration/gui", ["migration/gui/__init__.py", "migration/gui/dirview.py", "migration/gui/filespage.py", "migration/gui/help.py", "migration/gui/optionspage.py", "migration/gui/progresspage.py", "migration/gui/sidebar.py", "migration/gui/userpage.py"]),
+("migration/utility", ["migration/utility/__init__.py", "migration/utility/account.py", "migration/utility/bookmark.py", "migration/utility/files.py", "migration/utility/info.py", "migration/utility/partition.py", "migration/utility/registry.py", "migration/utility/wall.py", "migration/utility/wall.py"]),
+("help", ["help/help.css"]), ("help/tr", ["help/tr/main_help.html"])
+]
+
 def make_dist():
     distdir = "migration-%s" % version
     files = []
     for item in distfiles.split():
-        files.extend(glob.glob(t))
+        files.extend(glob.glob(item))
     if os.path.exists(distdir):
         shutil.rmtree(distdir)
     os.mkdir(distdir)
@@ -64,7 +71,7 @@
     min_qt_version = "3.3.5",
     license = "GPL",
     package_dir = {"":""},
-    application_data = [("migration", ["migration/migration.py", "migration/wizard.py", "migration/applythread.py", "migration/migration.png"]), ("migration/gui", ["migration/gui/__init__.py", "migration/gui/dirview.py", "migration/gui/filespage.py", "migration/gui/help.py", "migration/gui/optionspage.py", "migration/gui/progresspage.py", "migration/gui/sidebar.py", "migration/gui/userpage.py"]), ("migration/utility", ["migration/utility/__init__.py", "migration/utility/account.py", "migration/utility/bookmark.py", "migration/utility/files.py", "migration/utility/info.py", "migration/utility/partition.py", "migration/utility/registry.py", "migration/utility/wall.py", "migration/utility/wall.py"]), ("help", ["help"])],
+    application_data = app_data,
     executable_links = [("migration", "migration/migration.py")],
     i18n = ("po", ["migration", "migration/gui", "migration/utility"])
 )


Uludag-commits mesaj listesiyle ilgili daha fazla bilgi