Popular recipes tagged "user"http://code.activestate.com/recipes/tags/user/2013-09-13T06:34:08-07:00ActiveState Code Recipeseasy user input (Python) 2013-09-13T06:34:08-07:00yotahttp://code.activestate.com/recipes/users/4184815/http://code.activestate.com/recipes/578552-easy-user-input/ <p style="color: grey"> Python recipe 578552 by <a href="/recipes/users/4184815/">yota</a> (<a href="/recipes/tags/input/">input</a>, <a href="/recipes/tags/python3/">python3</a>, <a href="/recipes/tags/query/">query</a>, <a href="/recipes/tags/user/">user</a>). Revision 7. </p> <p>Improvement over <a href="http://code.activestate.com/recipes/577058/">Recipe 577058</a> and cie.</p> <p><code>easy_input()</code> function extends the built-in <code>input()</code> function. A question is prompted as well as some expected answers.</p> <p>The user input can be incomplete (ie. <code>y</code> or <code>ye</code> instead of <code>yes</code>)</p> <ul> <li>If no list of expected answer is provided, default will be "yes/no".</li> <li>If no default answer is provided, default will be the first expected answer.</li> </ul> <p>Try and see.</p> <p>Disclaimer: written in python3, meant for *nix shell, indented with tabs</p> <p><strong>Avoided caveat:</strong> If some expected <code>answer</code> have the same beginning, the user can not enter too few letters. Ex: <code>answer = ['continue', 'test', 'testicle']</code>, user can not input <code>t</code>, <code>te</code> or <code>tes</code> because it will be ambiguous. User can however input <code>test</code>, which is not.</p> user and root directory logfile (Python) 2011-03-22T10:00:49-07:00justin drakehttp://code.activestate.com/recipes/users/4177409/http://code.activestate.com/recipes/577619-user-and-root-directory-logfile/ <p style="color: grey"> Python recipe 577619 by <a href="/recipes/users/4177409/">justin drake</a> (<a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/log/">log</a>, <a href="/recipes/tags/time/">time</a>, <a href="/recipes/tags/user/">user</a>). </p> <p>script to retrieve time, current user, and root of directory output to spam.txt</p> <p>want to add more like windows version, bios info and other useful diagnostic information </p> <p>free to use and modify welcome any advice or corrections learning python hope this turns into a script to create a organized personal report of customer's pc</p> Subprocess As Another User (Python) 2010-12-23T00:10:08-08:00Eric Pruitthttp://code.activestate.com/recipes/users/4170757/http://code.activestate.com/recipes/577495-subprocess-as-another-user/ <p style="color: grey"> Python recipe 577495 by <a href="/recipes/users/4170757/">Eric Pruitt</a> (<a href="/recipes/tags/login/">login</a>, <a href="/recipes/tags/subprocess/">subprocess</a>, <a href="/recipes/tags/user/">user</a>, <a href="/recipes/tags/windows/">windows</a>). Revision 3. </p> <p>Modifies the subprocess module and supplies a new class, LoginSTARTUPINFO, to launch processes as another user on Windows. Requires the pywin32 libraries, but the system ../lib/subprocess.py does not need to be modified.</p> <pre class="prettyprint"><code>&gt;&gt;&gt; import subprocesswin32 as subprocess &gt;&gt;&gt; sysuser = LoginSTARTUPINFO("username", "machine", "passwd123") &gt;&gt;&gt; stdout, stderr = subprocess.Popen("cmd.exe", stdout=subprocess.PIPE, ... startupinfo=sysuser).communicate() </code></pre>