[CalendarServer-changes] [12093] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 12 11:23:13 PDT 2014


Revision: 12093
          http://trac.calendarserver.org//changeset/12093
Author:   wsanchez at apple.com
Date:     2013-12-13 16:33:05 -0800 (Fri, 13 Dec 2013)
Log Message:
-----------
Stop being soft on ctypes.

Modified Paths:
--------------
    CalendarServer/trunk/pyflakes
    CalendarServer/trunk/twistedcaldav/util.py

Modified: CalendarServer/trunk/pyflakes
===================================================================
--- CalendarServer/trunk/pyflakes	2013-12-14 00:25:35 UTC (rev 12092)
+++ CalendarServer/trunk/pyflakes	2013-12-14 00:33:05 UTC (rev 12093)
@@ -19,9 +19,8 @@
 
 tmp="$(mktemp "/tmp/pyflakes.XXXXX")";
 
-cd "${wd}" && "${pyflakes}" "$@" | sed                                    \
-  -e "/'from ctypes import \\*' used; unable to detect undefined names/d" \
-  -e "/xmlext.py:[0-9][0-9]*: /d"                                         \
+cd "${wd}" && "${pyflakes}" "$@" | sed  \
+  -e "/xmlext.py:[0-9][0-9]*: /d"       \
   | tee "${tmp}";
 
 if [ -s "${tmp}" ]; then error="true"; else error="false"; fi;

Modified: CalendarServer/trunk/twistedcaldav/util.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/util.py	2013-12-14 00:25:35 UTC (rev 12092)
+++ CalendarServer/trunk/twistedcaldav/util.py	2013-12-14 00:33:05 UTC (rev 12093)
@@ -35,14 +35,20 @@
 ##
 
 try:
-    from ctypes import *
-    import ctypes.util
+    from ctypes import (
+        cdll,
+        c_int, c_uint64, c_ulong,
+        c_char_p, c_void_p,
+        addressof, sizeof, c_size_t,
+        connect,
+    )
+    from ctypes.util import find_library
     hasCtypes = True
 except ImportError:
     hasCtypes = False
 
 if sys.platform == "darwin" and hasCtypes:
-    libc = cdll.LoadLibrary(ctypes.util.find_library("libc"))
+    libc = cdll.LoadLibrary(find_library("libc"))
 
     def getNCPU():
         """
@@ -56,8 +62,8 @@
         ]
         libc.sysctlbyname(
             "hw.ncpu",
-            c_voidp(addressof(ncpu)),
-            c_voidp(addressof(size)),
+            c_void_p(addressof(ncpu)),
+            c_void_p(addressof(size)),
             None,
             0
         )
@@ -77,8 +83,8 @@
         ]
         libc.sysctlbyname(
             "hw.memsize",
-            c_voidp(addressof(memsize)),
-            c_voidp(addressof(size)),
+            c_void_p(addressof(memsize)),
+            c_void_p(addressof(size)),
             None,
             0
         )
@@ -87,7 +93,7 @@
 
 
 elif sys.platform == "linux2" and hasCtypes:
-    libc = cdll.LoadLibrary(ctypes.util.find_library("libc"))
+    libc = cdll.LoadLibrary(find_library("libc"))
 
     def getNCPU():
         return libc.get_nprocs()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/7ae18859/attachment.html>


More information about the calendarserver-changes mailing list