From b75dc46979e13f980a206c02c8fa5aa24141be72 Mon Sep 17 00:00:00 2001 From: Steffen Schaumburg Date: Fri, 18 Mar 2011 00:11:47 +0100 Subject: [PATCH] display warning and dont load HUD if running without admin under vista/7 --- pyfpdb/GuiAutoImport.py | 17 +++++++++-------- pyfpdb/HUD_main.pyw | 15 +++++++++++++-- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/pyfpdb/GuiAutoImport.py b/pyfpdb/GuiAutoImport.py index 2b54f988..69d33cdd 100755 --- a/pyfpdb/GuiAutoImport.py +++ b/pyfpdb/GuiAutoImport.py @@ -223,15 +223,16 @@ class GuiAutoImport (threading.Thread): def startClicked(self, widget, data): """runs when user clicks start on auto import tab""" -# Check to see if we have an open file handle to the HUD and open one if we do not. -# bufsize = 1 means unbuffered -# We need to close this file handle sometime. + # Check to see if we have an open file handle to the HUD and open one if we do not. + # bufsize = 1 means unbuffered + # We need to close this file handle sometime. -# TODO: Allow for importing from multiple dirs - REB 29AUG2008 -# As presently written this function does nothing if there is already a pipe open. -# That is not correct. It should open another dir for importing while piping the -# results to the same pipe. This means that self.path should be a a list of dirs -# to watch. + # TODO: Allow for importing from multiple dirs - REB 29AUG2008 + # As presently written this function does nothing if there is already a pipe open. + # That is not correct. It should open another dir for importing while piping the + # results to the same pipe. This means that self.path should be a a list of dirs + # to watch. + if data == "autostart" or (widget == self.startButton and self.startButton.get_active()): self.startButton.set_active(True) # - Does the lock acquisition need to be more sophisticated for multiple dirs? diff --git a/pyfpdb/HUD_main.pyw b/pyfpdb/HUD_main.pyw index 8878cde3..139767ce 100755 --- a/pyfpdb/HUD_main.pyw +++ b/pyfpdb/HUD_main.pyw @@ -80,12 +80,23 @@ class HUD_main(object): self.hud_dict = {} self.hud_params = self.config.get_hud_ui_parameters() - # a thread to read stdin + # a thread to read stdin gobject.threads_init() # this is required thread.start_new_thread(self.read_stdin, ()) # starts the thread - # a main window + # a main window self.main_window = gtk.Window() + + if os.name == 'nt': # Check for admin rights, don't start auto import if we don't have them + if (os.sys.getwindowsversion()[0] >= 6): + import ctypes + if not ctypes.windll.shell32.IsUserAnAdmin(): + dia = gtk.MessageDialog(parent=self.main_window, flags=gtk.DIALOG_DESTROY_WITH_PARENT, type=gtk.MESSAGE_ERROR, buttons=(gtk.BUTTONS_OK), message_format=_("No admin rights for HUD")) + dia.format_secondary_text(_("Please right click fpdb.exe and HUD_main.exe, select properties, and set them both to run as admin.")+" "+_("You will need to restart fpdb afterwards.")) + response = dia.run() + dia.destroy() + return + if options.minimized: self.main_window.iconify() if options.hidden: