python

how to tell if a string is base64 or not.

Hi guys I have many emails coming in from different sources. they all have attachments, many of them have attachment names in chinese, so these names are converted to base64 by their email clients. When I receive these emails, I wish to decode the name. but there are other names which are not base64. How can I differentiate whether a s...

How should I stress test / load test a client server application?

Hi all I develop a client-server style, database based system and I need to devise a way to stress / load test the system. Customers inevitably want to know such things as: • How many clients can a server support? • How many concurrent searches can a server support? • How much data can we store in the database? • Etc. Key to all thes...

How to scan a webpage and get images and youtube embeds?

I am building a web app where I need to get all the images and any flash videos that are embedded (e.g. youtube) on a given URL. I'm using Python. I've googled, but have not found any good information about this (probably because I don't know what this is called to search for), does anyone have any experience with this and knows how it ...

User Authentication in Django

Hi, is there any way of making sure that, one user is logged in only once? I would like to avoid two different persons logging into the system with the same login/password. I guess I could do it myself by checking in the django_session table before logging in the user, but I rather prefer using the framework, if there is already such f...

Code Coverage and Unit Testing of Python Code

I have already visited Preferred Python unit-testing framework. I am not just looking at Python Unit Testing Framework, but also code coverage with respect to unit tests. So far I have only come across coverage.py. Is there any better option? An interesting option for me is to integrate cpython, unit testing of Python code and code cove...

"File -X: does not exist" message from ipy.exe in Windows PowerShell

If I type this line in an MS-DOS command prompt window: ipy -X:ColorfulConsole IronPython starts up as expected with the colorful console option enabled. However, if I type the same line in Windows PowerShell I get the message: File -X: does not exist Can someone explain what I'm doing wrong? ...

Python's os.execvp equivalent for PHP

I've got a PHP command line program running. And I want to connect to a mysql shell straight from PHP. I've done this before in Python using os.execvp But I can't get the same thing to work in PHP. I've tried the following functions: system passthru exec shell_exec example: system('mysql -u root -pxxxx db_name'); But they all see...

Generating a WSDL using Python and SOAPpy

First of all, I will admit I am a novice to web services, although I'm familiar with HTML and basic web stuff. I created a quick-and-dirty web service using Python that calls a stored procedure in a MySQL database, that simply returns a BIGINT value. I want to return this value in the web service, and I want to generate a WSDL that I c...

Python memory debugging with GDB

We have a Linux application that makes use of OpenSSL's Python bindings and I suspect it is causing random crashes. Occasionally, we see it crash with the message "Python Fatal Error: GC Object already tracked," which would appear to be either a programming error on the part of the library, or a symptom of memory corruption. Is there any...

Testing Web Services Consumer

Here are some tools that I have found to test web services consumers: http://www.soapui.org/ https://wsunit.dev.java.net/ Are there any others? I would prefer testing frameworks that are written in Java or Python. ...

Python: Best way to create directory if it doesn't exist for file write?

What's the most elegant way to check if the directory a file is going to be written to exists, and if not create the directory? Is there a better way than: Update: Somehow I'd missed os.path.exists, thanks kanja, Blair, and Douglas, this is what I've got now: def ensure_dir(f): d = os.path.dirname(f) if not os.path.exists(d): ...

Access second result set of stored procedure with SQL or other work-around? Python\pyodbc

I'm using python\pyodbc and would like to access the second result set of a stored procedure. As near as I can tell, pyodbc does not support multiple result sets. Additionally, I can't modify the stored procedure. Are there any options to access the second result set using SQL or some other work-around? Perhaps create a second stored pro...

Python 3.0 and language evolution

Python 3.0 breaks backwards compatibility with previous versions and splits the language into two paths (at least temporarily). Do you know of any other language that went through such a major design phase while in maturity? Also, do you believe that this is how programming languages should evolve or is the price to pay simply too high?...

python, basic question on loops

It's a really basic question but i can't think at the second. How do i set up a loop that asks each time the function inside runs whether to do it again. So it runs it then says something like; "loop again? y/n" ...

Is there a cross-platform way of getting information from Python's OSError

On a simple directory creation operation for example, I can make an OSError like this: (Ubuntu Linux) >>> import os >>> os.mkdir('foo') >>> os.mkdir('foo') Traceback (most recent call last): File "<stdin>", line 1, in <module> OSError: [Errno 17] File exists: 'foo' Now I can catch that error like this: >>> import os >>> os.mkdir('...

How do I Create an instance of a class in another class in Python

I am trying to learn Python and WxPython. I have been a SAS programmer for years. This OOP stuff is slowly coming together but I am still fuzzy on a lot of the concepts. Below is a section of code. I am trying to use a button click to create an instance of another class. Specifically-I have my main panel in one class and I wanted to...

How do I resize an image using PIL and maintain its aspect ratio?

Is there an obvious way to do this that I'm missing? I'm just trying to make thumbnails. ...

UTF-8 latin-1 conversion issues, python django

ok so my issue is i have the string '\222\222\223\225' which is stored as latin-1 in the db. What I get from django (by printing it) is the following string, 'ââââ¢' which I assume is the UTF conversion of it. Now I need to pass the string into a function that does this operation: strdecryptedPassword + chr(ord(c) - 3 - intCounter -...

How to copy a file in Python with a progress bar?

When copying large files using shutil.copy(), you get no indication of how the operation is progressing.. I have put together something that works - it uses a simple ProgressBar class (which simple returns a simple ASCII progress bar, as a string), and a loop of open().read() and .write() to do the actual copying. It displays the progre...

config_vars.mk missing in default xampp-linux installation.

I extracted the xampp package xampp-linux-1.6.7 on a Ubuntu 8.10 system and followed the instuctions from mod_wsgi documentation. I get the error below: ravi@Ibex:~/mod_wsgi-2.3$ ./configure --with-apxs=/opt/lampp/bin/apxs checking Apache version... cannot open /opt/lampp/build/config_vars.mk: No such file or directory at /opt/lampp/b...