Most viewed recipes tagged "linux"http://code.activestate.com/recipes/tags/linux/views/2017-03-31T14:30:30-07:00ActiveState Code RecipesBash script to create a header for Bash scripts (Bash) 2011-11-02T01:57:07-07:00userendhttp://code.activestate.com/recipes/users/4179007/http://code.activestate.com/recipes/577862-bash-script-to-create-a-header-for-bash-scripts/ <p style="color: grey"> Bash recipe 577862 by <a href="/recipes/users/4179007/">userend</a> (<a href="/recipes/tags/auto/">auto</a>, <a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/create/">create</a>, <a href="/recipes/tags/emacs/">emacs</a>, <a href="/recipes/tags/gpl/">gpl</a>, <a href="/recipes/tags/header/">header</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/script/">script</a>, <a href="/recipes/tags/shell/">shell</a>, <a href="/recipes/tags/vim/">vim</a>). Revision 3. </p> <p>This will create a header for a Bash script. It is a nice way keep a track of what your script does and when it was created, the author of the script, etc.. </p> <p>It will open the script automatically with one of the two most popular editor out there, Vim or Emacs! It also checks to see if there is a script with the same name in the current working directory so it will not overwrite another file.</p> <p>v0.4: I had to kick this up a notch. I took the suggestion of "dev h" to add a chance for the user to select another name for the script.</p> <p>Please leave comments and suggestions.</p> Simple command-line alarm clock in Python (Python) 2015-10-25T18:27:27-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/579117-simple-command-line-alarm-clock-in-python/ <p style="color: grey"> Python recipe 579117 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/alarm/">alarm</a>, <a href="/recipes/tags/clock/">clock</a>, <a href="/recipes/tags/commandline/">commandline</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/time/">time</a>, <a href="/recipes/tags/unix/">unix</a>, <a href="/recipes/tags/windows/">windows</a>). </p> <p>This recipe shows how to create a simple alarm clock in Python, that can be run from the command line in a terminal. It lets you specify the alarm time in minutes as a command line argument, and prints a wake-up message and beeps a few times, after that time arrives. You can use 0 for the minutes to test it immediately, including to adjust the volume using your speaker controls.</p> Python script to create a header for Python scripts (Python) 2011-10-02T15:45:11-07:00userendhttp://code.activestate.com/recipes/users/4179007/http://code.activestate.com/recipes/577846-python-script-to-create-a-header-for-python-script/ <p style="color: grey"> Python recipe 577846 by <a href="/recipes/users/4179007/">userend</a> (<a href="/recipes/tags/2/">2</a>, <a href="/recipes/tags/auto/">auto</a>, <a href="/recipes/tags/create/">create</a>, <a href="/recipes/tags/emacs/">emacs</a>, <a href="/recipes/tags/header/">header</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/script/">script</a>, <a href="/recipes/tags/vim/">vim</a>). Revision 5. </p> <p>This will create a header for a Python script. It is a nice way keep a track of what your script does and when it was created, the author of the script, etc.. </p> <p>Update: Now, it will automatically open with one of the two most popular editors, Vim or Emacs! This script has been updated from the second version to replace spaces with underscores in the title, to convert uppercase to lowercase. It also checks to see if there is a script with the same name in the current working directory so it will not overwrite another file. Please leave comments and suggestions.</p> Decimal Number To Byte(s) And String To Byte(s) Converter. (Python) 2012-01-24T21:11:47-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578025-decimal-number-to-bytes-and-string-to-bytes-conver/ <p style="color: grey"> Python recipe 578025 by <a href="/recipes/users/4177147/">Barry Walker</a> (<a href="/recipes/tags/bytes/">bytes</a>, <a href="/recipes/tags/converter/">converter</a>, <a href="/recipes/tags/decimal/">decimal</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/string/">string</a>, <a href="/recipes/tags/windows/">windows</a>). </p> <p>A function to convert decimal integer numbers, (from 0 to 255), into byte(s) format. Another function calling the above function to convert ASCII strings into byte(s) format.</p> <p>Python 3.1.3 (r313:86834, Nov 28 2010, 10:01:07) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information.</p> <pre class="prettyprint"><code>&gt;&gt;&gt; exec(open('/home/G0LCU/Desktop/Code/d2b.py').read()) &gt;&gt;&gt; a=78 &gt;&gt;&gt; type(a) &lt;class 'int'&gt; &gt;&gt;&gt; b=d2b(a) &gt;&gt;&gt; print(b) b'N' &gt;&gt;&gt; type(b) &lt;class 'bytes'&gt; &gt;&gt;&gt; text="\x00(C)2012, B.Walker, G0LCU.\xFF" &gt;&gt;&gt; len(text) 27 &gt;&gt;&gt; type(text) &lt;class 'str'&gt; &gt;&gt;&gt; newtext=t2b(text) &gt;&gt;&gt; len(newtext) 27 &gt;&gt;&gt; print(newtext) b'\x00(C)2012, B.Walker, G0LCU.\xff' &gt;&gt;&gt; type(newtext) &lt;class 'bytes'&gt; </code></pre> <p>It requires NOTHING special at all to work and can be run like above or imported from the correct "Lib" drawer/folder/directorfy as:-</p> <pre class="prettyprint"><code>&gt;&gt;&gt; import d2b </code></pre> <p>And when imported called as:-</p> <pre class="prettyprint"><code>&gt;&gt;&gt; d2b.d2b(some_number, optional_some_other_mumber)&lt;RETURN/ENTER&gt; </code></pre> <p>OR</p> <pre class="prettyprint"><code>&gt;&gt;&gt; d2b.t2b(some_ASCII_string)&lt;RETURN/ENTER&gt; </code></pre> <p>Read the code for much more information...</p> <p>Issued under the GPL2 licence.</p> <p>Enjoy finding simple solutions to often very difficult problems.</p> <p>Bazza, G0LCU.</p> Access grep from python (Python) 2010-02-24T08:30:25-08:00Daniel Cohnhttp://code.activestate.com/recipes/users/4172918/http://code.activestate.com/recipes/577069-access-grep-from-python/ <p style="color: grey"> Python recipe 577069 by <a href="/recipes/users/4172918/">Daniel Cohn</a> (<a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/grep/">grep</a>, <a href="/recipes/tags/linux/">linux</a>). </p> <p>The recipe below passes a filename and an argument to grep, returning the stdout and stderr. Each line in the stdout will have its line number prepended.</p> Position The Cursor Almost Anywhere Inside Standard Text Mode Python Terminal. (Python) 2012-06-17T17:10:29-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578167-position-the-cursor-almost-anywhere-inside-standar/ <p style="color: grey"> Python recipe 578167 by <a href="/recipes/users/4177147/">Barry Walker</a> (<a href="/recipes/tags/amiga/">amiga</a>, <a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/cursor/">cursor</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/e_uae/">e_uae</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/locate/">locate</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/winuae/">winuae</a>). </p> <p>A DEMO showing the power of the ANSI (ASCII) _Esc_ codes in standard text mode Python.</p> <p>ANSI _Esc_ codes here:- <a href="http://www.termsys.demon.co.uk/vtansi.htm" rel="nofollow">http://www.termsys.demon.co.uk/vtansi.htm</a></p> <p>There are only three important things from the ANSI _Esc_ codes that are needed to obtain a neat finish to a program written in standard text mode Python:-</p> <p>1) Clearing the screen. (Already done without the dedicated ANSI _Esc_ code!)</p> <p>2) Colours and other character attributes. (Already done!)</p> <p>3) A forced printing of a character or string from a given location inside the Terminal window.</p> <p>To clear the screen does NOT require another dedicated ANSI _Esc_ code, (although it exists). This code uses the print("\r\n") method which works in all cases coupled with the one function supplied......</p> <p>For The Classic AMIGA, E-UAE, WinUAE and Linux using Python(s) 1.4.0 to Python 3.2.2. Read the code for more information...</p> <p>Enjoy finding simple solutions to often very difficult problems...</p> <p>Bazza, G0LCU.</p> Simple White Noise Generator Using Standard Python In Linux. (Python) 2011-03-10T18:03:55-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/577604-simple-white-noise-generator-using-standard-python/ <p style="color: grey"> Python recipe 577604 by <a href="/recipes/users/4177147/">Barry Walker</a> (<a href="/recipes/tags/audio/">audio</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/noise/">noise</a>, <a href="/recipes/tags/program/">program</a>, <a href="/recipes/tags/signal/">signal</a>, <a href="/recipes/tags/sound/">sound</a>, <a href="/recipes/tags/source/">source</a>). </p> <p>Simple White Noise Generator Using Standard Python In Linux - noise.py</p> <p>This code is a stand alone program to generate a signal, at the earphone sockets, of white noise.</p> <p>It needs /dev/dsp to work; if you haven't got it then install oss-compat from your distro's repository. (NOTE:- /dev/audio could also be used but I decided to use /dev/dsp to show that this was within easy reach of standard Python too.)</p> <p>Ensure the audio system is NOT in use for this to work and all the levels are set up for your normal requirements. In my case root level WAS NOT required but that does not mean that root level IS NOT required - so be aware.</p> <p>All that is required to make this a piece of audio test equipment is a cable plugged into to the earphone socket. The output level is fully controllable inside the code and the noise is generated in about 10 second bursts</p> <p>Assuming it is copied into the module(s) drawer just type:-</p> <pre class="prettyprint"><code>&gt;&gt;&gt; import noise[RETURN/ENTER] </code></pre> <p>And away you go...</p> <p>This is Public Domain and you may do with it as you like.</p> <p>Read the program for more information. (There will be more to come in the future... :)</p> <p>Enjoy finding simple solutions to often very difficult problems... ;o)</p> <p>73...</p> <p>Bazza, G0LCU...</p> <p>Team AMIGA...</p> Simple 1KHz Audio Function Generator Using Standard Python In Linux... (Python) 2011-03-01T19:37:16-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/577592-simple-1khz-audio-function-generator-using-standar/ <p style="color: grey"> Python recipe 577592 by <a href="/recipes/users/4177147/">Barry Walker</a> (<a href="/recipes/tags/audio/">audio</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/function/">function</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/program/">program</a>, <a href="/recipes/tags/signal/">signal</a>, <a href="/recipes/tags/sound/">sound</a>, <a href="/recipes/tags/source/">source</a>). </p> <h5 id="simple-1khz-audio-function-generator-using-standard-python-in-linux-afgpy">Simple 1KHz Audio Function Generator Using Standard Python In Linux - afg.py</h5> <p>This code is a stand alone program to generate a signal, at the earphone sockets, of 1KHz. It is a basic audio signal generator and can be used as a starter test signal source for amateur electronics enthusiasts testgear suite(s).</p> <p>It needs /dev/audio to work; if you haven't got it then install oss-compat from your distro's repository.</p> <p>Ensure the audio system is NOT in use for this to work.</p> <p>Sine, Square, Triangle, Sawtooth+, Sawtooth-, Pulse+ and Pulse- signals are generated in 10 second bursts. The waveforms generated are unfiltered and therefore not "pure", but hey, an audio function generator signal source, for free, without external hardware, AND, using standard Python, what more do you want... :) An oscilloscope will show the waveforms generated at the earphone socket.</p> <p>Noise is not included but that is SO easy that I left it out FTTB. (This will be a future upload. ;o)</p> <p>All that is required to make this a piece of audio test equipment is a cable plugged into to the earphone socket.</p> <p>Assuming it is copied into the module(s) drawer just type:-</p> <pre class="prettyprint"><code>&gt;&gt;&gt; import afg[RETURN/ENTER] </code></pre> <p>And away you go...</p> <p>This is Public Domain and you may do with it as you like.</p> <p>Read the program for more information. (There will be more to come in the future... :)</p> Colo(u)rs Inside Text Mode Python... (Python) 2012-08-21T21:01:57-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578101-colours-inside-text-mode-python/ <p style="color: grey"> Python recipe 578101 by <a href="/recipes/users/4177147/">Barry Walker</a> (<a href="/recipes/tags/amiga/">amiga</a>, <a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/color/">color</a>, <a href="/recipes/tags/colour/">colour</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/display/">display</a>, <a href="/recipes/tags/e_uae/">e_uae</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/windows/">windows</a>, <a href="/recipes/tags/winuae/">winuae</a>). Revision 2. </p> <p>A simple DEMO to show how to enhance Python inside a Terminal. This works on Classic AMIGAs, E-UAE, Debian Linux 6.0.0, PCLinuxOS 2009, Windows XP and Vista and WinUAE, from Python 1.4.0 to 3.3A2.</p> <p>Due to a complaint about my _fun_ upload recently I decided to post this so that the MANY can now find out how to manipulate text inside a Python Terminal window so that it looks much better.</p> <p>Read the code for more information...</p> <p>Enjoy finding simple solutions to often very difficult problems...</p> <p>Bazza...</p> A DEMO to show how to write text into the Python terminal Title Bar... (Python) 2013-09-17T17:55:53-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578662-a-demo-to-show-how-to-write-text-into-the-python-t/ <p style="color: grey"> Python recipe 578662 by <a href="/recipes/users/4177147/">Barry Walker</a> (<a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/bar/">bar</a>, <a href="/recipes/tags/cygwin/">cygwin</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/title/">title</a>, <a href="/recipes/tags/title_bar/">title_bar</a>). </p> <p>This DEMO is show how to write some text of your choice into the Title Bar of the Python terminal window.</p> <p>Firstly it imports "time" just for this demo so that a simple time delay can be generated. Next the Python terminal window is written to for the 5 seconds of delay; see code. And finally the Title Bar is restored to normal...</p> <p>A snapshot image can be seen here:-</p> <p><a href="http://wisecracker.host22.com/public/Title_Bar.jpg" rel="nofollow">http://wisecracker.host22.com/public/Title_Bar.jpg</a></p> <p>Bazza...</p> Unix tee-like functionality via a Python class (Python) 2017-03-31T14:30:30-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580767-unix-tee-like-functionality-via-a-python-class/ <p style="color: grey"> Python recipe 580767 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/cli/">cli</a>, <a href="/recipes/tags/command/">command</a>, <a href="/recipes/tags/commandline/">commandline</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/tee/">tee</a>, <a href="/recipes/tags/unix/">unix</a>, <a href="/recipes/tags/utilities/">utilities</a>, <a href="/recipes/tags/windows/">windows</a>). </p> <p>The Unix tee commmand, when used in a command pipeline, allows you to capture the output of the preceding command to a file or files, while still sending it on to standard output (stdout) for further processing via other commands in a pipeline, or to print it, etc.</p> <p>This recipe shows how to implement simple tee-like functionality via a Python class. I do not aim to exactly replicate the functionality of the Unix tee, only something similar.</p> <p>More details and sample output here:</p> <p><a href="https://jugad2.blogspot.in/2017/03/a-python-class-like-unix-tee-command.html" rel="nofollow">https://jugad2.blogspot.in/2017/03/a-python-class-like-unix-tee-command.html</a></p> Running linux command inside your python script (Python) 2012-09-09T08:08:46-07:00Ahmed Kamelhttp://code.activestate.com/recipes/users/4183490/http://code.activestate.com/recipes/578254-running-linux-command-inside-your-python-script/ <p style="color: grey"> Python recipe 578254 by <a href="/recipes/users/4183490/">Ahmed Kamel</a> (<a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/sysadmin/">sysadmin</a>). </p> <p>Running any linux command line inside your python script.</p> High level inotify wrapper (Python) 2008-09-21T05:17:23-07:00Louis RIVIEREhttp://code.activestate.com/recipes/users/4035877/http://code.activestate.com/recipes/576377-high-level-inotify-wrapper/ <p style="color: grey"> Python recipe 576377 by <a href="/recipes/users/4035877/">Louis RIVIERE</a> (<a href="/recipes/tags/inotify/">inotify</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/system/">system</a>). Revision 4. </p> <p>This is an exemple to show how to use the inotify module, it could be very usefull unchanged though.</p> <p>A Watcher instance let you define callbacks for any event that occur on any file or directory and subdirectories.</p> <p>The inotify module is from <a href="http://code.activestate.com/recipes/576375/">Recipe 576375</a></p> Linux Terminal Color Setter (Python) 2008-09-11T17:08:30-07:00Collin Stockshttp://code.activestate.com/recipes/users/4149235/http://code.activestate.com/recipes/576503-linux-terminal-color-setter/ <p style="color: grey"> Python recipe 576503 by <a href="/recipes/users/4149235/">Collin Stocks</a> (<a href="/recipes/tags/just_for_fun/">just_for_fun</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/terminal/">terminal</a>, <a href="/recipes/tags/unix/">unix</a>). </p> <p>This module can move the cursor around in the terminal, change the text color, highlighting color, et cetera, bold, underlined, flashing (if supported). It also has a word wrap function, and can center text.</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> Handling ANSI Terminal. (Python) 2010-02-09T05:51:23-08:00Louis RIVIEREhttp://code.activestate.com/recipes/users/4035877/http://code.activestate.com/recipes/574451-handling-ansi-terminal/ <p style="color: grey"> Python recipe 574451 by <a href="/recipes/users/4035877/">Louis RIVIERE</a> (<a href="/recipes/tags/ansi/">ansi</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/system/">system</a>, <a href="/recipes/tags/terminal/">terminal</a>). Revision 9. </p> <p>This function can be used, with or instead of print, to get <a href="http://en.wikipedia.org/wiki/ANSI_escape_code">ANSI</a> output.</p> Daemon to create a wifi hotspot on linux (Python) 2014-07-08T04:45:27-07:00Prahlad Yerihttp://code.activestate.com/recipes/users/4190347/http://code.activestate.com/recipes/578904-daemon-to-create-a-wifi-hotspot-on-linux/ <p style="color: grey"> Python recipe 578904 by <a href="/recipes/users/4190347/">Prahlad Yeri</a> (<a href="/recipes/tags/hotspot/">hotspot</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/wifi/">wifi</a>). </p> <p>This recipe is based on Hotspotd, a small linux daemon to create a wifi hotspot on linux. It depends on hostapd for AP provisioning and dnsmasq to assign IP addresses to devices.</p> <p>Hotspotd works by creating a virtual NAT (Network address transation) table between your connected device and the internet using iptables.</p> File comparison utility in Python (Python) 2016-03-26T18:31:11-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580631-file-comparison-utility-in-python/ <p style="color: grey"> Python recipe 580631 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/commandline/">commandline</a>, <a href="/recipes/tags/comparison/">comparison</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/unix/">unix</a>, <a href="/recipes/tags/utilities/">utilities</a>). </p> <p>This is a recipe to compare any two files via a Python command-line program. It is like a basic version of the cmp command of Unix or the fc.exe (file compare) command of Windows.</p> Clear screen and beep for various platforms. (Python) 2011-02-26T14:26:02-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/577588-clear-screen-and-beep-for-various-platforms/ <p style="color: grey"> Python recipe 577588 by <a href="/recipes/users/4177147/">Barry Walker</a> (<a href="/recipes/tags/amiga/">amiga</a>, <a href="/recipes/tags/audio/">audio</a>, <a href="/recipes/tags/beep/">beep</a>, <a href="/recipes/tags/clearscreen/">clearscreen</a>, <a href="/recipes/tags/display/">display</a>, <a href="/recipes/tags/error_beep/">error_beep</a>, <a href="/recipes/tags/error_sound/">error_sound</a>, <a href="/recipes/tags/e_uae/">e_uae</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/screenclear/">screenclear</a>, <a href="/recipes/tags/sound/">sound</a>, <a href="/recipes/tags/windows/">windows</a>, <a href="/recipes/tags/winuae/">winuae</a>). </p> <p>This little module gives a clear screen and beep for the classic AMIGA, WinUAE, Windows and Linux all in CLI/Command-Prompt/Terminal mode.</p> <p>It works from Python 1.4.x to 2.7.x; talk about backwards compatibility... ;oD With very little modification it will work on Python 3.x.x easily.)</p> <p>See the file clsbeep.py attached for more information.</p> <p>it is saved as clsbeep.py and placed into the Python - Lib drawer or where-ever the modules are located and called as a module:-</p> <pre class="prettyprint"><code>&gt;&gt;&gt; import clsbeep </code></pre> <p>Its usage is:-</p> <p>clsbeep.cls() and clears the screen. clsbeep.beep() and creates an error beep. clsbeep.both() creates an error beep first then clears the screen.</p> <p>It is Public Domain and if you modify it to suit other platforms please let me have a copy of your code... :)</p> <p>Enjoy finding simple solutions to often very difficult problems. ;o)</p> Interrogating linux /dev/usb/hiddev0 in python (Python) 2009-07-07T01:32:17-07:00Dima Tisnekhttp://code.activestate.com/recipes/users/4068698/http://code.activestate.com/recipes/576834-interrogating-linux-devusbhiddev0-in-python/ <p style="color: grey"> Python recipe 576834 by <a href="/recipes/users/4068698/">Dima Tisnek</a> (<a href="/recipes/tags/hid/">hid</a>, <a href="/recipes/tags/hiddev/">hiddev</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/usb/">usb</a>). </p> <p>What this recipe does:</p> <p>Maps linux usb hid ioctls and related C structs to python; Call ioctls, make some sense of output. Prints all reports for the device with some info.</p> <p>Works with python 2.4 (tested python 2.4.6 on linux amd64). Would need changes (e.g. print) for python 3.0. Might need changes (ioctl signed/unsigned "FIX") for newer python than tested.</p>