4 commits - liveusb/creator.py liveusb/gui.py liveusb/__init__.py po/liveusb-creator.pot po/POTFILES.in

Luke Macken lmacken at fedoraproject.org
Wed Aug 27 16:34:11 UTC 2008


 liveusb/__init__.py    |    9 +-
 liveusb/creator.py     |   58 +++++++-------
 liveusb/gui.py         |   70 ++++++++---------
 po/POTFILES.in         |    3 
 po/liveusb-creator.pot |  200 +++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 275 insertions(+), 65 deletions(-)

New commits:
commit b2b0abe2f137095f8244f0b5e9eaa17c804cb533
Author: Luke Macken <lmacken at redhat.com>
Date:   Wed Aug 27 09:38:48 2008 -0400

    Add our liveusb-creator.pot file

diff --git a/po/liveusb-creator.pot b/po/liveusb-creator.pot
new file mode 100644
index 0000000..2b57bdd
--- /dev/null
+++ b/po/liveusb-creator.pot
@@ -0,0 +1,200 @@
+# liveusb-creator.
+# Copyright (C) 2008  Red Hat, Inc.
+# This file is distributed under the same license as the liveusb-creator package.
+# Luke Macken <lmacken at redhat.com>, 2008.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: liveusb-creator 2.7\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2008-08-27 09:34-0400\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+"Language-Team: LANGUAGE <LL at li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../liveusb/gui.py:69
+#, python-format
+msgid "Unknown release: %s"
+msgstr ""
+
+#: ../liveusb/gui.py:73
+#, python-format
+msgid "Downloading %s..."
+msgstr ""
+
+#: ../liveusb/gui.py:152
+msgid "Verifying filesystem..."
+msgstr ""
+
+#: ../liveusb/gui.py:155
+msgid ""
+"Error: Cannot set the label or obtain the UUID of your device.  Unable to "
+"continue."
+msgstr ""
+
+#: ../liveusb/gui.py:164
+msgid "Verifying SHA1 of LiveCD image..."
+msgstr ""
+
+#: ../liveusb/gui.py:166
+msgid ""
+"Error: The SHA1 of your Live CD is invalid.  You can run this program with "
+"the --noverify argument to bypass this verification check."
+msgstr ""
+
+#: ../liveusb/gui.py:177
+msgid "Extracting live image to USB device..."
+msgstr ""
+
+#: ../liveusb/gui.py:180
+#, python-format
+msgid "Creating %d Mb persistent overlay..."
+msgstr ""
+
+#: ../liveusb/gui.py:183
+msgid "Configuring and installing bootloader..."
+msgstr ""
+
+#: ../liveusb/gui.py:187
+#, python-format
+msgid "Complete! (%s)"
+msgstr ""
+
+#: ../liveusb/gui.py:190 ../liveusb/gui.py:193
+msgid "LiveUSB creation failed!"
+msgstr ""
+
+#: ../liveusb/gui.py:316
+#, python-format
+msgid "Persistent Storage (%d Mb)"
+msgstr ""
+
+#: ../liveusb/gui.py:334
+msgid ""
+"Your device already contains a LiveOS.\n"
+"If you continue, this will be overwritten."
+msgstr ""
+
+#: ../liveusb/gui.py:337
+msgid ""
+"Warning: Creating a new persistent overlay will delete your existing one."
+msgstr ""
+
+#: ../liveusb/gui.py:339
+msgid "Press 'Create Live USB' again if you wish to continue."
+msgstr ""
+
+#. The user has confirmed that they wish to overwrite their
+#. existing Live OS.  Here we delete it first, in order to
+#. accurately calculate progress.
+#: ../liveusb/gui.py:349
+msgid "Removing existing Live OS..."
+msgstr ""
+
+#: ../liveusb/gui.py:383
+msgid "Download complete!"
+msgstr ""
+
+#: ../liveusb/gui.py:387
+msgid "Download failed: "
+msgstr ""
+
+#: ../liveusb/gui.py:388
+msgid "You can try again to resume your download"
+msgstr ""
+
+#: ../liveusb/gui.py:392
+msgid "Select Live ISO"
+msgstr ""
+
+#: ../liveusb/gui.py:399
+msgid ""
+"Sorry, I'm having trouble encoding the filename of your livecd.  You may "
+"have better luck if you move your ISO to the root of your drive (ie: C:\\)"
+msgstr ""
+
+#: ../liveusb/gui.py:404
+#, python-format
+msgid "ISO selected: %s"
+msgstr ""
+
+#: ../liveusb/creator.py:146
+#, python-format
+msgid ""
+"There was a problem executing the following command: `%s`\n"
+"A more detailed error log has been written to 'liveusb-creator.log'"
+msgstr ""
+
+#: ../liveusb/creator.py:183
+msgid "Not enough free space on device."
+msgstr ""
+
+#: ../liveusb/creator.py:190
+#, python-format
+msgid "Creating %sMB persistent overlay"
+msgstr ""
+
+#: ../liveusb/creator.py:226
+#, python-format
+msgid "Unable to remove previous LiveOS: %s"
+msgstr ""
+
+#: ../liveusb/creator.py:257
+#, python-format
+msgid "Cannot find device %s"
+msgstr ""
+
+#: ../liveusb/creator.py:306
+msgid "Unable to find any USB drives"
+msgstr ""
+
+#: ../liveusb/creator.py:327
+#, python-format
+msgid "Filesystem for %s unknown!"
+msgstr ""
+
+#: ../liveusb/creator.py:335
+#, python-format
+msgid "Unable to mount device: %s"
+msgstr ""
+
+#: ../liveusb/creator.py:370
+#, python-format
+msgid "Unknown filesystem for %s.  Your device may need to be reformatted."
+msgstr ""
+
+#: ../liveusb/creator.py:373
+#, python-format
+msgid "Unsupported filesystem: %s"
+msgstr ""
+
+#: ../liveusb/creator.py:400
+msgid "Unable to find LiveOS on ISO"
+msgstr ""
+
+#: ../liveusb/creator.py:472
+msgid "Unable to find any removable devices"
+msgstr ""
+
+#: ../liveusb/creator.py:479
+msgid ""
+"Make sure your USB key is plugged in and formatted with the FAT filesystem"
+msgstr ""
+
+#: ../liveusb/creator.py:482
+#, python-format
+msgid ""
+"Unsupported filesystem: %s\n"
+"Please backup and format your USB key with the FAT filesystem."
+msgstr ""
+
+#: ../liveusb/creator.py:558
+#, python-format
+msgid ""
+"Cannot find '%s'.  Make sure to extract the entire liveusb-creator zip file "
+"before running this program."
+msgstr ""


