hi, i'm reading the Gray Hat Python,, i reach for this ::
class debugger():
def __init__(self):
self.h_process = None
self.pid = None
self.debugger_active = False
def load(self,path_to_exe):
creation_flags = DEBUG_PROCESS
startupinfo = STARTUPINFO()
process_information = PROCESS_I...
I'm trying to use Python to run pdftotext, but for some reason, my code isn't working. If I run the below, I expect that the content variable would contain the contents of the PDF, but the result I am getting is just an empty string.
Does anybody know what I'm missing?
def getPDFContent(path):
path = "/path/to/a valid/pdffile.pdf"...
Is there a Python way without using a subprocess to clone a git repository? I'm up for using any sort of modules you recommend.
...
Sometimes (in customer's PCs) I need a python script to execute in the Windows shell like a .CMD or .BAT, but without having the .py or .pyw extensions associated with PYTHON / PYTHONW.
I came out with a pair of 'quick'n dirty' solutions:
1)
"""
e:\devtool\python\python.exe %0 :: or %PYTHONPATH%\python.exe
goto eof:
"""
# Python test...
I don't see an option to checkout or list remote/local branches in this module
http://gitorious.org/git-python/
...
I have a command line script that uses the Django ORM and MySQL backend. I want to turn off autocommit and commit manually. For the life of me, I cannot get this to work. Here is a pared down version of the script. A row is inserted into testtable every time I run this and I get this warning from MySQL: "Some non-transactional change...
How can i open file in python and write to it multiple times?
I am using speech recognition, and i want one file to change its contents based on what i say.
Other application needs to be able to read this file.
Is there way to do this, or i need to open/close for each write?
...
In some sphinx docs I am writing, I am including code samples from an ancillary file like so:
.. literalinclude:: mymodule.py
:pyobject: MyClass
:linenos:
This particular doc is a tutorial, where the classes are build up step by step. What I would like to do is include the entire class or a single method, and emphasize only the ...
I want to run my unit tests for a Python Google App Engine project using
Run As => Python unit-test
But when I try that all my Model tests bail with the error message:
BadArgumentError: app must not be empty.
Anyone got this to work?
NB: The tests runs fine using Nose --with-gae. But I want the PyDev integration with hyperlinki...
How do I set a GChat or jabber status via python? Right now I've got this:
import xmpp
new_status = "blah blah blah"
login = 'email'
pwd = 'password'
cnx = xmpp.Client('gmail.com')
cnx.connect( server=('talk.google.com',5223) )
cnx.auth(login, pwd, 'botty')
pres = xmpp.Presence()
pres.setStatus(new_status)
cnx.send(pres)
I...
Hello,
some small application I'm developing uses a module I have written to check certain web services via a REST API. I've been trying to add unit tests to it so I don't break stuff, and I stumbled upon a problem.
I use a lot of signal-slot connections to perform operations asynchronously. For example a typical test would be (pseudo-...
I'd like to bypass some frequent queries by storing str(key) in memcache. When I get the encoded_key back from memcached, I can reconstruct the key with Key(encoded=encoded_key).
But how can I query the actual object from the key? A possibility would be to use
GqlQuery('SELECT * FROM ' + Key(encoded_key).kind() + \
' WHERE __key__ ...
I need to execute this script from my Python script.
Is it possible? The script generate some outputs with some files being written. How do I access these files? I have tried with subprocess call function but without success.
fx@fx-ubuntu:~/Documents/projects/foo$ bin/bar -c somefile.xml -d text.txt -r aString -f anotherString >output
...
I'm trying to solve this programming riddle and although the solution (see code below) works correctly, it is too slow for succesful submission.
Any pointers as how to make this run
faster (removal of every n-th element from a list)?
Or suggestions for a better algorithm to calculate the same; seems I can't think of anything
else than ...
First, I am NOT a python developer. I am trying to fix an issue within a python script that is being executed from the command line. This script was written by someone who is no longer around, and no longer willing to help with issues.
This is python 2.5, and for the moment it cannot be upgraded. Here are the lines of code in question:...
I have a big file I'm reading from, and convert every few lines to an instance of an Object.
Since I'm looping through the file, I stash the instance to a list using list.append(instance), and then continue looping.
This is a file that's around ~100MB so it isn't too large, but as the list grows larger, the looping slows down progress...
We have had a Python script running for many months now that simply scans through a directory of files, and posts each file to our web site via a web service call. The web site is also written in Python.
For no apparent reason, this morning this script started throwing the following error:
urllib2.URLError: <urlopen error (10060, 'Oper...
Are there any good gui libraries for python 3 (NOT 2)? I would love to use tkinter but it's widgets are not native and it is extremely ugly in my opinion. I was wondering if there were any other gui libraries for python 3.
...
I'd like to calculate the mathematical rank of a matrix using scipy. The most obvious function numpy.rank calculates the dimension of an array (ie. scalars have dimension 0, vectors 1, matrices 2, etc...). I am aware that the numpy.linalg.lstsq module has this capability, but I was wondering if such a fundamental operation is built into ...
I'm using Python's max and min functions on lists for a minimax algorithm, and I need the index of the value returned by max() or min(). In other words, I need to know which move produced the max (at a first player's turn) or min (second player) value.
for i in range(9):
newBoard = currentBoard.newBoardWithMove([i / 3, i % 3...