From aecc895cb6ff6b61186fe7f72bb68736ccc35acf Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Sun, 12 Apr 2009 13:06:50 -0400 Subject: [PATCH] Whitespace removal --HG-- extra : convert_revision : 8e5e3aaaa2ec19d4c5aa5ee14cffa9ee2a7d8a1b --- examples/crankd/MountManager.py | 2 +- examples/crankd/NetworkConfig.py | 1 - .../sample-of-events/generate-event-plist.py | 28 +++++++------- examples/ctypes/keychain-delete.py | 3 +- examples/ctypes/keychain-update.py | 38 +++++++++---------- lib/PyMacAdmin/SCUtilities/SCPreferences.py | 12 +++--- .../Security/tests/test_Keychain.py | 22 +++++------ .../diskimage_unittesting/dmgtestutilities.py | 6 +-- utilities/diskimage_unittesting/macdmgtest.py | 4 +- .../diskimage_unittesting/run_image_tests.py | 8 ++-- .../tests/example_plist_test.py | 32 ++++++++-------- .../tests/skipsetup_test.py | 4 +- .../tests/zz_world_writable_test.py | 4 +- 13 files changed, 81 insertions(+), 83 deletions(-) diff --git a/examples/crankd/MountManager.py b/examples/crankd/MountManager.py index 5f79322..4ff9a68 100755 --- a/examples/crankd/MountManager.py +++ b/examples/crankd/MountManager.py @@ -8,4 +8,4 @@ def onNSWorkspaceDidMountNotification_(self, aNotification): def onNSWorkspaceDidUnmountNotification_(self, aNotification): path = aNotification.userInfo()['NSDevicePath'] self.logger.info("Unmount: %s" % path) - + diff --git a/examples/crankd/NetworkConfig.py b/examples/crankd/NetworkConfig.py index dbb7298..7ae3c92 100755 --- a/examples/crankd/NetworkConfig.py +++ b/examples/crankd/NetworkConfig.py @@ -4,4 +4,3 @@ class NetworkConfig(object): """Handles network related changes for kicker-replacement""" def atalk_change(self, context=None, logger=None, **kwargs): logger.info("Atalk? You poor person, you…") - \ No newline at end of file diff --git a/examples/crankd/sample-of-events/generate-event-plist.py b/examples/crankd/sample-of-events/generate-event-plist.py index d1e39f8..9f2a3bd 100755 --- a/examples/crankd/sample-of-events/generate-event-plist.py +++ b/examples/crankd/sample-of-events/generate-event-plist.py @@ -31,12 +31,12 @@ def AddCategoryOfEvents(event_category, events): def AddKnownEvents(): """Here we add all the events that we know of to the dictionary""" - + # Add a bunch of dynamic events store = SCDynamicStoreCreate(None, "generate_event_plist", None, None) AddCategoryOfEvents(u"SystemConfiguration", SCDynamicStoreCopyKeyList(store, ".*")) - + # Add some standard NSWorkspace events AddCategoryOfEvents(u"NSWorkspace", u''' @@ -57,28 +57,28 @@ def AddKnownEvents(): def PrintEvents(): """Prints all the events, for debugging purposes""" for category in sorted(event_dict): - + print category - + for event in sorted(event_dict[category]): print "\t" + event def OutputEvents(): """Outputs all the events to a file""" - + # print the header for the file plist = open(OUTPUT_FILE, 'w') - + print >>plist, ''' ''' - + for category in sorted(event_dict): - + # print out the category print >>plist, " %s\n " % category - + for event in sorted(event_dict[category]): print >>plist, """ %s @@ -86,16 +86,16 @@ def OutputEvents(): command %s '%s' '%s' """ % ( event, 'tunnel.sh', category, event ) - + # end the category print >>plist, " " - + # end the plist file print >>plist, '' print >>plist, '' - + plist.close() - + def main(): """Runs the program""" AddKnownEvents() @@ -104,4 +104,4 @@ def main(): main() - + diff --git a/examples/ctypes/keychain-delete.py b/examples/ctypes/keychain-delete.py index 6e46211..167a175 100755 --- a/examples/ctypes/keychain-delete.py +++ b/examples/ctypes/keychain-delete.py @@ -38,5 +38,4 @@ if rc != 0: raise RuntimeError('SecKeychainItemDelete failed: rc=%d' % rc) - - \ No newline at end of file + diff --git a/examples/ctypes/keychain-update.py b/examples/ctypes/keychain-update.py index 4bb61ae..aeb9ec2 100755 --- a/examples/ctypes/keychain-update.py +++ b/examples/ctypes/keychain-update.py @@ -38,21 +38,21 @@ def UpdatePassword(account_name, new_password, server_name, protocol_type_string protocol_type_code = FourCharCode(protocol_type_string) else: protocol_type_code = 0 - + # Call function to locate existing keychain item rc = Security.SecKeychainFindInternetPassword( - None, - len(server_name), + None, + len(server_name), server_name, - None, - None, - len(account_name), - account_name, - None, - None, - port_number, - protocol_type_code, - None, + None, + None, + len(account_name), + account_name, + None, + None, + port_number, + protocol_type_code, + None, None, # To retrieve the current password, change this argument to: ctypes.byref(password_length) None, # To retrieve the current password, change this argument to: ctypes.pointer(password_pointer) ctypes.pointer(item) @@ -60,18 +60,18 @@ def UpdatePassword(account_name, new_password, server_name, protocol_type_string if rc != 0: raise RuntimeError('Did not find existing password for server %s, protocol type %s, account name %s: rc=%d' % (server_name, protocol_type_code, account_name, rc)) - + # Call function to update password rc = Security.SecKeychainItemModifyAttributesAndData( - item, - None, - len(new_password), + item, + None, + len(new_password), new_password ) if rc != 0: raise RuntimeError('Failed to record new password for server %s, protocol type %s, account name %s: rc=%d' % (server_name, protocol_type_code, account_name, rc)) - + return 0 # Start execution @@ -85,11 +85,11 @@ def UpdatePassword(account_name, new_password, server_name, protocol_type_string new_password = sys.argv[2] # Call UpdatePassword for each password to update. -# +# # If more than one keychain item will match a server and account name, you must # specify a protocol type. Otherwise, only the first matching item will be # updated. -# +# # The list of protocol type codes is in # /System/Library/Frameworks/Security.framework/Versions/Current/Headers/SecKeychain.h diff --git a/lib/PyMacAdmin/SCUtilities/SCPreferences.py b/lib/PyMacAdmin/SCUtilities/SCPreferences.py index eb12763..1ca009b 100755 --- a/lib/PyMacAdmin/SCUtilities/SCPreferences.py +++ b/lib/PyMacAdmin/SCUtilities/SCPreferences.py @@ -17,20 +17,20 @@ class SCPreferences(object): """Utility class for working with the SystemConfiguration framework""" proxy_protocols = ('HTTP', 'FTP', 'SOCKS') # List of the supported protocols session = None - + def __init__(self): super(SCPreferences, self).__init__() self.session = SCPreferencesCreate(None, "set-proxy", None) - + def save(self): if not self.session: - return + return if not SCPreferencesCommitChanges(self.session): raise RuntimeError("Unable to save SystemConfiguration changes") if not SCPreferencesApplyChanges(self.session): raise RuntimeError("Unable to apply SystemConfiguration changes") - - def set_proxy(self, enable=True, protocol="HTTP", server="localhost", port=3128): + + def set_proxy(self, enable=True, protocol="HTTP", server="localhost", port=3128): new_settings = SCPreferencesPathGetValue(self.session, u'/NetworkServices/') for interface in new_settings: @@ -38,7 +38,7 @@ def set_proxy(self, enable=True, protocol="HTTP", server="localhost", port=3128) if enable: new_settings[interface]['Proxies']['%sPort' % protocol] = int(port) new_settings[interface]['Proxies']['%sProxy' % protocol] = server - + SCPreferencesPathSetValue(self.session, u'/NetworkServices/', new_settings) class SCPreferencesTests(unittest.TestCase): diff --git a/lib/PyMacAdmin/Security/tests/test_Keychain.py b/lib/PyMacAdmin/Security/tests/test_Keychain.py index a8bf406..35acaac 100644 --- a/lib/PyMacAdmin/Security/tests/test_Keychain.py +++ b/lib/PyMacAdmin/Security/tests/test_Keychain.py @@ -11,23 +11,23 @@ class KeychainTests(unittest.TestCase): """Unit test for the Keychain module""" - + def setUp(self): pass - + def test_load_default_keychain(self): k = Keychain() self.failIfEqual(k, None) - + def test_load_system_keychain(self): k = Keychain('/Library/Keychains/System.keychain') self.failIfEqual(k, None) - + def test_find_airport_password(self): system_keychain = Keychain("/Library/Keychains/System.keychain") # BUG: Most people probably have this - but not everyone? - system_keychain.find_generic_password(account_name="linksys") - + system_keychain.find_generic_password(account_name="linksys") + def test_find_nonexistent_generic_password(self): import uuid system_keychain = Keychain("/Library/Keychains/System.keychain") @@ -39,11 +39,11 @@ def test_add_and_remove_generic_password(self): service_name = "PyMacAdmin Keychain Unit Test" account_name = str(uuid.uuid4()) password = str(uuid.uuid4()) - + i = GenericPassword(service_name=service_name, account_name=account_name, password=password) k.add(i) self.assertEquals(i.password, k.find_generic_password(service_name, account_name).password) - + k.remove(i) self.assertRaises(KeyError, k.find_generic_password, **{"service_name": service_name, "account_name": account_name}) @@ -63,16 +63,16 @@ def test_add_and_remove_internet_password(self): 'authentication_type': 'http', 'password': str(uuid.uuid4()) } - + i = InternetPassword(**kwargs) k.add(i) self.assertEquals(i.password, k.find_internet_password(server_name=kwargs['server_name'], account_name=kwargs['account_name']).password) - + k.remove(i) self.assertRaises(KeyError, k.find_internet_password, **{"server_name": kwargs['server_name'], "account_name": kwargs['account_name']}) if __name__ == '__main__': unittest.main() - + diff --git a/utilities/diskimage_unittesting/dmgtestutilities.py b/utilities/diskimage_unittesting/dmgtestutilities.py index ac4f0fc..39e04a5 100644 --- a/utilities/diskimage_unittesting/dmgtestutilities.py +++ b/utilities/diskimage_unittesting/dmgtestutilities.py @@ -1,5 +1,5 @@ #!/usr/bin/python2.5 -# +# # Use 2.5 so we can import objc & Foundation in tests # # Copyright 2008 Google Inc. All Rights Reserved. @@ -7,9 +7,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/utilities/diskimage_unittesting/macdmgtest.py b/utilities/diskimage_unittesting/macdmgtest.py index 818144a..bf41959 100644 --- a/utilities/diskimage_unittesting/macdmgtest.py +++ b/utilities/diskimage_unittesting/macdmgtest.py @@ -7,9 +7,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/utilities/diskimage_unittesting/run_image_tests.py b/utilities/diskimage_unittesting/run_image_tests.py index c1e3da4..8db6a12 100755 --- a/utilities/diskimage_unittesting/run_image_tests.py +++ b/utilities/diskimage_unittesting/run_image_tests.py @@ -7,9 +7,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -71,7 +71,7 @@ def AttachDiskImage(path): def DetachDiskImage(path): """forcibly unmounts a given dmg from the mountpoint path.""" - + command = ["/usr/bin/hdiutil", "detach", path] returncode = subprocess.call(command) if returncode: @@ -116,7 +116,7 @@ def GetTestSuite(path, mountpoint, options): def ListTests(path): """lists tests in directory "path" ending in _test.py.""" - + pattern = re.compile("^\w*_test.py$", re.IGNORECASE) tests = [] for test in os.listdir(path): diff --git a/utilities/diskimage_unittesting/tests/example_plist_test.py b/utilities/diskimage_unittesting/tests/example_plist_test.py index eefc20e..ea77e15 100755 --- a/utilities/diskimage_unittesting/tests/example_plist_test.py +++ b/utilities/diskimage_unittesting/tests/example_plist_test.py @@ -1,11 +1,11 @@ # Copyright 2008 Google Inc. -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,16 +19,16 @@ /Library/Preferences/com.foo.corp.imageinfo.plist This plist identifies the date at which an image was created, so this series -of tests simply checks whether the plist exists, whether it is a proper file +of tests simply checks whether the plist exists, whether it is a proper file as opposed to a symlink, whether the imageVersion field exists, whether it can be made into a valid date, and whether the date is a sane value. -As with this whole framework, the attribute self.mountpoint refers to the +As with this whole framework, the attribute self.mountpoint refers to the location at which the image to be tested is mounted. Note that we're copying the plist to a temporary location and converting it -to xml1 format rather than binary. We do this so that plistlib works -(it doesn't work on binary plists) and so that we're not actually trying to +to xml1 format rather than binary. We do this so that plistlib works +(it doesn't work on binary plists) and so that we're not actually trying to modify the image, which is mounted in read-only mode. Original Author: Nigel Kersten (nigelk@google.com) @@ -50,7 +50,7 @@ class TestMachineInfo(unittest.TestCase): - + def setUp(self): """copy the original file to a temp plist and convert it to xml1.""" self.tempdir = tempfile.mkdtemp() @@ -62,17 +62,17 @@ def setUp(self): if returncode: raise StandardError("unable to convert plist to xml1") self.imageinfo = plistlib.readPlist(imageinfo_file) - + def tearDown(self): """clean up the temporary location.""" if self.tempdir: if os.path.isdir(self.tempdir): shutil.rmtree(self.tempdir) - + def testFile(self): """test the original file is a proper file.""" self.assert_(os.path.isfile(self.orig_imageinfo_file)) - + def testOwnerGroupMode(self): """test owner, group and mode of original file.""" orig_imageinfo_stat = os.stat(self.orig_imageinfo_file) @@ -83,16 +83,16 @@ def testOwnerGroupMode(self): self.assertEqual(0, owner) self.assertEqual(80, group) self.assertEqual('0644', num_mode) - + def testImageVersionPresent(self): """test that the ImageVersion field is present.""" self.failUnless("ImageVersion" in self.imageinfo) - + def testImageVersionFormat(self): """test that the ImageVersion field is well formed.""" pattern = re.compile("^\d{8}$") self.failUnless(pattern.match(self.imageinfo["ImageVersion"])) - + def testImageVersionValueIsDate(self): """test that the ImageVersion value is actually a date""" image_version = self.imageinfo["ImageVersion"] @@ -101,7 +101,7 @@ def testImageVersionValueIsDate(self): day = int(image_version[6:]) now = datetime.datetime.now() self.failUnless(now.replace(year=year,month=month,day=day)) - + def testImageVersionValueIsCurrentDate(self): """test that the ImageVersion value is a current date.""" image_version = self.imageinfo["ImageVersion"] @@ -109,7 +109,7 @@ def testImageVersionValueIsCurrentDate(self): year_range = range(2006, 2100) self.failUnless(year in year_range) - + if __name__ == "__main__": unittest.main() diff --git a/utilities/diskimage_unittesting/tests/skipsetup_test.py b/utilities/diskimage_unittesting/tests/skipsetup_test.py index efa2d50..f7d1187 100644 --- a/utilities/diskimage_unittesting/tests/skipsetup_test.py +++ b/utilities/diskimage_unittesting/tests/skipsetup_test.py @@ -5,9 +5,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/utilities/diskimage_unittesting/tests/zz_world_writable_test.py b/utilities/diskimage_unittesting/tests/zz_world_writable_test.py index 89dfc26..9073634 100644 --- a/utilities/diskimage_unittesting/tests/zz_world_writable_test.py +++ b/utilities/diskimage_unittesting/tests/zz_world_writable_test.py @@ -5,9 +5,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.