commit c622a3c5b0ca80991147e572fe110829c79751b5
Author: Luke Macken <lmacken at redhat.com>
Date:   Wed Aug 27 09:33:10 2008 -0400

    Make our strings translatable

diff --git a/liveusb/creator.py b/liveusb/creator.py
index 1507825..eacf06f 100755
--- a/liveusb/creator.py
+++ b/liveusb/creator.py
@@ -37,6 +37,7 @@ from StringIO import StringIO
 from stat import ST_SIZE
 
 from liveusb.releases import releases
+from liveusb import _
 
 
 class LiveUSBError(Exception):
@@ -142,9 +143,9 @@ class LiveUSBCreator(object):
         self.output.write(out + '\n' + err + '\n')
         if proc.returncode:
             self.write_log()
-            raise LiveUSBError("There was a problem executing the following "
-                               "command: `%s`\nA more detailed error log has "
-                               "been written to 'liveusb-creator.log'" % cmd)
+            raise LiveUSBError(_("There was a problem executing the following "
+                                 "command: `%s`\nA more detailed error log has "
+                                 "been written to 'liveusb-creator.log'" % cmd))
         return proc
 
     def verify_image(self, progress=None):
@@ -179,14 +180,14 @@ class LiveUSBCreator(object):
         self.log.debug('overlaysize = %d' % overlaysize)
         self.totalsize = overlaysize + self.isosize
         if self.totalsize > freebytes:
