4 commits - liveusb/creator.py liveusb/gui.py setup.py
Luke Macken
lmacken at fedoraproject.org
Thu Jan 6 00:58:31 UTC 2011
liveusb/creator.py | 28 +++++++++++++++++++++++-----
liveusb/gui.py | 8 ++++++++
setup.py | 25 +++++++++++++++++++++++++
3 files changed, 56 insertions(+), 5 deletions(-)
New commits:
commit b7e0e5b6ab72548d1d1080cb94c2e6e8e3f92683
Author: Luke Macken <lmacken at redhat.com>
Date: Wed Jan 5 19:56:21 2011 -0500
Look for our tools in the windows PROGRAMFILES.
Ideally, we should grab this location from the registry...
diff --git a/liveusb/creator.py b/liveusb/creator.py
index ae63f84..257ccd1 100755
--- a/liveusb/creator.py
+++ b/liveusb/creator.py
@@ -1017,8 +1017,15 @@ class WindowsLiveUSBCreator(LiveUSBCreator):
import win32process
if isinstance(cmd, basestring):
cmd = cmd.split()
- tool = os.path.join('.', 'tools', '%s.exe' % cmd[0])
- if not os.path.exists(tool):
+ prgmfiles = os.getenv('PROGRAMFILES')
+ paths = (prgmfiles, prgmfiles + ' (x86)', '.')
+ tool = None
+ for path in paths:
+ exe = os.path.join(path, 'LiveUSB Creator', 'tools', '%s.exe' % cmd[0])
+ if os.path.exists(exe):
+ tool = '"%s"' % exe
+ break
+ else:
raise LiveUSBError(_("Cannot find") + ' %s. ' % (cmd[0]) +
_("Make sure to extract the entire "
"liveusb-creator zip file before "
commit 0e73c3201f82a34ac00927df10f97e5fe8c02ee5
Author: Luke Macken <lmacken at redhat.com>
Date: Wed Jan 5 19:55:10 2011 -0500
Mention the error log filename when we write one out
diff --git a/liveusb/creator.py b/liveusb/creator.py
index b79e879..ae63f84 100755
--- a/liveusb/creator.py
+++ b/liveusb/creator.py
@@ -192,12 +192,12 @@ class LiveUSBCreator(object):
err = err.encode('utf-8', 'replace')
self.output.write(out + '\n' + err + '\n')
if proc.returncode:
- self.write_log()
+ filename = self.write_log()
if not passive:
raise LiveUSBError(_("There was a problem executing the "
"following command: `%s`\nA more detailed "
"error log has been written to "
- "'liveusb-creator.log'" % cmd))
+ "'%s'" % (cmd, filename)))
return proc
def verify_iso_sha1(self, progress=None):
@@ -333,9 +333,12 @@ class LiveUSBCreator(object):
def write_log(self):
""" Write out our subprocess stdout/stderr to a log file """
tmpdir = os.getenv('TEMP', '/tmp')
- out = file(os.path.join(tmpdir, 'liveusb-creator.log'), 'a')
+ filename = os.path.join(tmpdir, 'liveusb-creator.log')
+ out = file(filename, 'a')
out.write(self.output.getvalue())
out.close()
+ return filename
+
def existing_liveos(self):
return os.path.exists(self.get_liveos())
commit 25c075c3210d43bd9174a5fc8504305d9cbc5f40
Author: Luke Macken <lmacken at redhat.com>
Date: Wed Jan 5 19:54:22 2011 -0500
Add a LiveUSBCreator.is_admin method, and warn the user if they are not running as an admin.
diff --git a/liveusb/creator.py b/liveusb/creator.py
index f626d22..b79e879 100755
--- a/liveusb/creator.py
+++ b/liveusb/creator.py
@@ -406,6 +406,8 @@ class LiveUSBCreator(object):
""" Flush filesystem buffers """
pass
+ def is_admin(self):
+ raise NotImplementedError
class LinuxLiveUSBCreator(LiveUSBCreator):
@@ -845,6 +847,8 @@ class LinuxLiveUSBCreator(LiveUSBCreator):
def flush_buffers(self):
self.popen('sync', passive=True)
+ def is_admin(self):
+ return os.getuid() == 0
class WindowsLiveUSBCreator(LiveUSBCreator):
@@ -1125,3 +1129,7 @@ class WindowsLiveUSBCreator(LiveUSBCreator):
""" Format the selected partition as FAT32 """
self.log.info('Formatting %s as FAT32' % self.drive['device'])
self.popen('format /Q /X /y /V:Fedora /FS:FAT32 %s' % self.drive['device'])
+
+ def is_admin(self):
+ from win32com.shell import shell
+ return shell.IsUserAnAdmin()
diff --git a/liveusb/gui.py b/liveusb/gui.py
index a820c64..3cf2ad9 100755
--- a/liveusb/gui.py
+++ b/liveusb/gui.py
@@ -289,6 +289,14 @@ class LiveUSBDialog(QtGui.QDialog, LiveUSBInterface):
if arg.lower().endswith('.iso') and os.path.exists(arg):
self.selectfile(arg)
+ # Determine if we have admin rights
+ if not self.live.is_admin():
+ self.live.log.error(_('Warning: This tool needs to be run as an '
+ 'Administrator. To do this, right click on the icon and open '
+ 'the Properties. Under the Compatibility tab, check the "Run '
+ 'this program as an administrator" box.'))
+
+
def populate_devices(self, *args, **kw):
if self.in_process:
return
commit a3e54a38f19a2228b6266437055b16ad4eec0998
Author: Luke Macken <lmacken at redhat.com>
Date: Wed Jan 5 19:47:58 2011 -0500
Add a py2exe win32com.shell hack to our setup.py
diff --git a/setup.py b/setup.py
index cdf5dce..07a1cd0 100644
--- a/setup.py
+++ b/setup.py
@@ -9,6 +9,31 @@ if os.path.exists('po/locale'):
locales.append(os.path.join(lang, 'LC_MESSAGES'))
if sys.platform == 'win32':
+
+ # win32com.shell fix from http://www.py2exe.org/index.cgi/win32com.shell
+ # ModuleFinder can't handle runtime changes to __path__, but win32com uses them
+ try:
+ # py2exe 0.6.4 introduced a replacement modulefinder.
+ # This means we have to add package paths there, not to the built-in
+ # one. If this new modulefinder gets integrated into Python, then
+ # we might be able to revert this some day.
+ # if this doesn't work, try import modulefinder
+ try:
+ import py2exe.mf as modulefinder
+ except ImportError:
+ import modulefinder
+ import win32com
+ for p in win32com.__path__[1:]:
+ modulefinder.AddPackagePath("win32com", p)
+ for extra in ["win32com.shell"]: #,"win32com.mapi"
+ __import__(extra)
+ m = sys.modules[extra]
+ for p in m.__path__[1:]:
+ modulefinder.AddPackagePath(extra, p)
+ except ImportError:
+ # no build path setup, no worries.
+ pass
+
import py2exe
LOCALE_DIR = 'locale'
More information about the liveusb-creator
mailing list