python

Find the file with a given SVN URL within a SVN working copy

Given a starting point in a Subversion working copy (e.g. current working directory), and a target SVN URL, I'd like to find the file in the working copy that has that SVN URL. For example, given this current directory: c:\Subversion\ProjectA\a\b\c\ which has this SVN URL: https://svnserver/svn/ProjectA/trunk/a/b/c/ I'd like to lo...

Need help installing MySQL for Python

Trying to install MySQL for Python. Two problems: 1) Instructions over the net says installation is python setup.py For me, it results with can't open file 'setup.py': [Errno 2] No such file or directory 2) README.txt says: The Z MySQL database adapter uses the MySQLdb package.This must be installed before you can use the Z MySQL DA. Y...

Json encoder python recursive reference

Hey everyone I don't know whether I am doing the right thing here, basically I want both of my class to be json-serializable. import json class gpagelet(json.JSONEncoder): """ Holds 1) the pagelet xpath, which is a string 2) the list of pagelet shingles, list """ def __init__(self, parent): if not ...

How to create a MAPI32.dll stub to be able to "send as attachment" from MS Word?

Microsoft Word has "send as attachment" functionality which creates a new message in Outlook with the document attached. I would like to replace Outlook with a custom mail agent, but I do not know how to achieve this. Now my mail agent is simply a program that runs, and takes a file name as parameter. As far as I know, "send as attac...

Python ctypes and not enough arguments (4 bytes missing)

The function i'm trying to call is: void FormatError (HRESULT hrError,PCHAR pszText); from a custom dll using windll. c_p = c_char_p() windll.thedll.FormatError(errcode, c_p) Results in: ValueError: Procedure probably called with not enough arguments (4 bytes missing) Using cdll instead increases the bytes missing counter to 12....

Modify address in Django middleware

hello, I don't know if it's possible but I'd like to add few parameters at the end of the URL using middleware. Can it be done without redirect after modyfing requested URL? ie. user clicks: .../some_link and middleware rewrites it to: .../some_link?par1=1&par2=2 Other way is to modify reponse and replace every HTML link but it's not ...

Python - Is there a way around 'os.listdir()' returning gibberish for bad folder name?

I have a simple script written in Python: import os def Path(SourcePath): for Folder in os.listdir(SourcePath): print "TESTING: %s" % Folder Path("\\\\192.168.0.36\\PDFs") When i run this it recurses through a remote share on the LAN and just simply displays the names of the folders found. This share primarily contains fold...

Is there a C# equivalent to Python's unhexlify?

Possible Duplicate: How to convert hex to a byte array? I'm searching for a python compatible method in C# to convert hex to binary. I've reversed a hash in Python by doing this: import sha import base64 import binascii hexvalue = "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8" binaryval = binascii.unhexlify(hexvalue) print base64...

How can I protect myself from a zip bomb?

I just read about zip bombs, i.e. zip files that contain very large amount of highly compressible data (00000000000000000...). When opened they fill the server's disk. How can I detect a zip file is a zip bomb before unzipping it? UPDATE Can you tell me how is this done in Python or Java? ...

Looking for a bare-bones open-source editor written in python

I'm looking for a bare bones cross platform editor written in python that I can pick up and customize. The fewer dependencies the better. Please note: I'm not looking for a python editor or python IDE. Just a no-frills editor, that I can use as a base for an app that I'm starting on. Must be open source and free to modify for commerc...

Which out of Python, Ruby, F# is better for learning as first programming language with dynamic type system?

I am thinking to learn programming language with dynamic type system. Which one should I learn first? Criteria: I can learn and start programming in a day or two Easy, Concise In few days I should be able to write small scripts for some batch jobs with file systems. To mention, I am normally a quick learner. ...

module reimported if imported from different path

In a big application I am working, several people import same modules differently e.g. import x or from y import x the side effects of that is x is imported twice and may introduce very subtle bugs, if someone is relying on global attributes e.g. suppose I have a package mypakcage with three file mymodule.py, main.py and init.py mymodu...

pyparsing - load ABNF?

can pyparsing read ABNF from a file instead of having to define it in terms of python objects? If not, is there something which can do similar (load an ABNF file into a parser object) ...

listing network shares with python

Hello, if I explicitly attempt to list the contents of a shared directory on a remote host using python on a windows machine, the operation succeeds, for example, the following snippet works fine: os.listdir("\\\\remotehost\\share") However, if I attempt to list the network drives/directories available on the remote host, python fails...

Non-Blocking method for parsing (streaming) XML in python

I have an XML document coming in over a socket that I need to parse and react to on the fly (ie parsing a partial tree). What I'd like is a non blocking method of doing so, so that I can do other things while waiting for more data to come in (without threading). Something like iterparse would be ideal if it finished iterating when the r...

Get the inputs from Excel and use those inputs in python script

How to get the inputs from excel and use those inputs in python. ...

Do not require non-NULL field (allow empty strings) in FormAlchemy

I'm fairly novice to FormAlchemy and it seems that I don't get something. I have a SQLAlchemy model defined like this: ... class Device(meta.Base): __tablename__ = 'devices' id = sa.Column('id_device', sa.types.Integer, primary_key=True) serial_number = sa.Column('sn', sa.types.Unicode(length=20), nullable=False) mac = ...

KindError on setting a ReferenceProperty value

This seemingly perfect Google App Engine code fails with a KindError. # in a django project 'stars' from google.appengine.ext import db class User(db.Model): pass class Picture(db.Model): user = db.ReferenceProperty(User) user = User() user.put() picture = Picture() picture.user = user # ===> KindError: Property user must be...

Why pysqlite does not work properly?

I tried to install pysqlite. Some suspicious things start to appear during the installation. Why I typed: python setup.py build I got the following message in the end: src/module.c:286: error: ‘SQLITE_PRAGMA’ undeclared here (not in a function) src/module.c:287: error: ‘SQLITE_READ’ undeclared here (not in a function) src/module.c:28...

epylint script is not working on Windows.

I have installed http://ftp.logilab.org/pub/pylint/pylint-0.18.1.tar.gz on Windows and now I am trying to configure my Emacs's flymake mode using epylint script. But it is not working. Here is the output of I got when I tried epylint on windows command prompt. C:\>epylint test.py 'test.py':1: [F] No module named 'test.py' Did anyone t...