-            raise LiveUSBError("Not enough free space on device.\n"
-                               "%dMB ISO + %dMB overlay > %dMB free space" % 
-                               (self.isosize/1024**2, self.overlay,
-                                freebytes/1024**2))
+            raise LiveUSBError(_("Not enough free space on device." + 
+                                 "\n%dMB ISO + %dMB overlay > %dMB free space" %
+                                 (self.isosize/1024**2, self.overlay,
+                                  freebytes/1024**2)))
 
     def create_persistent_overlay(self):
         if self.overlay:
-            self.log.info("Creating %sMB persistent overlay" % self.overlay)
+            self.log.info(_("Creating %sMB persistent overlay" % self.overlay))
             if self.fstype == 'vfat':
                 # vfat apparently can't handle sparse files
                 self.popen('dd if=/dev/zero of=%s count=%d bs=1M'
@@ -222,8 +223,8 @@ class LiveUSBCreator(object):
                 try:
                     shutil.rmtree(path)
                 except OSError, e:
-                    raise LiveUSBError("Unable to remove previous LiveOS: %s" %
-                                       str(e))
+                    raise LiveUSBError(_("Unable to remove previous LiveOS: "
+                                         "%s" % str(e)))
 
     def write_log(self):
         """ Write out our subprocess stdout/stderr to a log file """
@@ -253,7 +254,7 @@ class LiveUSBCreator(object):
 
     def _set_drive(self, drive):
         if not self.drives.has_key(drive):
-            raise LiveUSBError("Cannot find device %s" % drive)
+            raise LiveUSBError(_("Cannot find device %s" % drive))
         self.log.debug("%s selected: %s" % (drive, self.drives[drive]))
         self._drive = drive
         self.uuid = self.drives[drive]['uuid']
@@ -302,7 +303,7 @@ class LinuxLiveUSBCreator(LiveUSBCreator):
                             break
 
         if not len(self.drives):
-            raise LiveUSBError("Unable to find any USB drives")
+            raise LiveUSBError(_("Unable to find any USB drives"))
 
     def _add_device(self, dev):
         mount = str(dev.GetProperty('volume.mount_point'))
@@ -323,15 +324,15 @@ class LinuxLiveUSBCreator(LiveUSBCreator):
         self.dest = self.drive['mount']
         if not self.dest:
             if not self.fstype:
-                raise LiveUSBError("Filesystem for %s unknown!" % 
-                                   self.drive['device'])
+                raise LiveUSBError(_("Filesystem for %s unknown!" % 
+                                     self.drive['device']))
             try:
                 self.log.debug("Calling %s.Mount('', %s, [], ...)" % (
                                self.drive['udi'], self.fstype))
                 self.drive['udi'].Mount('', self.fstype, [],
                         dbus_interface='org.freedesktop.Hal.Device.Volume')
             except Exception, e:
-                raise LiveUSBError("Unable to mount device: %s" % str(e))
+                raise LiveUSBError(_("Unable to mount device: %s" % str(e)))
             device = self.hal.FindDeviceStringMatch('block.device',
                                                     self.drive['device'])
             device = self._get_device(device[0])
@@ -366,10 +367,11 @@ class LinuxLiveUSBCreator(LiveUSBCreator):
     def verify_filesystem(self):
         if self.fstype not in ('vfat', 'msdos', 'ext2', 'ext3'):
             if not self.fstype:
-                raise LiveUSBError("Unknown filesystem for %s.  Your device "
-                                   "may need to be reformatted.")
+                raise LiveUSBError(_("Unknown filesystem for %s.  Your device "
+                                     "may need to be reformatted."))
             else:
-                raise LiveUSBError("Unsupported filesystem: %s" % self.fstype)
+                raise LiveUSBError(_("Unsupported filesystem: %s" %
+                                     self.fstype))
         if self.drive['label']:
             self.label = self.drive['label']
         else:
@@ -395,7 +397,7 @@ class LinuxLiveUSBCreator(LiveUSBCreator):
         tmpliveos = os.path.join(tmpdir, 'LiveOS')
         try:
             if not os.path.isdir(tmpliveos):
-                raise LiveUSBError("Unable to find LiveOS on ISO")
+                raise LiveUSBError(_("Unable to find LiveOS on ISO"))
             liveos = os.path.join(self.dest, 'LiveOS')
             if not os.path.exists(liveos):
                 os.mkdir(liveos)
@@ -467,19 +469,19 @@ class WindowsLiveUSBCreator(LiveUSBCreator):
                     'device': drive,
                 }
         if not len(self.drives):
