[Tutor] Shelve

2010-02-11 Thread Randy Raymond
I am running Python 2.6.4 under Windows Vista 32-bit Home Edition.  When I run:

import shelve
test=shelve.open("myTest.fil")

I get a DCPermissionerror exception.  I am an administrator on this machine (it 
is my home PC).  Python and Pythonw are both allowed exceptions to the Windows 
firewall.  I tried turning the Windows Firewall completely off, but that does 
not help.  Any ideas?  

Randy Raymond
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Downloading S3 Logs

2010-02-11 Thread Randy Raymond
Mr. Mao, I am not a professional programmer.  However, I do think that you want 
to reduce the number of "things" that you have to do in loops that go through 
the transaction (log entries in your case).  Since you are converting to a 
datetime, perhaps rather than doing a calculation, you should remove the 
calculation and compare the datetime to yesterday (yesterday=now-1, whatever 
the datetime needs to make it yesterday) in the "if" statement (I.e. change 
"time_differnce < 1" to recordDate (<-make this instead of time_difference).  

You can try changing things a bit to see if it speeds up.  For example, if a 
lot of messages are failing the "key.name.startswith("log/access_log")" test, 
then maybe make a nested if, testing "key.name.startswith("log/access_log")" 
before you actually test the date difference.  Or, switch it around and test 
the date first, the the "key.name.startswith("log/access_log")".

Sincerely,
Randy Raymond


From: Lao Mao 
Sent: Thursday, February 11, 2010 10:23 AM
To: tutor@python.org 
Subject: [Tutor] Downloading S3 Logs


Hello,

I've written the below to get the previous day's logs from an Amazon S3 bucket.


#!/usr/bin/python 
import time 
from datetime import datetime 
import boto 


daily_s3_log = open("/tmp/s3logs", "w+") 
now = datetime.now() 
connection = boto.connect_s3() 
bucket = connection.get_bucket("downloads.sekrit.co.uk") 
todays_keys = [] 


for key in bucket: 
  time_difference = (now - 
datetime(*time.strptime(key.last_modified.split(".")[0], "%Y-%m-%dT%H: 
%M:%S")[0:6])).days 
  if time_difference < 1 and key.name.startswith("log/access_log"): 
todays_keys.append(key) 


for key in todays_keys: 
  key.get_file(daily_s3_log) 


daily_s3_log.close() 


This takes about 2 mins to download a day's logs (about 25M). 


I'd appreciate any improvements or feedback on the above. 


For example, would it make sense to make the first loop into a generator 
function that yields the interesting keys?  Also is there a cleaner way to do 
the date comparison in Python 2.4?

Thanks,

Laomao










___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Shelve

2010-02-11 Thread Randy Raymond
Ok, I see that is was the directory restriction that was the problem.  Sorry 
for the simple question.

Randy Raymond


From: Randy Raymond 
Sent: Thursday, February 11, 2010 10:09 AM
To: Tutor Python 
Subject: [Tutor] Shelve


I am running Python 2.6.4 under Windows Vista 32-bit Home Edition.  When I run:

import shelve
test=shelve.open("myTest.fil")

I get a DCPermissionerror exception.  I am an administrator on this machine (it 
is my home PC).  Python and Pythonw are both allowed exceptions to the Windows 
firewall.  I tried turning the Windows Firewall completely off, but that does 
not help.  Any ideas?  

Randy Raymond






___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Just a Note

2010-02-12 Thread Randy Raymond
By the way, Alan Gauld's emails generate an error in my system.  His is the 
only emails I have a problem with so far.  At first it tried to open a News 
service.  

Randy Raymond
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread Randy Raymond

I use Editra.  Randy

--
From: "spir" 
Sent: Tuesday, February 23, 2010 11:13 AM
To: 
Subject: Re: [Tutor] What Editori?


On Tue, 23 Feb 2010 17:46:24 +0100
Giorgio  wrote:


Definitely i just use pyscripter because it has the py idle integrated in
the window.

It's very useful!


Most editors have an integreated console that allow typing commands, 
launching the interactice interpreter, and running progs all without 
quitting the editor.
I use geany which is imo good for every language... and has the absolutely 
necessary duplicate feature ;-) (*). Its only drawback is syntax 
highlighting must be set by editing config files.


Denis

(*) Does anyone know another editor that has it?


la vita e estrany

http://spir.wikidot.com/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor 


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread Randy Raymond

I use Editra.  Randy

--
From: "spir" 
Sent: Tuesday, February 23, 2010 11:13 AM
To: 
Subject: Re: [Tutor] What Editori?


On Tue, 23 Feb 2010 17:46:24 +0100
Giorgio  wrote:


Definitely i just use pyscripter because it has the py idle integrated in
the window.

It's very useful!


Most editors have an integreated console that allow typing commands,
launching the interactice interpreter, and running progs all without
quitting the editor.
I use geany which is imo good for every language... and has the absolutely
necessary duplicate feature ;-) (*). Its only drawback is syntax
highlighting must be set by editing config files.

Denis

(*) Does anyone know another editor that has it?


la vita e estrany

http://spir.wikidot.com/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor 


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Running a dos program with python

2010-03-10 Thread Randy Raymond
I use wxPython, which allows a statement like:

wx.Execute('c:\shake91.exe "FLAC.txt" "a.txt" "b.txt"')


From: Armstrong, Richard J. 
Sent: Wednesday, March 10, 2010 4:51 PM
To: Wayne Werner 
Cc: tutor@python.org 
Subject: Re: [Tutor] Running a dos program with python


 

 

From: sri...@gmail.com [mailto:sri...@gmail.com] On Behalf Of Wayne Werner
Sent: Wednesday, March 10, 2010 2:24 PM
To: Armstrong, Richard J.
Cc: tutor@python.org
Subject: Re: [Tutor] Running a dos program with python

 

On Wed, Mar 10, 2010 at 3:20 PM, Armstrong, Richard J.  
wrote:

Hello all,

 

This is my first post to the Tutor@python.org mailing list. I am in the process 
of switching from Matlab to Python and there is one task that I am having a 
hard time doing and cannot find the answer on the web. I want to write a script 
in python that will open up a windows dos program, send three inputs (file 
names) into program and then run it. I know one way to open up the dos program 
with os.system(r"c:\shake91.txt") but cannot do the rest.

 

Use the subprocess module:

http://docs.python.org/library/subprocess.html

 

untested, but should work:

 

subprocess.Popen([r'c:\shake91.txt', 'param1', 'paramN-1', 'paramN'])

 

if you want to communicate with the process you can add , 
stdout=subprocess.PIPE, stdin=subprocess.PIPE) to the function call.

 

Check the docs for more info.

HTH,

Wayne

 

Wayne,

 

It kindof works. I wrote 

 

subprocess.Popen([r'c:\shake91.exe', 'FLAC.txt', 'a.txt', 'b.txt'])

 

The dos program pops up and if I hit the enter key three times then it runs. 
How can I add these three "enters" into the script? 

 

Thanks,

 

Richie






___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor