def launchUibMountWindowsfolder_(self, notification): try: uibip = uiblibrary.getstatusuibnet() if (uibip): uiblibrary.openuriinfinder(uiblibrary.findwindowshomedirectory(NSUserName())) s = NSAppleScript.alloc().initWithSource_("tell app \"Finder\" to activate") s.executeAndReturnError_(None) else: uiblibrary.connectvpn("UiB Ansatt VPN", "%s@ansatt" % NSUserName()) timeout = 0 while not uibip and timeout < 5: time.sleep(1) uibip = uiblibrary.getstatusuibnet() print "DEBUG: Waiting for UiB IP" timeout += 1 if (uibip): uiblibrary.openuriinfinder(uiblibrary.findwindowshomedirectory(NSUserName())) s = NSAppleScript.alloc().initWithSource_("tell app \"Finder\" to activate") s.executeAndReturnError_(None) else: print "DEBUG: Still no UiB IP-address, giving up." self.notify("Cant establish connection", "Missing uib-ip", "Please connect to VPN and retry") pass except (OSError) as e: NSLog(e)
def launchUibVpn_(self, notification): try: uiblibrary.connectvpn("UiB Ansatt VPN", "%s@ansatt" % NSUserName()) except (OSError) as e: NSLog(e)