[CalendarServer-changes] [2382]
CalendarServer/branches/users/wsanchez/logging/twistedcaldav/util.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed May 7 13:29:53 PDT 2008
Revision: 2382
http://trac.macosforge.org/projects/calendarserver/changeset/2382
Author: wsanchez at apple.com
Date: 2008-05-07 13:29:52 -0700 (Wed, 07 May 2008)
Log Message:
-----------
Don't import the same things twice.
Modified Paths:
--------------
CalendarServer/branches/users/wsanchez/logging/twistedcaldav/util.py
Modified: CalendarServer/branches/users/wsanchez/logging/twistedcaldav/util.py
===================================================================
--- CalendarServer/branches/users/wsanchez/logging/twistedcaldav/util.py 2008-05-07 20:24:46 UTC (rev 2381)
+++ CalendarServer/branches/users/wsanchez/logging/twistedcaldav/util.py 2008-05-07 20:29:52 UTC (rev 2382)
@@ -27,42 +27,36 @@
except ImportError:
hasCtypes = False
-if sys.platform == 'darwin' and hasCtypes:
- from ctypes import *
- import ctypes.util
+if sys.platform == "darwin" and hasCtypes:
+ libc = cdll.LoadLibrary(ctypes.util.find_library("libc"))
- libc = cdll.LoadLibrary(ctypes.util.find_library('libc'))
-
def getNCPU():
ncpu = c_int(0)
-
size = c_int(sizeof(ncpu))
- libc.sysctlbyname('hw.ncpu',
- c_voidp(addressof(ncpu)),
- addressof(size),
- None, 0)
+ libc.sysctlbyname(
+ "hw.ncpu",
+ c_voidp(addressof(ncpu)),
+ addressof(size),
+ None, 0
+ )
return int(ncpu.value)
-elif sys.platform == 'linux2' and hasCtypes:
- from ctypes import *
- import ctypes.util
+elif sys.platform == "linux2" and hasCtypes:
+ libc = cdll.LoadLibrary(ctypes.util.find_library("libc"))
- libc = cdll.LoadLibrary(ctypes.util.find_library('libc'))
-
def getNCPU():
return libc.get_nprocs()
else:
def getNCPU():
if not hasCtypes:
- msg = "without ctypes"
+ msg = " without ctypes"
else:
msg = ""
- raise NotImplementedError(
- "getNCPU not supported on %s %s" % (sys.platform, msg))
+ raise NotImplementedError("getNCPU not supported on %s%s" % (sys.platform, msg))
##
#
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080507/14edfcd7/attachment.html
More information about the calendarserver-changes
mailing list