python

Windows Authentication with Python and urllib2

Hi, I want to grab some data off a webpage that requires my windows username and password. So far, I've got: opener = build_opener() try: page = opener.open("http://somepagewhichneedsmywindowsusernameandpassword/") print page except URLError: print "Oh noes." Is this supported by urllib2? I've found Python NTLM, but that...

pywikipedia logging in?

For various reasons I can't use login.py to log me in so I was wondering if anyone knew code so that I could log in to Wikipedia with my script without running a separate script? Cheers! ...

Reading "raw" Unicode-strings in Python

Dear all, I am quite new to Python so my question might be silly, but even though reading through a lot of threads I didn't find an answer to my question. I have a mixed source document which contains html, xml, latex and other textformats and which I try to get into a latex-only format. Therefore, I have used python to recognise ...

Changing a get request to a post in python?

Hi, I have this- en.wikipedia.org/w/api.php?action=login&lgname=user&lgpassword=password But it doesn't work because it is a get request. What would the the post request version of this? Cheers! ...

Python MemoryError - how can I force object deletion

I have a program that process several files, and for each file a report is generated. The report generating part is a separate function that takes a filename, then returns. During report generation, intermediate parts are cached in memory, as they may be used for several parts of the report, to avoid recalculating. When I run this progr...

Resize fields in Django Admin

Django tends to fill up horizontal space when adding or editing entries on the admin, but, in some cases, is a real waste of space, when, i.e., editing a date field, 8 characters wide, or a CharField, also 6 or 8 chars wide, and then the edit box goes up to 15 or 20 chars. How can I tell the admin how wide a textbox should be, or the he...

Problems with python script on web hosting

Hi guys, I have written a script for Wikipedia & it works fine on my computer, yet when I upload it to my web host(Dreamhost) it doesn't work & says that the user I am trying to log in as is blocked-this is not true, it works on my computer & I#m not blocked. This is the exact error message I get- A problem occurred in a Python script. ...

Possible: Program executing Qt3 and Qt4 code?

Maybe its a very dumb question but I hope you can give me some answers. I have a commercial application which uses Qt3 for its GUI and an embedded Python interpreter (command line) for scripting. I want to write a custom plugin for this application which uses Qt4. The plugin is mainly a subclassed QMainWindow-class that is linked into a...

Django objects change model field

This doesn't work: >>> pa = Person.objects.all() >>> pa[2].nickname u'arst' >>> pa[2].nickname = 'something else' >>> pa[2].save() >>> pa[2].nickname u'arst' But it works if you take p = Person.objects.get(pk=2) and change the nick. Why so. ...

A reliable way to determine if ntfs permissions were inherited

Hello, I have a somewhat obscure question here. What I need: To determine if the permissions (or, strictly speaking, a specific ACE of a DACL) of a file/folder was inherited. How I tried to solve this: using winapi bindings for python (win32security module, to be precise). Here is the stripped down version, that does just that, - it s...

Python MS Word

I'm looking into a requirements management system (like requiste pro - Rational Rose) - and will need to read through a MS Word doc searching for specific tags - on either a windows or Apple OS environment. Are there any known frameworks for this (I couldn't find any) - or suggested approaches? Just to add some clarification - this wou...

Recommended way to run another program from within a Python script

Possible Duplicate: How to call external command in Python I'm writing a Python script on a windows machine. I need to launch another application "OtherApp.exe". What is the most suitable way to do so? Till now I've been looking at os.system() or os.execl() and they don't quite look appropriate (I don't even know if the latter...

Send an xmpp message using a python library

How can I send an XMPP message using one of the following Python libraries: wokkel, xmpppy, or jabber.py ? I think I am aware of the pseudo-code, but so far have not been able to get one running correctly. This is what I have tried so far: Call some API and pass the servername and port number to connect to that server. Call some API...

How to show characters non ascii in python?

Hi, I'm using the Python Shell in this way: >>> s = 'Ã' >>> s '\xc3' How can I print s variable to show the character Ã??? This is the first and easiest question. Really, I'm getting the content from a web page that has non ascii characters like the previous and others with tilde like á, é, í, ñ, etc. Also, I'm trying to execute a re...

Storing information on points in a 3d space

I'm writing some code (just for fun so far) in Python that will store some data on every point in a 3d space. I'm basically after a 3d matrix object that stores arbitary objects that will allow me to do some advanced selections, like: Get the point where x=1,y=2,z=3. Getting all points where y=2. Getting all points within 3 units of po...

Django/Python EnvironmentError?

I am getting an error when I try to use syncdb: python manage.py syncdb Error message: File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 83, in __init__ raise EnvironmentError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e) EnvironmentError: ...

python monitoring over serial port

Good afternoon, I would ask some suggestion about the best way to monitor events over the serial port. I'm using PySerial to write "commands" over the serial port towards some devices and I would like to receive feedback about the status of this devices. Wich is the best way: 1) fullfill a pipe and read into, 2) a new thread delegate...

Python and Qt (PyQt) - calling method before resize event

Hello, i have a question. There is application class in my program. It is inherited from QtGui.QMainWindow. In ini I call my own method which works with graphic. And it should be called before resize event. How can i do that? Thanks. EDIT: As you can se here the value of resize event is 14, and show event is 17. So i should find event w...

Django/Python UserWarning Error

I keep getting this error/warning, which is annoying, and wanted to see if I can fix it, but I'm not sure where to start (I'm a newbie): /home/simi/workspace/hssn_svn/hssn/../hssn/log/loggers.py:28: UserWarning: ERROR: Could not configure logging warnings.warn('ERROR: Could not configure logging', UserWarning) I'm getting this when ...

Python: Inheriting from Built-In Types

Hi fellow Pythonistas, I have a question concerning subtypes of built-in types and their constructors. I want a class to inherit both from tuple and from a custom class. Let me give you the concrete example. I work a lot with graphs, meaning nodes connected with edges. I am starting to do some work on my own graph framework. There is ...