[Server-devel] [PATCH] Introducing: server side traffic control

Martin Langhoff martin.langhoff at gmail.com
Wed Jun 25 08:33:34 EDT 2008


On Wed, Jun 25, 2008 at 4:33 AM, Jim Tittsler <jim at onnz.net> wrote:
> On Jun 25, 2008, at 12:18, martin.langhoff at gmail.com wrote:
>
> I write a lot of my "shell scripts" in Python, so I recognize the
> style... but I can't help a couple of comments.

Jim - comments welcome, mine is probably  "Python as a Second
Language" (PaSL). More pythonic approaches are welcome, as long as
they aren't too exception heavy, or resource hoggy. :-)

>> +    os.system('touch ' + recentclientsdir + '/' + clientid)
>
> I would write that:
>     open(os.path.join(recentclientsdir, clientid), 'wb').write('')
> although if you really want it to be able to fail silently, it would
> need to be wrapped in a try: except IOError: pass.

I'll give that a go...

>> +    clientcount = os.system('find ' + recentclientsdir +
>> +                            ' -mmin -5 -type f | wc -l');
>
> And your use of 'find' here and a bit further on is really succinct,

And cheap on resources - I don't ever want to have the list in memory :-)

The pure-python way looks expensive (as the pure Perl way that
File::Find implements). Can you give me an example using subprocess?

> Jim Tittsler, Gisborne

I'm sure we met before - do you ever visit Wellington? :-)

cheers,



martin
-- 
 martin.langhoff at gmail.com
 martin at laptop.org -- School Server Architect
 - ask interesting questions
 - don't get distracted with shiny stuff - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff


More information about the Server-devel mailing list