summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Macken <lmacken@redhat.com>2011-01-05 19:54:22 -0500
committerLuke Macken <lmacken@redhat.com>2011-01-05 19:54:22 -0500
commit25c075c3210d43bd9174a5fc8504305d9cbc5f40 (patch)
tree7d90135d2391a5b1abec73743eca87c197657d2c
parenta3e54a38f19a2228b6266437055b16ad4eec0998 (diff)
Add a LiveUSBCreator.is_admin method, and warn the user if they are not running as an admin.
-rwxr-xr-xliveusb/creator.py8
-rwxr-xr-xliveusb/gui.py8
2 files changed, 16 insertions, 0 deletions
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