-            raise LiveUSBError("Unable to find any removable devices")
+            raise LiveUSBError(_("Unable to find any removable devices"))
 
     def verify_filesystem(self):
         import win32api, win32file, pywintypes
         try:
             vol = win32api.GetVolumeInformation(self.drive['device'])
         except Exception, e:
-            raise LiveUSBError("Make sure your USB key is plugged in and "
-                               "formatted with the FAT filesystem")
+            raise LiveUSBError(_("Make sure your USB key is plugged in and "
+                                 "formatted with the FAT filesystem"))
         if vol[-1] not in ('FAT32', 'FAT'):
-            raise LiveUSBError("Unsupported filesystem: %s\nPlease backup and "
-                               "format your USB key with the FAT filesystem." %
-                               vol[-1])
+            raise LiveUSBError(_("Unsupported filesystem: %s\nPlease backup "
+                                 "and format your USB key with the FAT "
+                                 "filesystem." % vol[-1]))
         self.fstype = 'vfat'
         if vol[0] == '':
             try:
@@ -553,9 +555,9 @@ class WindowsLiveUSBCreator(LiveUSBCreator):
             cmd = cmd.split()
         tool = os.path.join('tools', '%s.exe' % cmd[0])
         if not os.path.exists(tool):
-            raise LiveUSBError("Cannot find '%s'.  Make sure to extract the "
-                               "entire liveusb-creator zip file before running "
-                               "this program.")
+            raise LiveUSBError(_("Cannot find '%s'.  Make sure to extract the "
+                                 "entire liveusb-creator zip file before "
+                                 "running this program."))
         return LiveUSBCreator.popen(self, ' '.join([tool] + cmd[1:]),
                                     creationflags=win32process.CREATE_NO_WINDOW,
                                     **kwargs)
diff --git a/liveusb/gui.py b/liveusb/gui.py
index 258d4dc..035ccc0 100755
--- a/liveusb/gui.py
+++ b/liveusb/gui.py
@@ -29,7 +29,7 @@ from time import sleep
 from datetime import datetime
 from PyQt4 import QtCore, QtGui
 
-from liveusb import LiveUSBCreator, LiveUSBError
+from liveusb import LiveUSBCreator, LiveUSBError, _
 from liveusb.dialog import Ui_Dialog
 from liveusb.releases import releases
 from liveusb.urlgrabber.grabber import URLGrabber, URLGrabError
@@ -66,11 +66,11 @@ class ReleaseDownloader(QtCore.QThread):
                 self.url = rel['url']
                 break
         else:
-            raise LiveUSBError("Unknown release: %s" % release)
+            raise LiveUSBError(_("Unknown release: %s" % release))
 
     def run(self):
         self.emit(QtCore.SIGNAL("status(PyQt_PyObject)"),
-                  "Downloading %s..." % os.path.basename(self.url))
+                  _("Downloading %s..." % os.path.basename(self.url)))
         grabber = URLGrabber(progress_obj=self.progress, proxies=self.proxies)
         try:
             iso = grabber.urlgrab(self.url, reget='simple')
@@ -149,11 +149,11 @@ class LiveUSBThread(QtCore.QThread):
     def run(self):
         now = datetime.now()
         try:
