On Mon, Jun 30, 2008 at 03:11:48PM -0400, [EMAIL PROTECTED] wrote:

> +datestamp = subprocess.Popen(['date', '-u', '+%Y-%m-%d_%H:%M'],stdout=PIPE
> +                             ).communicate()[0]
> +# comes with newline - rstrip() will chomp it
> +datestamp = datestamp.rstrip()

A common Python equivalent:

import time
time.strftime('%Y-%m-%d_%H:%M', time.gmtime())


> +sys.stdout.write(datestamp)
> +exitcode = subprocess.call(['cp', '-al',
> +                            user[5] + '/datastore-current',
> +                            user[5] + '/datastore-' + datestamp])
> +if (exitcode != 0):
> +    sys.stderr.write('Cannot cp -al')
> +    exit(1)

Seen subprocess.check_call()?

> +# Note the -n parameter here. Without it
> +# the symlink lands inside the previous
> +# target of datastore-last. Oops!
> +exitcode = subprocess.call(['ln', '--force', '-sn',
> +                 user[5] + '/datastore-' + datestamp,
> +                 user[5] + '/datastore-last'])
> +if (exitcode != 0):
> +    sys.stderr.write('Cannot ln')
> +    exit(1)

Same as above. Here I'd be tempted just to symlink(), then rename() and
be done with it.

Michael
_______________________________________________
Server-devel mailing list
[EMAIL PROTECTED]
http://lists.laptop.org/listinfo/server-devel

Reply via email to