python

Python, generating PDF using ReportLab.Platypus SimpleDocTemplate, date/time in header

Hi, I'm working on a project in Python/Django which uses ReportLab's SimpleDocTemplate to generate PDF documents. All the documents generated have the current date/time printed in the top right corner. I can't see that it's being done anywhere in my code, is this a default behaviour in the SimpleDocTemplate object? How do I get rid o...

XMPPPY have function to manage invitation in client side?

Hi, I'm coding by python about Gtalk I use XMPPPY. But I can chat with GTalk client but the problem is I can't accept invitation. Is XMPPY can do ? ...

Can we do a smart-copy in Python?

I'm a python newbie, and I'm writing a script to copy compiled files from one location to another. What I have is quite simple at the moment, something like this: import os import shutil shutil.copy2 (src, dst) #... many more shutil.copy commands #src is a filename string #dst is the directory where the file is to be copied My proble...

Django test FileField using test fixtures

I'm trying to build tests for some models that have a FileField. The model looks like this: class SolutionFile(models.Model): ''' A file from a solution. ''' solution = models.ForeignKey(Solution) file = models.FileField(upload_to=make_solution_file_path) I have encountered two problems: When saving data to a fix...

Django Loading Templates with Inheritance from Specific Directory

In our project, we have a bunch of different templates that clients to choose from (for their webstore). The file layout is something like this: templates cart.html closed.html head.html standard bishop default indiana marley mocca nihilists raconteurs tripw...

Paginating the results of a Django forms POST request

I'm using Django Forms to do a filtered/faceted search via POST, and I would like to Django's paginator class to organize the results. How do I preserve the original request when passing the client between the various pages? In other words, it seems that I lose the POST data as soon as I pass the GET request for another page back to my...

How to I disable and re-enable console logging in Python?

I am using python logging module and I want to disable the console logging for some time but it doesn't work. #!/usr/bin/python import logging logger = logging.getLogger() # this gets the root logger # ... here I add my own handlers #logger.removeHandler(sys.stdout) #logger.removeHandler(sys.stderr) print logging.handl...

How to break the following line of python

Hello Stack Overflow, I have come upon a couple of lines of code similar to this one, but I'm unsure how I should break it: blueprint = Blueprint(self.blueprint_map[str(self.ui.blueprint_combo.currentText())], runs=self.ui.runs_spin.text(), me=self.ui.me_spin.text(), pe=self.ui.pe_skill_combo.currentIndex()) Thanks in advance ...

Making super() work in Python's urllib2.Request

This afternoon I spent several hours trying to find a bug in my custom extension to urllib2.Request. The problem was, as I found out, the usage of super(ExtendedRequest, self), since urllib2.Request is (I'm on Python 2.5) still an old style class, where the use of super() is not possible. The most obvious way to create a new class with ...

Django legacy database encoding

Hello, I'm sure this question is not specific to django, but since I couldn't find any solution for my problem in other questions about python and encodings, I'm going to ask this. I need to add new features to existing website which is written in PHP using MySQL as backend. I inspected the database and created models for tables I am goi...

Is there a Django ModelField that allows for multiple choices, aside from ManyToMany?

I'd like the user to be able to make multiple selections via the admin interface, and store the result as a list of comma-separated values. A select-multiple or a list of checkboxes would be great. However, I don't need the items in this list of values to refer to any models in particular... I just want a text list of items, plain and si...

convert integer to a string in a given numeric base in python

Python allows easy creation of an integer from a string of a given base via int(str,base). I want to perform the inverse: creation of a string from an integer. i.e. I want some function int2base(num,base) such that: int( int2base( X , BASE ) , BASE ) == X the function name/argument order is unimportant For any number X and ba...

overloading augmented arithmetic assignments in python

Hi all. I'm new to Python so apologies in advance if this is a stupid question. For an assignment I need to overload augmented arithmetic assignments(+=, -=, /=, =, *=, %=) for a class myInt. I checked the Python documentation and this is what I came up with: def __iadd__(self, other): if isinstance(other, myInt): self.a +...

How do I get the content-type from return of urlopen(url) in python2.x?

Are theere any functions in 3.x using the http.client.HTTPMessage().get_content_type() ? ...

Python .flv media file conversion

I'm looking for a library similar to FFDshow to help me convert .flv to .avi format and possibly do more. I understand that I can do this via VLC player, but I'd rather do it manually with Python (and in bulk). Similar to: http://stackoverflow.com/questions/1233685/media-conversion-library-plugin-preferably-php http://stackoverflow.com/...

Dynamic class loading in Python 2.6: RuntimeWarning: Parent module 'plugins' not found while handling absolute import

I am working on a plugin system where plugin modules are loaded like this: def load_plugins(): plugins=glob.glob("plugins/*.py") instances=[] for p in plugins: try: name=p.split("/")[-1] name=name.split(".py")[0] log.debug("Possible plugin: %s", name) f, file, desc=imp.find_module(name...

How can I use a large wxCursor?

The wx.Cursor class automatically scales the image I give it to 32x32 and I need to use a cursor that is larger than that. On http://support.microsoft.com/kb/307213 I saw what might be the reason for this behavior Although cursors can, in theory, be any size, the system imposes a standard size that is exposed by means of the ...

How to convert from IEEE Python float to Microsoft Basic float

I got Python float value and I need to convert it in to Microsoft Basic Float (MBF) format. Luckily, Got some code from internet that does the reverse. def fmsbin2ieee(self,bytes): """Convert an array of 4 bytes containing Microsoft Binary floating point number to IEEE floating point format (which is used by Python)""" as_in...

Can you auto hide frames/dialogs using wxPython?

I would like to create an application that has 3-4 frames (or windows) where each frame is attached/positioned to a side of the screen (like a task bar). When a frame is inactive I would like it to auto hide (just like the Windows task bar does; or the dock in OSX). When I move my mouse pointer to the position on the edge of the screen w...

Grab a line's whitespace/indention with Python

Basically, if I have a line of text which starts with indention, what's the best way to grab that indention and put it into a variable in Python? For example, if the line is: \t\tthis line has two tabs of indention Then it would return '\t\t'. Or, if the line was: this line has four spaces of indention Then it would return four...