python

Python imaging alternatives

I have python code that needs to do just a couple simple things to photographs: crop, resize, and overlay a watermark. I've used PIL, and the resample/resize results are TERRIBLE. I've used imagemagick, and the interface and commands were designed by packaging a cat in a box, and then repeatedly throwing it down a set of stairs at a keyb...

Whats the error in this python code?

What do i do to solve it? Terminal output is: abhi@abhi-desktop:~/Desktop/sslstrip-0.1$ python sslstrip.py --listen=3130 Traceback (most recent call last): File "sslstrip.py", line 254, in main(sys.argv[1:]) File "sslstrip.py", line 246, in main server = ThreadingHTTPServer(('', listenPort), StripProxy) File "/usr/lib/p...

Subdomains and Logins

If you multiple subdomains e.g.: sub1.domain_name.com sub2.domain_name.com Is there a way to have a user be able to log into both of these without issues and double login issue? The platform is Python, Django. ...

Python execute program change path

I'm trying to make a python script run another program from its own path. I've got the execution of the other program working using os.system, but the program will crash because it cannot find its reasources (wrong path, I assume). I tried adding the folder harboring the executable to the path, but that didn't help. Any help please? ...

transforming Jython's source / ast

I've got a problem to solve in Jython. The function I've got looks like this: ok = whatever1(x, ...) self.assertTrue("whatever1 failed: "+x...(), ok) ok = whatever2(x, ...) self.assertTrue("whatever2 failed: "+x...(), ok) [ many many lines ] ... There are many tests that look like this, they contain mostly ok=... tests, but there ar...

Python Web-Scrape Loop via CSV list of URLs ???

HI, I've got a list of 10 websites in CSV. All of the sites have the same general format, including a large table. I only want the the data in the 7th columns. I am able to extract the html and filter the 7th column data (via RegEx) on an individual basis but I can't figure out how to loop through the CSV. I think I'm close but my script...

Multiple Windows in PyQt4

I have a PyQt program used to visualize some python objects. I would like to do display multiple objects, each in its own window. What is the best way to achieve multi-window applications in PyQt4? Currently I have the following: from PyQt4 import QtGui class MainWindow(QtGui.QMainWindow): windowList = [] def __init__(self,...

Accessing a Python variable in a list

Hi-- I think this is probably something really simple, but I'd appreciate a hint: I am using a python list to hold some some database insert statements: list = [ "table_to_insert_to" ],["column1","column2"],[getValue.value1],["value2"]] The problem is one of the values isn't evaluated until runtime-- so before the page even gets run,...

Full-featured date and time library

I'm wondering if anyone knows of a good date and time library that has correctly-implemented features like the following: Microsecond resolution Daylight savings Example: it knows that 2:30am did not exist in the US on 8 March 2009 for timezones that respect daylight savings. I should be able to specify a timezone like "US/Eastern" a...

Failing to insert a record in sqlite using python

Am getting a error when i attempt to insert a record in sqlite using python. This is my code: import sqlite3 db = sqlite3.connect('mydb') ins_str = 'insert into filer_filer(number, ms_date, ms_time, mp_code, Amount, recipient_name,recipient_number, Tran_date, Tran_time, balance, userid_id ) values ('752098','09/09/16','17:54:19','K79...

Python program to split a list into two lists with alternating elements

Can you make it more simple/elegant? def zigzag(seq): """Return two sequences with alternating elements from `seq`""" x, y = [], [] p, q = x, y for e in seq: p.append(e) p, q = q, p return x, y ...

Lauch default editor (like 'webbrowser' module)

Is there a simple way to lauch the systems default editor from a Python command-line tool, like the webbrowser module? ...

Radix 64 and encryption

Dear Community members, Need to share my problem that is : A PGP public key server gives me the key in Radix64 format . And i searching for any method which can encrypt my message using this Radix64 format public key . any alternate suggestions or documents are welcome ......... ...

Completely wrap an object in Python

I am wanting to completely wrap an object so that all attribute and method requests get forwarded to the object it's wrapping, but also overriding any methods or variables that I want, as well as providing some of my own methods. This wrapper class should appear 100% as the existing class (isinstance must act as if it is actually the cla...

How do I protect my Python codebase so that guests can't see certain modules but so it still works?

We're starting a new project in Python with a few proprietary algorithms and sensitive bits of logic that we'd like to keep private. We also will have a few outsiders (select members of the public) working on the code. We cannot grant the outsiders access to the small, private bits of code, but we'd like a public version to work well eno...

Is it possible to divert a module in python? (ResourceX diverted to ResourceXSimulated)

I want to simulate MyApp that imports a module (ResourceX) which requires a resource that is not available at the time and will not work. A solution for this is to make and import a mock module of ResourceX (named ResourceXSimulated) and divert it to MyApp as ResourceX. I want to do this in order to avoid breaking a lot of code and get...

Django : Iterate over a query set without cache

I have a dumb simple loop for alias in models.Alias.objects.all() : alias.update_points() but looking into the django QuerySet it seems to keep around a _result_cache of all the previous results. This is eating Gigs and Gigs of my machine and eventually everything blows up. How can I throw away all the stuff that I won't ever ca...

help with python regular expression

I am wondering if problem down here can be solved with one regular expression or I should make standard loop and evaluate line by line, when I run included code I get ['Ethernet0/22', 'Ethernet0/24'], only result should be ['Ethernet0/23', 'Ethernet0/25']. any advice on this? import re txt='''# interface Ethernet0/22 stp disabl...

How to read a structure containing an array using Python's ctypes and readinto?

We have some binary files created by a C program. One type of file is created by calling fwrite to write the following C structure to file: typedef struct { unsigned long int foo; unsigned short int bar; unsigned short int bow; } easyStruc; In Python, I read the structs of this file as follows: class easyStruc(Structure...

Django Models internal methods

I'm new to Django so I just made up an project to get to know it but I'm having a little problem with this code, I want to be able to as the car obj if it is available so I do a: >>>cars = Car.objects.all() >>>print cars[0].category >>>'A' >>>cars[0].available(fr, to) that results in a: >>>global name 'category' is not defined So i...