Re: [Off topic] Software epigrams
On Mon, May 13, 2013, at 05:20 AM, Steven D'Aprano wrote: > My, it's been a long time since I've seen these: > > http://pu.inf.uni-tuebingen.de/users/klaeren/epigrams.html > > They pre-date the Zen of Python by at least a decade, and quite frankly I > think many of them miss the mark. But whether you agree or disagree with > them, they're worth reading. Yes, they're all over the place, but worth reading. My favorite is: 101: Dealing with failure is easy: Work hard to improve. Success is also easy to handle: You've solved the wrong problem. Work hard to improve. -- http://mail.python.org/mailman/listinfo/python-list
Re: Illegal seek error with seek() and os.lseek()
On Tue, May 14, 2013, at 03:00 PM, krishna2pra...@gmail.com wrote: > I am trying to use os.open() and os.lseek() methods to operate on a > device file in Linux. My code goes something like this - > > # first, open the file as a plain binary > try: > self.file = open(/dev/relpcfpga, "r+b", buffering=0) > > except IOError: > raise IOError ('Failed to open.') > > # Figure out file size > self.file.seek(0, 2) > self.file_size = self.file.tell() > > > The method seek() complains "OSError: [Errno 29] Illegal seek" > The device relpcfpga is a char device. > > The same code works with a normal text file. > I have tried to use os.open() and os.lseek() methods, but see the same > error. > Is there a different method to operate on device files? Some file streams are not seekable. Specifically, some (all?) char devices aren't seekable (because e.g. they can't be rewound or they have no end). You'd get the same error in C (well it would return -1). See also: http://www.linuxintro.org/wiki/Device -- http://mail.python.org/mailman/listinfo/python-list
Re: String object has no attribute "append"
On Tue, May 28, 2013, at 02:25 PM, Matt Graves wrote: > I receive this error while toying around with Functions... > > def pulldata(speclist,speccolumn): > with open('profiles.csv', 'r') as f: > reader = csv.reader(f) > for column in reader: > (speclist).append(column[('speccolumn')]) > > pulldata(speclist = 'numbers', speccolumn = "0") > > > >Traceback (most recent call last): > > File "C:\Desktop\Python\CFI\Devices V2\users.py", line 17, in > >pulldata(speclist = 'numbers', speccolumn = "0") > > File "C:\Desktop\Python\CFI\Devices V2\users.py", line 16, in pulldata > >(speclist).append(column[('speccolumn')]) > >AttributeError: 'str' object has no attribute 'append' > > I'm getting the error because it should say "numbers.append", but it is > reading it as "(speclist).append". Because it indeed says "(speclist).append"... am I missing something? -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading log and saving data to DB
On Wed, Aug 14, 2013, at 09:18 AM, Guy Tamir wrote: > Hi all, > > I have a Ubuntu server running NGINX that logs data for me. > I want to write a python script that reads my customized logs and after > a little rearrangement save the new data into my DB (postgresql). > > The process should run about every 5 minutes and i'm expecting large > chunks of data on several 5 minute windows.. > > My plan for achieving this is to install python on the server, write a > script and add it to cron. > > My question is what the simplest way to do this? > should i use any python frameworks? Rarely do I put "framework" and "simplest way" in the same set. I would do 1 of 2 things: * Write a simple script that reads lines from stdin, and writes to the db. Make sure it gets run in init before nginx does and tail -F -n 0 to that script. Don't worry about the 5-minute cron. * Similar to above but if you want to use cron also store in the db the offset of the last byte read in the file, then when the cron job kicks off again seek to that position + 1 and begin reading, at EOF write the offset again. This is irrespective of any log rotating that is going on behind the scenes, of course. -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiprocessing / threading confusion
On Thu, Sep 5, 2013, at 03:27 PM, Paul Pittlerson wrote: > I'm trying to understand data handling using multiprocessing and > threading, haven't gotten very far without running into problems. This is > my code: [snip (not sure why you are using multiprocessing and threading at the same time] > What I expect to happen is the Debugger object will receive one string at > a time, and read it from the queue. But that's not what I see the the > output, the "started worker" stuff seems to print for every process, but > "ticked" and "exited" will show up in unpredictable ways, I'm guessing > they overwrite each other and therefore will not always appear in the > output. > > So I'm looking for help in trying to make sense of this kind of stuff, I > thought this was the basic functionality that Queue() would take care of > unless there is some other problem in my code. My output is probably totally different than your output. I only get the processes starting. Here's why: This stuff all runs asynchronously. When you start the "Debugger" thread.. I see you put a sleep() in it, but that guarantees nothing. At least on my machine which is somewhat loaded ATM, by the time the Processes are started, the Debugger thread has already finished (because of the check to see if the queue was empty). Apparently it is took longer than 1 second from the time the Debugger was started and the first Process was started. Likewise, what you are getting is probably a case where the queue is momentarily empty by the time the debugger loop gets ahold of the queue lock and checks to see if it's empty. Therefore the Debugger quits. Also because of the asynchronicity of processes, threads, you can not guarantee the order that the processes will get the opportunity to put() into the queue. Also you can't (and shouldn't) depend on the time that __del__ gets called. It can get called at any time, in any order and sometimes not at all.* Hope this helps. * http://docs.python.org/3/reference/datamodel.html?highlight=__del__#object.__del__ -- https://mail.python.org/mailman/listinfo/python-list
Re: os.system() not responding on django... any reason?
On Fri, Mar 1, 2013, at 09:24 AM, Roy Smith wrote: > In article <4fcc93b7-3be9-416f-a2d4-bdc6cba21...@googlegroups.com>, > Jaiky wrote: > > [a lot of code involving ssh and paramiko] > > Here's a few general suggestions: > > 1) Try to reduce this to the smallest possible amount of code which > demonstrates the problem. You gave us a page full of complicated stuff. > Keep hacking away lines of code that don't change the behavior until you > get it down to something small and understandable. > > 2) Try to eliminate environmental problems. You're running this under > django? Does it work as a stand-alone process (i.e. without django)? Also, what is the context (Is it running in a Django view; a model? a signal handler? in settings?)? -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is Ruby on Rails more popular than Django?
> My questions: > 1. Why is Ruby on Rails much more popular than Django? AFAIK Rails got a slightly longer head start than Django. And it has been said that RoR's first killer app was a screencast. A little marketing can go a long way. Since then Django has caught up a bit with RoR in terms of maturity and adoption (I think this is in part because of RoR's adoption slowing due to it not being the NKOTB anymore (not to mention a few security embarrassments)) . > 2. Why is there a much stronger demand for Ruby on Rails developers than > Django/Python developers? I'm not sure how big the difference is, but it's probably related to its early(er) adoption. Same reason that there is a stronger demand for PHP coders. PHP hit it big first, so there is a lot more PHP code to maintain. > 3. If Doppler Value Investing were your project instead of mine, would > you recommend the Ruby on Rails route or the Django route? If you already know/work with Python than I would go the Django route. RoR and Django are not that much different nowadays as far as methodologies. The main differences I think between RoR and Django are that one is Ruby-based and one is Python-based. Other than that, if you can get used to one you can get used to the other. -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me with Event handlers please
On Sun, Mar 17, 2013, at 03:30 PM, Dreamer wrote: > Hi can anybody share some expertise on event handlers...i need to use em > to update user activity in my web appthanks in advance > Cheers You're proably going to need to be more specific about what help you need. Just a generic "give me a hand with X" is probably not going to get you very far. -a -- http://mail.python.org/mailman/listinfo/python-list