def toggleAutoConnect_(self, sender): share = self.config_manager.get_sharebykey('title', sender.parentItem().title()) if share.get('share_type') in ['managed', 'smb_home']: existing_share, index = self.config_manager.get_managedshare_bykey( 'title', share.get('title')) else: existing_share, index = self.config_manager.get_useradded_bykey( 'title', share.get('title')) if existing_share: if existing_share.get('connect_automatically'): sender.setState_(False) existing_share['connect_automatically'] = False self.config_manager.update_share(existing_share, index) NSLog('User has set {0} to no longer connect automatically'. format(existing_share.get('title'))) else: sender.setState_(True) existing_share['connect_automatically'] = True if existing_share.get( 'mount_point' ) not in SMUtilities.get_mounted_network_volumes(): SMUtilities.mount_share(existing_share.get('share_url')) self.config_manager.update_share(existing_share, index) NSLog('User has set {0} to connect automatically.'.format( existing_share.get('title'))) if self.addShareWindow.isVisible(): self.connectAutoCheck.setState_(share.get('connect_automatically'))
def connectToShare_(self, sender): NSLog('User clicked {}'.format(sender.title())) try: share_title = sender.parentItem().title() except AttributeError: share_title = self.shareTitleField.stringValue() network_share = self.config_manager.get_sharebykey('title', share_title) if network_share.get('mount_point') in SMUtilities.get_mounted_network_volumes(): d = PyDialog.AlertDialog('Cannot mount "{0}"'.format(network_share.get('title')), 'Volume is already mounted at "{0}"'.format(network_share.get('mount_point'))) d.display() else: SMUtilities.mount_share(network_share.get('share_url'))
def autoMountShares(self): managed_shares = SMUtilities.get_managed_shares() user_added_shares = SMUtilities.get_user_added_shares() if self.ldap_reachable: for share in managed_shares: if (share.get('connect_automatically') and share.get('mount_point') not in SMUtilities.get_mounted_network_volumes()): NSLog('Automounting {0}'.format(share.get('share_url'))) SMUtilities.mount_share(share.get('share_url')) for share in user_added_shares: if (share.get('connect_automatically') and share.get('mount_point') not in SMUtilities.get_mounted_network_volumes()): SMUtilities.mount_share(share.get('share_url'))
def connectToShare_(self, sender): NSLog('User clicked {}'.format(sender.title())) try: share_title = sender.parentItem().title() except AttributeError: share_title = self.shareTitleField.stringValue() network_share = self.config_manager.get_sharebykey( 'title', share_title) if network_share.get( 'mount_point') in SMUtilities.get_mounted_network_volumes(): d = PyDialog.AlertDialog( 'Cannot mount "{0}"'.format(network_share.get('title')), 'Volume is already mounted at "{0}"'.format( network_share.get('mount_point'))) d.display() else: SMUtilities.mount_share(network_share.get('share_url'))
def toggleAutoConnect_(self, sender): share = self.config_manager.get_sharebykey('title', sender.parentItem().title()) if share.get('share_type') in ['managed', 'smb_home']: existing_share, index = self.config_manager.get_managedshare_bykey('title', share.get('title')) else: existing_share, index = self.config_manager.get_useradded_bykey('title', share.get('title')) if existing_share: if existing_share.get('connect_automatically'): sender.setState_(False) existing_share['connect_automatically'] = False self.config_manager.update_share(existing_share, index) NSLog('User has set {0} to no longer connect automatically'.format(existing_share.get('title'))) else: sender.setState_(True) existing_share['connect_automatically'] = True if existing_share.get('mount_point') not in SMUtilities.get_mounted_network_volumes(): SMUtilities.mount_share(existing_share.get('share_url')) self.config_manager.update_share(existing_share, index) NSLog('User has set {0} to connect automatically.'.format(existing_share.get('title'))) if self.addShareWindow.isVisible(): self.connectAutoCheck.setState_(share.get('connect_automatically'))