python

How to set up Atana Studio 3 Themes in Pydev

I've installed the Aptana Studio 3 preview and noticed it has support for themes (such as a bespin style or Ruby envy) and I'd love to use the Bespin one in Pydev but so far I've had no luck getting it to work, anyone have a clue as to how to get it to work? Video showing the themes in action. ...

Hide console window with wxPython and cxFreeze

I'm developing a Python application using wxPython and freezing it using cxFreeze. All seems to be going fine apart from this following bit: When I run the executable created by cxFreeze, a blank console window pops up. I don't want to show it. Is there any way I could hide it? It doesn't seem to be documented on the cxFreeze site and...

How to install PySide v0.3.1 on Mac OS X?

I'm trying to install PySide v0.3.1 in Mac OS X, for Qt development in python. As a pre-requisite, I have installed CMake and the Qt SDK. I have gone through the documentation and come up with the following installation script: export PYSIDE_BASE_DIR="<my_dir>" export APIEXTRACTOR_DIR="$PYSIDE_BASE_DIR/apiextractor-0.5.1" export GENE...

Need to get the uploaded file to my local PC

Hi, I have created a test form which will ask users to enter a name and upload the image file: <html lang="en"> <head> <title>Testing image upload</title> </head> <body> <form action="/services/upload" method="POST" enctype="multipart/form-data"> File Description: <input name='fdesc' type='text'><br> File name: <input ty...

is this code useful ?

def _oauth_escape(val): if isinstance(val, unicode):# useful ? val = val.encode("utf-8")#useful ? return urllib.quote(val, safe="~") i think it is not useful , yes ?? updated i think unicode is ‘utf-8’ ,yes ? ...

How to use SQLAlchemy to dump an SQL file from query expressions to bulk-insert into a DBMS?

Please bear with me as I explain the problem, how I tried to solve it, and my question on how to improve it is at the end. I have a 100,000 line csv file from an offline batch job and I needed to insert it into the database as its proper models. Ordinarily, if this is a fairly straight-forward load, this can be trivially loaded by just ...

Python rounding problem

>>> num = 4.123456 >>> round(num, 3) # expecting 4.123 4.1230000000000002 I'm expecting 4.123 as a result, Am I wrong? ...

Task queue execution

I'm developing a site for a customer which regularly sends email notifications, to facilitate this I have a cron job which runs at 2am to start scheduling individual tasks to send out the notications. This is all fine and work perfectly with tasks being scheduled to execute immediately, but to assist development and testing I've written ...

os.walk in python not running with cmd line parameter passed as path

Hello, I needed to find the number of files in a folder on the system. This is what i used: file_count = sum((len(f) for _, _, f in os.walk('path'))) This works fine when we specify the path as a string in quotes, but when I enter a variable name that holds the path, type(file_count) is a generator object, and hence cannot be used a...

Time difference in seconds (as a floating point)

>>> from datetime import datetime >>> t1 = datetime.now() >>> t2 = datetime.now() >>> delta = t2 - t1 >>> delta.seconds 7 >>> delta.microseconds 631000 Is there any way to get that as 7.631000 ? I can use time module, but I also need that t1 and t2 variables as DateTime objects. So if there is an easy way to do it with datettime, that ...

"Win32 exception occurred releasing IUnknown at..." error using Pylons and WMI

Hi all, Im using Pylons in combination with WMI module to do some basic system monitoring of a couple of machines, for POSIX based systems everything is simple - for Windows - not so much. Doing a request to the Pylons server to get current CPU, however it's not working well, or atleast with the WMI module. First i simply did (somethin...

Django: automatically import MEDIA_URL in context

Hi, like exposed here, one can set a MEDIA_URL in settings.py (for example i'm pointing to Amazon S3) and serve the files in the view via {{ MEDIA_URL }}. Since MEDIA_URL is not automatically in the context, one have to manually add it to the context, so, for example, the following works: #views.py from django.shortcuts import render_...

Play Shoutcast Radio stream in Python?

I know this is a second post on the same topic, but I am doing this in hopes of some help. I am trying to create a player for my Shoutcast internet radio station, but I can't seem to get anything to work. It is a live MP3 broadcast. When you click the link to tune in, it gives a .PLS file with the server url in it. Anyone have any ideas ...

What is the pythonic way to add type information to an object's attributes?

I'm building classes where I know the intended types of the attributes, but Python of course doesn't. While it's un-pythonic to want to tell it, supposing I do want to, is there an idiomatic way to do so? Why: I'm reading in foreign-format data (without type information) involving objects-nested-inside-objects. It's easy to put it into ...

How to get the contents of the wav file into array so as to cut the required segment and convert it back to wav format using python??

How to get the contents of the wav file into array so as to cut the required segment and convert it back to wav format using python?? My prob is similar to "ROMANs" prob,i hav seen earlier in the post at this site.. Basically,i want to combine parts of different wav file into one wav file?? if there is ne other apporach thn takin the co...

Python daylight savings time

How do I check if daylight saving time is in effect? ...

Troubles with PyDev and external libraries in OS X

I've successfully installed the latest version of PyDev in my Eclipse (3.5.1) under OS X 10.6.3, with python 2.6.1 I have troubles in making the libraries I have installed work. For example, I'm trying to use the cx_Oracle library, which is perfectly working if called from the python interpeter of from simple scripts made with some text ...

Filling textarea with Python mechanize module

Is there a way to fill out textarea that is part of form using mechanize module for Python? ...

Python socket for receiving UDP packages from an FPGA

Hello everybody, I am trying to read the UDP packages in python, which were sent from an FPGA. I see the packages in wireshark, and they look allright. Python, however does not receive anything when I use this simple script: import socket import sys HOST, PORT = "192.168.1.1", 21844 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRA...

Convert shoutcast stream to playable samples in Python?

I have a shoutcat radio station and now want to build a player for it. I know how to "get" thet stream from the server, thanks a lot to bobince , but I am not sure how to convert that stream into playable samples. How is it done? ...