def __init__(self, server_url, username): self.server_url = server_url # This is the top-level container that is destroyed and recreated to # "switch pages". See _PrepTop(). self.top_frame = None self.username = username self.storage = glue.GetStorage() self.root = Tkinter.Tk() self.root.title('CauliflowerVest') # Set our fixed size, and center on the screen. self.root.geometry('%dx%d+%d+%d' % ( self.WIDTH, self.HEIGHT, self.root.winfo_screenwidth() / 2 - self.WIDTH / 2, self.root.winfo_screenheight() / 2 - self.HEIGHT / 2, )) # Override Tk's default error handling. self.root.report_callback_exception = ( lambda _1, exc, *_2, **_3: self.ShowFatalError(exc)) # Lame hack around OSX focus issue. http://goo.gl/9U0Vg util.Exec( ('/usr/bin/osascript', '-e', 'tell app "Finder" to set frontmost of process "python" to true')) self.top_frame = None self.status_callback = None
def main(options): if options.username: username = options.username else: username = pwd.getpwuid(os.getuid()).pw_name if options.login_type == 'oauth2': gui = tkinter.GuiOauth(options.server_url, username) else: raise NotImplementedError('Unsupported login type: %s', options.login_type) storage = glue.GetStorage() if not storage: gui.ShowFatalError('Could not determine File System type') return 1 _, encrypted_volumes, _ = storage.GetStateAndVolumeIds() try: if encrypted_volumes: gui.EncryptedVolumePrompt(status_callback=status_callback) else: gui.PlainVolumePrompt(options.welcome, status_callback=status_callback) except Exception as e: # pylint: disable=broad-except gui.ShowFatalError(e) return 1 finally: return exit_status # pylint: disable=lost-exception
def run_tkinter_gui(username, options): """Runs CauliflowerVest with a Tkinter GUI.""" if options.login_type == 'oauth2': gui = tkinter.GuiOauth(options.server_url, username) else: raise NotImplementedError('Unsupported login type: %s', options.login_type) storage = glue.GetStorage() if not storage: gui.ShowFatalError('Could not determine File System type') return 1 _, encrypted_volumes, _ = storage.GetStateAndVolumeIds() try: if encrypted_volumes: gui.EncryptedVolumePrompt(status_callback=status_callback) else: gui.PlainVolumePrompt(options.welcome, status_callback=status_callback) except Exception as e: # pylint: disable=broad-except gui.ShowFatalError(e) return 1 finally: return exit_status # pylint: disable=lost-exception