-            self.status("Verifying filesystem...")
+            self.status(_("Verifying filesystem..."))
             self.live.verify_filesystem()
             if not self.live.drive['uuid'] and not self.live.label:
-                self.status("Error: Cannot set the label or obtain " 
-                            "the UUID of your device.  Unable to continue.")
+                self.status(_("Error: Cannot set the label or obtain " 
+                              "the UUID of your device.  Unable to continue."))
                 return
 
             self.live.check_free_space()
@@ -161,12 +161,12 @@ class LiveUSBThread(QtCore.QThread):
             # If the ISO looks familar, verify it's SHA1SUM
             if not self.parent.opts.noverify:
                 if self.live.get_release_from_iso():
-                    self.status("Verifying SHA1 of LiveCD image...")
+                    self.status(_("Verifying SHA1 of LiveCD image..."))
                     if not self.live.verify_image(progress=self):
-                        self.status("Error: The SHA1 of your Live CD is "
-                                    "invalid.  You can run this program with "
-                                    "the --noverify argument to bypass this "
-                                    "verification check.")
+                        self.status(_("Error: The SHA1 of your Live CD is "
+                                      "invalid.  You can run this program with "
+                                      "the --noverify argument to bypass this "
+                                      "verification check."))
                         return
 
             self.progress.set_data(size=self.live.totalsize,
@@ -174,23 +174,23 @@ class LiveUSBThread(QtCore.QThread):
                                    freebytes=self.live.get_free_bytes)
             self.progress.start()
 
-            self.status("Extracting live image to USB device...")
+            self.status(_("Extracting live image to USB device..."))
             self.live.extract_iso()
             if self.live.overlay:
-                self.status("Creating %d Mb persistent overlay..." %
-                            self.live.overlay)
+                self.status(_("Creating %d Mb persistent overlay..." %
+                            self.live.overlay))
                 self.live.create_persistent_overlay()
-            self.status("Configuring and installing bootloader...")
+            self.status(_("Configuring and installing bootloader..."))
             self.live.update_configs()
             self.live.install_bootloader()
             duration = str(datetime.now() - now).split('.')[0]
-            self.status("Complete! (%s)" % duration)
+            self.status(_("Complete! (%s)" % duration))
         except LiveUSBError, e:
             self.status(str(e))
-            self.status("LiveUSB creation failed!")
+            self.status(_("LiveUSB creation failed!"))
         except Exception, e:
             self.status(str(e))
-            self.status("LiveUSB creation failed!")
+            self.status(_("LiveUSB creation failed!"))
             import traceback
             traceback.print_exc()
 
@@ -313,7 +313,7 @@ class LiveUSBDialog(QtGui.QDialog, Ui_Dialog):
         self.refreshDevicesButton.setEnabled(enabled)
 
     def overlay_value(self, value):
-        self.overlayTitle.setTitle("Persistent Storage (%d Mb)" % value)
+        self.overlayTitle.setTitle(_("Persistent Storage (%d Mb)" % value))
 
     def get_selected_drive(self):
         return str(self.driveBox.currentText()).split()[0]
@@ -331,13 +331,13 @@ class LiveUSBDialog(QtGui.QDialog, Ui_Dialog):
 
         if self.live.existing_liveos():
             if not self.confirmed:
-                self.status("Your device already contains a LiveOS.\nIf you "
-                            "continue, this will be overwritten.")
+                self.status(_("Your device already contains a LiveOS.\nIf you "
+                              "continue, this will be overwritten."))
                 if self.live.existing_overlay() and self.overlaySlider.value():
-                    self.status("Warning: Creating a new persistent overlay "
-                                "will delete your existing one.")
-                self.status("Press 'Create Live USB' again if you wish to "
-                            "continue.")
+                    self.status(_("Warning: Creating a new persistent overlay "
+                                  "will delete your existing one."))
+                self.status(_("Press 'Create Live USB' again if you wish to "
+                              "continue."))
                 self.confirmed = True
                 self.live.unmount_device()
                 self.enable_widgets(True)
