python

django binary (no source code) deployment

Hello all, is there possible only to deploy binary version of web application based on django , no source code publish? Thanks ...

In GTK on Windows, how do I change the background color of the whole app?

According to http://www.pygtk.org/docs/pygtk/gtk-constants.html, there are five state types: STATE_NORMAL, STATE_INSENSITIVE, etc. I want to set the background color of a Table, HBox, VBox, whatever, and I've tried setting every possible color of every kind of state: style = self.get_style() for a in (style.base, style.fg, style...

Qt QFileDialog QSizePolicy of sidebar

With a QFileDialog I'm trying to change the size of the side bar in a QFileDialog. I want it to have a larger width. I was looking at dir(QtGui.QFileDialog) which shows a plethora of functions/methods and dir(QtGui.QSizePolicy) which seemed like the right choice. I've not been able to manipulate the size of the side bar though. print 's...

Optimal way to replace characters in large string with Python?

Hi there. I'm dealing with cleaning relatively large (30ish lines) blocks of text. Here's an excerpt: PID|1||06225401^^^PA0^MR||PATIENT^FAKE R|||F PV1|1|I|||||025631^DoctorZ^^^^^^^PA0^^^^DRH|DRH||||... ORC|RE||CYT-09-06645^AP||||||200912110333|INTERFACE07 OBR|1||CYT09-06645|8104^^L|||20090602|||||||200906030000[co...

Multiple blocks of same name in Jinja2

In Jinja2, I have a base template like this: <title>{% block title %}{% endblock %} - example.com</title> [...] <h1> {% block title %}{% endblock %} - example.com </h1> Jinja2, then, fails with the following message: lines = [self.message, ' ' + location] : block 'title' defined twice It must be now evident as to what I am t...

Generating a graph with multiple (sets of multiple sets of multiple) X-axis data sets

I am looking for a way to generate a graph with multiple sets of data on the X-axis, each of which is divided into multiple sets of multiple sets. I basically want to take this graph and place similar graphs side by side with it. I am trying to graph the build a graph of the duration (Y-axis) of the same jobs (0-3) with different confi...

why does this python program print True

x=True def stupid(): x=False stupid() print x ...

How can I highlight a row in a gtk.Table?

I want to highlight specific rows in a gtk.Table. I also want a mouseover to highlight it w/ a different color (like on a link in a web browser). I thought of just packing each cell with an eventBox and changing the STATE_NORMAL and STATE_PRELIGHT bg colors, which does work, but mousing over the eventbox doesn't work. Is there a better w...

What's the point of alloc_color() in gtk?

Various examples always use alloc_color() and stuff like gtk.color.parse('red'), etc. I just do gtk.gdk.Color(65535,0,0), and that seems to work. What's the need for alloc_color? ...

subclassing int to attain a Hex representation

Basically I want to have access to all standard python int operators, eg __and__ and __xor__ etc, specifically whenever the result is finally printed I want it represented in Hex format. (Kind of like putting my calculator into Hex mode) class Hex(int): def __repr__(self): return "0x%x"%self __str__=__repr__ # this certainly he...

pygtk: free variable referenced before assignment in enclosing scope

Very bizarre scoping error which I can't even see. Inside of an updater function, I have a nested helper function to... help w/ something: def attach_row(ws,r1,r2): es = [] for i,w in enumerate(ws): eb = gtk.EventBox() a = gtk.Alignment(xalign=0.0,yalign=0.5) a.add(w) e...

Beautiful Soup cannot find a CSS class if the object has other classes, too

if a page has <div class="class1"> and <p class="class1">, then soup.findAll(True, 'class1') will find them both. If it has <p class="class1 class2">, though, it will not be found. How do I find all objects with a certain class, regardless of whether they have other classes, too? ...

Finding python site-packages directory with CMake.

I use CMake to build my application. How can I find where the python site-packages directory is located? I need the path in order to compile an extension to python. CMake has to be able to find the path on all three major OS as I plan to deploy my application on Linux, Mac and Windows. I tried using include(FindPythonLibs) find_path(...

How to disable Control-C in a WindowsXP Python console program?

I'd like to put my cmd.com window into a mode where Control-C does not generate a SIGINT signal to Python (ActiveState if it matters). I know I can use the signal module to handle SIGINT. The problem is that handling SIGINT is too late; by the time it is handled, it has already interrupted a system call. I'd like something equivalent t...

Qt Image From Web

I'd like PyQt to load an image and display it from the web. Dozens of examples I've found online did not work, as they are for downloading the image. I simply want to view it. Something like from PyQt4.QtWebKit import * web = QWebView() web.load(QUrl("http://stackoverflow.com/content/img/so/logo.png")) ...

Validating XML in Python without non-python dependencies

I'm writing a small Python app for distribution. I need to include simple XML validation (it's a debugging tool), but I want to avoid any dependencies on compiled C libraries such as lxml or pyxml as those will make the resulting app much harder to distribute. I can't find anything that seems to fit the bill - for DTDs, Relax NG or XML S...

Access a large file in a zip archive with HTML in a python-webkit WebView without extracting

I apologize for any confusion from the question title. It's kind of a complex situation with components that are new to me so I'm unsure of how to describe it succinctly. I have some xml data and an image in an archive (zip in this case, but could easily be tar or tar.gz) and using python, gtk, and webkit, place the image in a webkit.We...

Programmatically extract data from an Excel spreadsheet.

Is there a simple way, using some common Unix scripting language (Perl/Python/Ruby) or command line utility, to convert an Excel Spreadsheet file to CSV? Specifically, this one: http://www.econ.yale.edu/~shiller/data/ie_data.xls And specifically the third sheet of that spreadsheet (the first two being charts). ...

can't edit line in python's command line in Linux

I'm running the Python CLI under Linux: bla:visualization> python Python 2.1.1 (#18, Nov 1 2001, 11:15:13) [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 Type "copyright", "credits" or "license" for more information. >>> For some reason the arrow keys and the delete key don't work: delete: >>> x^H^H^H up arrow:...

Accessing a pointer in an object's internal structure

I'm using the pyOpenSSL interface to the OpenSSL library but it is missing some functions I need and I can't or don't want to modify it to support these methods (for various reasons). So what I want to achieve, is to retrieve the OpenSSL object pointer. After that, I will be able to call the missing functions through ctypes. What is the...