python

Django with huge mysql database

What would be the best way to import multi-million record csv files into django. Currently using python csv module, it takes 2-4 days for it process 1 million record file. It does some checking if the record already exists, and few others. Can this process be achieved to execute in few hours. Can memcache be used somehow. Update: Th...

Python if statement "SyntaxError: invalid syntax"

Hi, Trying to execute someone's code, getting a syntax error. No idea why :( def GetParsers( self, systags ): childparsers = reduce( lambda a,b : a+b, [[]] + [ plugin.GetParsers( systags ) for plugin in self.plugins ] ) parsers = [ p for plist in [ self.parsers[t] for t in systags if self.parsers.has_key(t) ] for p in plist ] ...

Python PIL load throwing AttributeError: 'NoneType' object has no attribute 'read'

Hi all, I've been struggling with this error for several days with little headway. Basically, I'm trying to read in an image file and then use PIL to preform a specific operation on it. (my end goal is to preform a PIL paste operation). However, whenever I load my image in, and then invoke the load() method on it (operations like s...

IDLE processes numerical input in a weird way (python 2.6)

If you simply type an integer after the >>> prompt they give you in the IDLE interpreter, most of the time it'll simply bounce the number back at you. >>> 3 3 >>> 8 8 >>> 10 10 Start the nubmer off with a 0 however, and some interesting errors happen. >>> 010 8 >>> 020 16 ...

how to access the list in different function

I have made a class in which there are 3 functions. def maxvalue def min value def getAction In the def maxvalue function, I have made a list of actions. I want that list to be accessed in def getaction function so that I can reverse the list and then take out the first entry from it. How can do i that?? def getAction(self,gamesta...

Made Django's auth track on emails, how to relate username field to email?

My original though was to simply put the email address into both username and email fields when creating accounts, this doesn't work as Django limits the username field to 30 characters which may not be enough for email addresses. My second thought was to md5 the email address, put the hash into username, and that would make it always ...

twitter connection needs to be closed?

i developed an aplication built on twitter api , but i get erorrs like a mesage that i've parsed and deleted to be parsed again at the next execution , could that be because i left the twitter connection opened or is just a fault of the twitter API. I also tried to delete all direct messages because it seemed too full for me but i...

Using the ttk (tk 8.5) Notebook widget effectively (scrolling of tabs)

I'm working on a project using Tkinter and Python. In order to have native theming and to take advantage of the new widgets I'm using ttk in Python 2.6. My problem is how to allow the user to scroll through the tabs in the notebook widget (a la firefox). Plus, I need a part in the right edge of the tabs for a close button. The frame for ...

List of lists and "Too many values to unpack"

I'm trying to use the following code on a list of lists to create a new list of lists, whose new elements are a certain combination of elements from the lists inside the old list...if that makes any sense! Here is the code: for index, item in outputList1: outputList2 = outputList2.append(item[6:].extend(outputList1[index+1][6:])) ...

list query, functions in function

i have a function: I need to first reverse the list and then take an entry from it. Earlier, I was making the 3 functions but now I am defining the main function and the other 2 functions in it. ...

How to convince boss to substitute Java/Netbeans Platform for Python/PyQt?

Hi all, I'm working for small company, which operates in the automation industry. The boss hired me because he wants to sell/give some desktop applications to his current costumers. He imposes me to use the Netbeans Platform (a generic desktop application framework). A software engineer friend of his advised him to choose this framework....

In Sqlalchemy, if i add an object using session.add() and flush it, session.query() does not give that object, why?

While using SQLAlchemy, i add a object to a session using session.add(objname), then either explicitly flush it using session.flush or enable autoflush=True while creating the engine itself. Now in the session, if want to return that object via session.query(classname).all(), i cannot retrieve it. Why is that so? or is there a way in w...

How to mimic Python set with django ORM?

Hello all, I am working on a membership application. I would like to make a membership reminder. (member during a period of time which is not member for another period of time). Currently, I am using set for making this calculation. See the code below. class Member(models.Model): ... class Membership(models.Model): member = ...

A django problem that doesn't show up in runserver

In runserver, I can view my website no problems. (viewing it through lynx on the same machine) But when I view the same thing through apache, (passenger) I get an error like the following: Could not import PROJ.APP.views Error was: No module named PROJ.views It looks like a problem with the urlconf, but again that is the same between...

Python - How can I fetch emails via POP or IMAP through a proxy?

Neither poplib or imaplib seem to offer proxy support and I couldn't find much info about it despite my google-fu attempts. I'm using python to fetch emails from various imap/pop enabled servers and need to be able to do it through proxies. Ideally, I'd like to be able to do it in python directly but using a wrapper (external program/s...

Python csv without header

With header information in csv file, city can be grabbed as: city = row['city'] Now how to assume that csv file does not have headers, there is only 1 column, and column is city. ...

Using Python to send/receive text from GUI program

Hi all - I'm using PyWin32's win32process.CreateProcess to start up a GUI program that has functionality I want to use in a Python class. I want to do the following from Python with this GUI: sent text to individual windows within the GUI (which seem to change identifiers every time I create the process if WinSpy++ is to be believed)...

fuse & gstreamer transcoding

I'm trying to create a FUSE fs which transcodes all sound files to mp3. My first idea is to use gstreamer as the backend for transcoding. I thought about using this pipeline: gst-launch -v filesrc location=01\ New\ Born.flac ! decodebin ! audioconvert ! lame vbr=4 vbr-quality=9 ! id3v2mux ! appsink The python bindings of fuse expect c...

Twisted.Web and AJAX

I've implemented a toy web service in Twisted.Web: from twisted.web import server, resource, http class RootResource(resource.Resource): def __init__(self): resource.Resource.__init__(self) self.putChild('test', TestHandler()) class TestHandler(resource.Resource): isLeaf = True def __init__(self): res...

logout from command prompt to uploading application on google app

I am uploading google app engine application with the help of appcfg.py command from command prompt in windows. But after one login I want to upload another application from the same command prompt but i cannot because this second application has no rights with the current login so i want to logout from this session on command prompt s...