I am on working on a Python script which is supposed to process a tarball and output new one, trying to keep the format of the original. Thus, I am looking for a way to lookup the compression method used in an open tarball to open the new one with same compression.
AFAICS TarFile class doesn't provide any public interface to get the nee...
I'm using django 1.1 and flatpages. It works pretty well, but I didn't manage to get a catchall or default page running.
As soon as I add a entry to url.py for my startpage, the flatpages aren't displayed anymore.
(r'^', 'myproject.mysite.views.startpage'),
I now flatpages uses a 404 hook, but how do you configure the default website...
I'm trying to use django-tinymce to make fields that are editable through Django's admin with a TinyMCE field. I am using tinymce.models.HTMLField as the field for this.
The problem is it's not working. I get a normal textarea. I check the HTML source, and it seems like all the code needed for TinyMCE is there. I also confirmed that the...
I'm trying to automate a ssh connection and control of a network device, that for some reason, only allows keyboard-interactive authentication. It doesn't appear that paramiko supports this by default or with the standard sshclient() object.
I've spent the past couple of days going through the paramiko documentation trying to figure th...
I'm writing a print system that puts a simplified interface on top of CUPS. Users drop jobs into one queue, the system processes them in various ways (statistics, page quotas, etc.), and then offers the user a web interface to dispatch the job to one of multiple printers.
Since there may be several user kiosks, an admin station, etc.,...
I'm writing a data processing library in Python that reads data from a variety of sources into memory, manipulates it, then exports it into a variety of different formats. I was loading this data into memory, but some of the datasets I'm processing can be particularly large (over 4 Gig).
I need an open source library for a backing stor...
Hi, I'd like to write an SConstruct file that will convert (e.g.) all the JPEG files in a directory into PNGs.
I think I have the Builder alright:
ConvToPNG = Builder(action = 'convert $SOURCE $TARGET',
suffix = '.png',
src_suffix = '.jpg')
env['BUILDERS']['ConvToPNG'] = ConvToPNG
But then I'm not sure how to make a l...
From research on Stack Overflow and other sites I'm 99% sure that the problem I'm having is due to incorrect importing. Below is a QLabel sub class that I'm using to respond to some mouse events:
import Qt
import sys
class ASMovableLabel(Qt.QLabel):
def mouseReleaseEvent(self, event):
button = event.button()
if b...
I want to launch a python script similar to this web crawler, wait for it to finish, process the data in php, then return the results to the user.
From what I hear, getting the output from python is trivial, but the above script is doing stuff in parallel, so just printing stuff as it finishes won't give me any kind of usable structure....
Hi all,
I'm building a Pylons application using evoque as our templating engine, though I think my question is relevant to other template engines. I have a base template that I'm using for our pages, and that base template does all the includes for CSS and Javascript files. I'd like to perform conditional test to include/exclude CSS and...
Is there a straightforward way to extracting the exponent from a power of 2 using bitwise operations only?
EDIT: Although the question was originally about bitwise operations, the thread is a good read also if you are wondering "What's the fastest way to find X given Y = 2**X in Python?"
I am currently trying to optimize a routine (Rab...
In Python I can use re.findall(pattern, string) to return all non-overlapping matches of pattern in a string.
For example, in the following SVG path command:
import re
spam = "M317.0,169.7C311.1,170.5 285.7,146.8 300.7,178.57 L 321.4,175.01"
eggs = re.findall("([A-Za-z]|-?[0-9]+\.?[0-9]*(?:e-?[0-9]*)?)", spam)
print(eggs)
['M', '317.0'...
Is there a way to change the name of a process running a python script on Linux?
When I do a ps, all I get are "python" process names.
...
I have django objects:
class Event(models.Model):
title = models.CharField(max_length=255)
event_start_date = models.DateField(null=True, blank='true')
...
class RegistrationDate(models.Model):
event = models.ForeignKey(tblEvents)
date_type = models.CharField(max_length=10, choices=registration_date_type)
start_dat...
Well, this could be a simple question, to be frank I'm a little confused with encodings an all those things.
Let's suppose I have the file 01234.txt which is iso-8859-1.
When I do:
iconv --from-code=iso-8859-1 --to-code=utf-8 01234.txt > 01234_utf8.txt
It gives me the desired result, but when I do the same thing with python and usin...
Here is the directory structure:
app/
__init__.py
sub1/
__init__.py
mod1.py
sub2/
__init__.py
sub2.so
test_sub2.py
The folder app is on my PYTHONPATH
All of the _init_.py files are empty.
The shared library sub2.so is a C++ extension module that I compiled using cmake and boost-pyth...
Hi,
I am looking for a hash functions family generator that could generate a family of hash functions given a set of parameters. I haven't found any such generator so far.
Is there a way to do that with the hashlib package ?
For example I'd like to do something like :
h1 = hash_function(1)
h2 = hash_function(2)
...
and h1 and h2 would...
What's the best name to describe this:
class Animal(object):
def __init__(self,animal_type):
self.animal = animal_type()
class Dog(object):
def __init__(self):
pass
fido = Animal(Dog)
?
In particular, this line:
self.animal = animal_type()
Basically what is happening is I'm passing the type of the class I...
I've been solving a couple of the WebGoat exampels for a uni-lab thing. In one of the exercises I tried to use a python script with urllib2 to do automated "tests" so I didnt manually have to used ascii(substr(first_name,3,1)) > 97 etc.
But I seem to get the same page eventhough I try different urls when using an urllib2 script aka f2, ...
This question has a little history http://stackoverflow.com/questions/2247892/is-there-a-way-to-make-a-query-respect-the-order-of-the-inputted-parameters
I'm new to building "specialized" queries, so I assumed that if I supply an IN clause as part of a SELECT query, it'll return results in the same order. Unfortunately that's not the c...