[Server-devel] [PATCH] postprocess.py gets _actually_ fleshed out- and incrontab tweaks
Michael Stone
michael at laptop.org
Mon Jun 30 15:25:23 EDT 2008
On Mon, Jun 30, 2008 at 03:11:48PM -0400, martin.langhoff at gmail.com 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
More information about the Server-devel
mailing list