def test_sanitize_path(self): self.assertEqual(S.sanitize_unc_path(''), '') self.assertEqual(S.sanitize_unc_path('abcABC'), 'abcABC') self.assertEqual(S.sanitize_unc_path(r'<>"/|?*'), '') self.assertEqual(S.sanitize_unc_path('\0\1\2\3\4\30\31'), '') self.assertEqual(S.sanitize_path(r'C:\a valid\folder'), r'C:\a valid\folder') self.assertEqual(S.sanitize_path(r':\\'), r':\\')
def disconnect(self): """ Disconnects the UNC path. If the command fails, this will raise a `ShellCommandError`. """ identifier = (self.disk_drive.get_drive() if self.disk_drive else S.sanitize_path(self.unc.get_normalized_path())) self.logger('Disconnecting the network UNC path "{path}".'.format(path=self.get_path())) run('NET USE "{id}" /DELETE /YES'.format(id=identifier), self.logger)
def disconnect(self): """ Disconnects the UNC path. If the command fails, this will raise a `ShellCommandError`. """ identifier = (self.disk_drive.get_drive() if self.disk_drive else S.sanitize_path(self.unc.get_normalized_path())) self.logger('Disconnecting the network UNC path "{path}".'.format( path=self.get_path())) run('NET USE "{id}" /DELETE /YES'.format(id=identifier), self.logger)