python

missing elements from pcap?

When I check the attributes available to the module pcap, I expect to see something like [ ...snip... 'dltvalue', 'findalldevs', 'lookupdev', 'lookupnet', 'ntoa', 'pcapObject', 'pcapObjectPtr'] With note on pcapObject. However, all I get when running dir(pcap) is [ ... snip... 'copyright', 'doc', 'file', 'license',...

Profiling shared library/plugins written in C++ for Python?

I've got a C++ library that lets me write plugins in C++ and then automatically exposes them to python. I'm working on some networking stuff in a plugin and I'd like to profile it with something like gprof, but simply compiling with -pg and running the plugin via python doesn't generated the necessary profiling data. Unfortunately the ...

Put an AuiManager inside a AuiNotebook page.

Is it possible ho put an AuiManager inside an AuiNotebook page? Have tested with a small sample code, but I only get a 'Segmentation fault'. Is this possible to begin with? The reason why I want this is to split a notebook page in two parts and get the caption field and the maximize field in the top of each part of the two parts. A sim...

Is it possible to see the source code of the violating files in Hudson with Violations and Pylint?

I'm using Hudson CI with a Python project. I've installed the Violations plugin and configured it to run the code against pylint. This works, but I only see a list of violations without linking to the source code. Is it possible to setup Violations and pylint to load and highlight the violating source files (something similar to the Cobe...

Implementing pyglet breaks my once working framebuffer OpenGL code.

This question repeats my earlier one but my earlier one was a failure because I didn't copy some vital information correctly, so I have to redo it. I'm getting an error with a call to an OpenGL function. Maybe pyglet isn't initialising OpenGL correctly? The error happens with a simple function that worked before: def setup_framebuffer...

Display an image as a splash screen when running Windows batch file, vbscript/wscript or Python console script

Any ideas how I can display an image file (bmp or png) centered on the screen as an application splash screen when running a Windows console script based on a batch file, vbscript/wscript or Python console script? I'm not interested in a wxPython solution - that's too much overhead just to implement a cosmetic feature like a splash scre...

Python: HTTP Post a large file with streaming

I'm uploading potentially large files to a web server. Currently I'm doing this: import urllib2 f = open('somelargefile.zip','rb') request = urllib2.Request(url,f.read()) request.add_header("Content-Type", "application/zip") response = urllib2.urlopen(request) However, this reads the entire file's contents into memory before posting ...

Update element values using xml.dom.minidom

Hello, I have an XML structure which looks similar to: <Store> <foo> <book> <isbn>123456</isbn> </book> <title>XYZ</title> <checkout>no</checkout> </foo> <bar> <book> <isbn>7890</isbn> </book> <title>XYZ2</title> <checkout>yes</checkout> </bar> </Store> Usin...

Python - store output of subprocess() call in a string

Hey all, I'm trying to make a system call in Python and store the output to a string that I can manipulate in the Python program. #!/usr/bin/python import subprocess p2 = subprocess.Popen("ntpq -p") I've tried a few things including some of the suggestions here: http://stackoverflow.com/questions/1996518/retrieving-the-output-of-su...

Problem about cvGetSeqElem in opencv - python

Hi, I'm trying to write eye detection in opencv with python but having some problems about cvGetSeqElem. In C we can write : CvRect *face = (CvRect*)cvGetSeqElem(faces, 0); When I'm trying to write this with Python : face = cvGetSeqElem(faces, 0) It returns str, therefore I can't reach x,y positions. Any idea ? ...

GAE Datastore Table Display using JSON and Google Visualization Table?

GAE Datastore Table Display using JSON and Google Visualization Table? Anyone has experience on this? How Google Visualization Table will render pagination with JSON? Really need an example on how to do this or another solution on achieving same result? I just want to render my table just like this sample using above methode and source. ...

Using boost.python to import a method with opencv calls but failing due to symbols not being found after compilation

So I don't have the code right now, as I am not home... but i used the boost library for python in C++ to allow python to access a function called something like loadImageIntoMainWindow(string filepath) in the C++ source code the method calls opencv methods that are imported at the top of the file, I included opencv in my Jamroot file, ...

Superfluous python parameters

I've noticed a discrepancy in the way that python parameters are called. In every other language I've dealt with, you either have foo() meaning either no parameters, or as many parameters as you like, or foo(arg1, arg2,...,argn) where you pass in the same number of parameters to define the function and call it. In python howev...

How to make Python Extensions for Windows for absolute beginners

Hello: I've been looking around the internet trying to find a good step by step guide to extend Python in Windows, and I haven't been able to find something for my skill level. let's say you have some c code that looks like this: #include <stdio.h> #include <math.h> double valuex(float value, double rate, double timex) { float v...

What is your strategy to avoid dynamic typing errors in Python (NoneType has no attribute x)?

Python is one of my favorite languages, but I really have a love/hate relationship with it's dynamicness. Apart from the advantages, it often results in me forgetting to check a type, trying to call an attribute and getting the NoneType (or any other) has no attribute x error. A lot of them are pretty harmless but if not handled correctl...

Simple forloop - Python

Hi folks, this is probably too simple of a question, but here I go. I have paginated items, each page contains 100 items. The program fetches items till it reaches the item index specified within item_num This is what I have: item_num = 56 range(0, item_num/100 + (item_num%100 > 0)): get_next_100() I'm not really sure about th...

Pygtk entry placeholder

How to create pygtk entry with placeholder like in HTML 5 input element? ...

SWIG: Python list to uint32_t *?

I'm trying to work with a Python module that was generated by SWIG. There's a C++ class defined that works like this (simplified): namespace Foo { class Thing { public: Thing(); ~Thing(); bool DoSomething(uint32_t x, uint32_t y, uint32_t z, uint32_t *buffer); }; }; When I try to call it from P...

Should I use a metaclass, class decorator, or override the __new__ method?

Here is my problem. I want the following class to have a bunch of property attributes. I could either write them all out like foo and bar, or based on some other examples I've seen, it looks like I could use a class decorator, a metaclass, or override the __new__ method to set the properties automagically. I'm just not sure what the "...

pylint ignore by directory

Following is from pylint docs: --ignore=<file> Add <file or directory> to the black list. It should be a base name, not a path. You may set this option multiple times. [current: %default] Yet I'm not having luck getting the directory part work. I have directory called migrations, which has django-south migration files. As I enter...