Popular recipes tagged "ctypes" but not "windows" and "immutable"http://code.activestate.com/recipes/tags/ctypes-windows-immutable/2016-05-09T18:00:44-07:00ActiveState Code RecipesUsing ctypes to call C code from Python (Python)
2016-05-09T18:00:44-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580660-using-ctypes-to-call-c-code-from-python/
<p style="color: grey">
Python
recipe 580660
by <a href="/recipes/users/4173351/">Vasudev Ram</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/ffi/">ffi</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/time/">time</a>).
</p>
<p>This recipe shows basic usage of the ctypes module to call C code from Python code.</p>
Simple video with ctypes and Xvid (Tkinter,pygame,...) (Python)
2015-06-29T13:59:38-07:00Jiri Justrahttp://code.activestate.com/recipes/users/4192188/http://code.activestate.com/recipes/579073-simple-video-with-ctypes-and-xvid-tkinterpygame/
<p style="color: grey">
Python
recipe 579073
by <a href="/recipes/users/4192188/">Jiri Justra</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/video/">video</a>, <a href="/recipes/tags/xvid/">xvid</a>).
</p>
<p>This is simple library for playing avi video clips. Videos must be SOUNDLESS (and maybe Xvid encoded wont hurt), to work it properly. I am using it to play intro. It suites good to this purpose, since it can play one clip at a time only.</p>
Reimplementation of rmtree supporting Windows reparse points (Python)
2014-03-08T21:17:41-08:00Charles Grunwaldhttp://code.activestate.com/recipes/users/4175823/http://code.activestate.com/recipes/578849-reimplementation-of-rmtree-supporting-windows-repa/
<p style="color: grey">
Python
recipe 578849
by <a href="/recipes/users/4175823/">Charles Grunwald</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/directories/">directories</a>, <a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/remove/">remove</a>, <a href="/recipes/tags/win32/">win32</a>).
Revision 3.
</p>
<p>Ctypes-based implementation of shutil.rmtree that correctly handles Windows reparse point folders. (symbolic links, junctions, etc)</p>
Windows directory walk using ctypes (Python)
2013-08-09T00:17:00-07:00Shao-chuan Wanghttp://code.activestate.com/recipes/users/4168519/http://code.activestate.com/recipes/578629-windows-directory-walk-using-ctypes/
<p style="color: grey">
Python
recipe 578629
by <a href="/recipes/users/4168519/">Shao-chuan Wang</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/system/">system</a>).
</p>
<p>Windows shell/explorer has a limit size of full path, but both NTFS and ReFS can support full path longer than the limit; this is making os.walk on Windows bad if files are in deeply nested folders, and therefore this recipe.</p>
car.py (Ctypes ARchiver in PYthon [libarchive ffi wrapper]) (Python)
2013-05-28T04:02:15-07:00Mike 'Fuzzy' Partinhttp://code.activestate.com/recipes/users/4179778/http://code.activestate.com/recipes/578531-carpy-ctypes-archiver-in-python-libarchive-ffi-wra/
<p style="color: grey">
Python
recipe 578531
by <a href="/recipes/users/4179778/">Mike 'Fuzzy' Partin</a>
(<a href="/recipes/tags/bzip2/">bzip2</a>, <a href="/recipes/tags/cpio/">cpio</a>, <a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/ffi/">ffi</a>, <a href="/recipes/tags/gzip/">gzip</a>, <a href="/recipes/tags/lzma/">lzma</a>, <a href="/recipes/tags/pax/">pax</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/tar/">tar</a>).
Revision 3.
</p>
<p>CTypes libarchive wrapper, handles extraction only with no arguments.</p>
DDE Client (Python)
2011-04-14T16:33:19-07:00David Naylorhttp://code.activestate.com/recipes/users/4177661/http://code.activestate.com/recipes/577654-dde-client/
<p style="color: grey">
Python
recipe 577654
by <a href="/recipes/users/4177661/">David Naylor</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/dde/">dde</a>, <a href="/recipes/tags/win32/">win32</a>).
</p>
<p>A DDE Client using ctypes for Windows. Unlike the pywin32 implementation this code supports advice requests. </p>
How to Mutate a Float (Python)
2012-05-14T16:49:13-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578132-how-to-mutate-a-float/
<p style="color: grey">
Python
recipe 578132
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/experiment/">experiment</a>, <a href="/recipes/tags/float/">float</a>, <a href="/recipes/tags/structure/">structure</a>).
</p>
<p>This is just an experiment to test my mental understanding of Python. It should not be used in any code as is violates the design principle that floats are to be immutable. The code also abuses <code>ctypes</code> and an understanding of how <code>floats</code> are currently arranged in memory. <code>set_float</code> is not guaranteed to work properly on any system, and may fail to work in the future if the data's arrangement changes.</p>
POSIX Semaphore (FreeBSD) (Python)
2011-04-14T17:54:16-07:00David Naylorhttp://code.activestate.com/recipes/users/4177661/http://code.activestate.com/recipes/577655-posix-semaphore-freebsd/
<p style="color: grey">
Python
recipe 577655
by <a href="/recipes/users/4177661/">David Naylor</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/freebsd/">freebsd</a>, <a href="/recipes/tags/semaphores/">semaphores</a>, <a href="/recipes/tags/signal/">signal</a>, <a href="/recipes/tags/threads/">threads</a>).
</p>
<p>POSIX Semaphore bindings for FreeBSD. </p>
Calling (C-level) finalizers without __del__ (Python)
2011-07-02T18:42:08-07:00Benjamin Petersonhttp://code.activestate.com/recipes/users/4170802/http://code.activestate.com/recipes/577242-calling-c-level-finalizers-without-__del__/
<p style="color: grey">
Python
recipe 577242
by <a href="/recipes/users/4170802/">Benjamin Peterson</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/finalization/">finalization</a>, <a href="/recipes/tags/weakref/">weakref</a>).
Revision 3.
</p>
<p>This recipe is meant for Python classes wrapping ctypes bindings where a C-level finalizer must be invoked when the wrapper is destroyed. It uses weakref callbacks to avoid problems with <code>__del__</code>.</p>
Shutdown your PC by using ctypes (Win32 Platform) (Python)
2009-08-03T10:05:38-07:00Shao-chuan Wanghttp://code.activestate.com/recipes/users/4168519/http://code.activestate.com/recipes/576865-shutdown-your-pc-by-using-ctypes-win32-platform/
<p style="color: grey">
Python
recipe 576865
by <a href="/recipes/users/4168519/">Shao-chuan Wang</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/reboot/">reboot</a>, <a href="/recipes/tags/shutdown/">shutdown</a>, <a href="/recipes/tags/system_programming/">system_programming</a>, <a href="/recipes/tags/win32/">win32</a>).
</p>
<p>It is true that by using win32 extension python modules, such as win32api, win32con, and win32security, we can easily shutdown the computer with a few steps. However, sometimes your python's runtime environment does not provide win32com module (because it is not a build-in module), we may have to shutdown the pc on our own.</p>
<p>By using ctypes, we are still able to shutdown or reboot the PC easily.</p>
C function decorator (Python)
2009-04-29T23:55:03-07:00geremy condrahttp://code.activestate.com/recipes/users/4170000/http://code.activestate.com/recipes/576731-c-function-decorator/
<p style="color: grey">
Python
recipe 576731
by <a href="/recipes/users/4170000/">geremy condra</a>
(<a href="/recipes/tags/cpp/">cpp</a>, <a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/function/">function</a>).
Revision 6.
</p>
<p>This recipe provides an easy-to-use, decorator-based solution to the problem of using functions from other languages, especially C, in Python. It takes advantage of Python's new annotations to provide simple type checking and automatic conversion. If you like it, you may also want to check out my <a href="http://code.activestate.com/recipes/576734/">C structure decorator</a></p>
ctype Enumeration class (Python)
2008-08-10T16:45:46-07:00Devan L Devan Lhttp://code.activestate.com/recipes/users/4166311/http://code.activestate.com/recipes/576415-ctype-enumeration-class/
<p style="color: grey">
Python
recipe 576415
by <a href="/recipes/users/4166311/">Devan L Devan L</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>).
</p>
<p>An example Enumeration class and metaclass to declare an enumeration in ctypes.</p>
Control CPU Usage by using ctypes (Win32 Platform) (Python)
2009-01-26T09:32:34-08:00Shao-chuan Wanghttp://code.activestate.com/recipes/users/4168519/http://code.activestate.com/recipes/576634-control-cpu-usage-by-using-ctypes-win32-platform/
<p style="color: grey">
Python
recipe 576634
by <a href="/recipes/users/4168519/">Shao-chuan Wang</a>
(<a href="/recipes/tags/cpu_usage/">cpu_usage</a>, <a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/system_programming/">system_programming</a>, <a href="/recipes/tags/win32/">win32</a>).
Revision 3.
</p>
<p>This program will make your cpu work at a given cpu usage. It should be also able to work on machines with multi-processors. The program has been tested on Windows xp sp2 with python of version 2.5.4.</p>
<p>The implementation is based on the fact that it will adjust the ratio of being busy over being idle in the main process to approach the target cpu usage rate. </p>
Get CPU Usage by using ctypes (Win32 Platform) (Python)
2009-01-26T06:43:38-08:00Shao-chuan Wanghttp://code.activestate.com/recipes/users/4168519/http://code.activestate.com/recipes/576631-get-cpu-usage-by-using-ctypes-win32-platform/
<p style="color: grey">
Python
recipe 576631
by <a href="/recipes/users/4168519/">Shao-chuan Wang</a>
(<a href="/recipes/tags/cpu_usage/">cpu_usage</a>, <a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/system_programming/">system_programming</a>, <a href="/recipes/tags/win32/">win32</a>).
Revision 2.
</p>
<p>The following code has been tested at Windows XP sp2 with Python of version 2.5.4.</p>
Low level inotify wrapper (Python)
2013-08-12T14:39:57-07:00Louis RIVIEREhttp://code.activestate.com/recipes/users/4035877/http://code.activestate.com/recipes/576375-low-level-inotify-wrapper/
<p style="color: grey">
Python
recipe 576375
by <a href="/recipes/users/4035877/">Louis RIVIERE</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/inotify/">inotify</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/system/">system</a>).
Revision 10.
</p>
<p>This module is meant to be as simple and straightforward as it gets.</p>
Calling Windows API using ctypes and win32con (Python)
2008-07-25T20:01:50-07:00Gary Eakinshttp://code.activestate.com/recipes/users/470921/http://code.activestate.com/recipes/208699-calling-windows-api-using-ctypes-and-win32con/
<p style="color: grey">
Python
recipe 208699
by <a href="/recipes/users/470921/">Gary Eakins</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/windows_api/">windows_api</a>).
Revision 4.
</p>
<p>It is easy to call Windows API dlls using the
ctypes module with win32con defining the
constant values for message identifiers and
parameter flags. The demo code shows a simple
but complete application that registers a
window class and a Python WndProc callback function,
creates the window and pumps messages.</p>