@@ -346,7 +346,7 @@ class LiveUSBDialog(QtGui.QDialog, Ui_Dialog):
                 # The user has confirmed that they wish to overwrite their
                 # existing Live OS.  Here we delete it first, in order to 
                 # accurately calculate progress.
-                self.status("Removing existing Live OS...")
+                self.status(_("Removing existing Live OS..."))
                 try:
                     self.live.delete_liveos()
                 except LiveUSBError, e:
@@ -380,28 +380,28 @@ class LiveUSBDialog(QtGui.QDialog, Ui_Dialog):
         the error message.
         """
         if os.path.exists(iso):
-            self.status("Download complete!")
+            self.status(_("Download complete!"))
             self.live.iso = iso
             self.live_thread.start()
         else:
-            self.status("Download failed: " + iso)
-            self.status("You can try again to resume your download")
+            self.status(_("Download failed: " + iso))
+            self.status(_("You can try again to resume your download"))
             self.enable_widgets(True)
 
     def selectfile(self):
-        isofile = QtGui.QFileDialog.getOpenFileName(self, "Select Live ISO",
+        isofile = QtGui.QFileDialog.getOpenFileName(self, _("Select Live ISO"),
                                                     ".", "ISO (*.iso)" )
         if isofile:
             try:
                 self.live.iso = self._to_unicode(isofile)
             except Exception, e:
                 self.live.log.error(str(e))
-                self.status("Sorry, I'm having trouble encoding the filename "
-                            "of your livecd.  You may have better luck if "
-                            "you move your ISO to the root of your drive "
-                            "(ie: C:\)")
+                self.status(_("Sorry, I'm having trouble encoding the filename "
+                              "of your livecd.  You may have better luck if "
+                              "you move your ISO to the root of your drive "
+                              "(ie: C:\)"))
 
-            self.live.log.info("ISO selected: %s" % repr(self.live.iso))
+            self.live.log.info(_("ISO selected: %s" % repr(self.live.iso)))
             self.textEdit.append(os.path.basename(self.live.iso) + ' selected')
 
     def terminate(self):


commit e88e621c97e899b3c5cb98b14a0b56f46816741f
Author: Luke Macken <lmacken at redhat.com>
Date:   Wed Aug 27 09:32:48 2008 -0400

    Add translation.ugettext (as _) in liveusb.__init__ module

diff --git a/liveusb/__init__.py b/liveusb/__init__.py
index 36e25ea..6d98981 100644
--- a/liveusb/__init__.py
+++ b/liveusb/__init__.py
@@ -19,6 +19,11 @@
 
 import os
 import sys
+import gettext
+
+translation = gettext.translation('liveusb-creator', '/usr/share/locale',
+                                  fallback=True)
+_ = translation.ugettext
 
 from liveusb.creator import LiveUSBError
 
@@ -29,9 +34,9 @@ if sys.platform == "win32":
     LiveUSBCreator = WindowsLiveUSBCreator
 else:
     if os.getuid() != 0:
-        print >> sys.stderr, "You must run this application as root"
+        print >> sys.stderr, _("You must run this application as root")
         sys.exit(1)
     from liveusb.creator import LinuxLiveUSBCreator
     LiveUSBCreator = LinuxLiveUSBCreator
 
-__all__ = ["LiveUSBCreator", "LiveUSBError"]
+__all__ = ("LiveUSBCreator", "LiveUSBError", "_")


commit f45ae9b6c76164a63c3f00023403f950c5d3a895
Author: Luke Macken <lmacken at redhat.com>
Date:   Wed Aug 27 09:31:42 2008 -0400

    Add a po directory, along with a POTFILES.in

diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644
index 0000000..691e83b
--- /dev/null
+++ b/po/POTFILES.in
@@ -0,0 +1,3 @@
+[encoding: UTF-8]
+liveusb/gui.py
+liveusb/creator.py




More information about the liveusb-creator mailing list