Re: [gentoo-portage-dev] [PATCH] egencache: --write-timestamp to create metadata/timestamp.chk

2013-11-29 Thread Mike Frysinger
On Friday 29 November 2013 08:36:43 sebastianlut...@gmx.de wrote:
 + f.write(time.strftime(%a, %d %b %Y %H:%M:%S 
 +\n,

would be nice to pull that time format out and into the const module.  the 
emerge actions.py file uses it too (twice actually).

 + except IOError:
 + ret.append(1)

ret.append(os.EX_IOERR) ?

otherwise looks good now
-mike


signature.asc
Description: This is a digitally signed message part.


[gentoo-portage-dev] [PATCH] egencache: --write-timestamp to create metadata/timestamp.chk

2013-11-27 Thread SebastianLuther
From: Sebastian Luther sebastianlut...@gmx.de

This is required to sync repositories using rsnyc.

URL: https://bugs.gentoo.org/488972
---
 bin/egencache | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/bin/egencache b/bin/egencache
index 54c517e..6ff1dcb 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -133,6 +133,9 @@ def parse_args(args):
common.add_argument(--ignore-default-opts,
action=store_true,
help=do not use the EGENCACHE_DEFAULT_OPTS environment 
variable)
+   common.add_argument(--write-timestamp,
+   action=store_true,
+   help=write metdata/timestamp.chk as required for rsync 
repositories)
 
update = parser.add_argument_group('--update options')
update.add_argument(--cache-dir,
@@ -1063,6 +1066,21 @@ def egencache_main(args):
gen_clogs.run()
ret.append(gen_clogs.returncode)
 
+   if options.write_timestamp:
+   timestamp_path = os.path.join(repo_path, metadata, 
timestamp.chk)
+   try:
+   timestampfile = open(timestamp_path, w)
+   try:
+   timestampfile.write(
+   time.strftime(%a, %d %b %Y %H:%M:%S 
+, time.gmtime()))
+   timestampfile.write(\n)
+   finally:
+   timestampfile.close()
+   except IOError:
+   ret.append(1)
+   else:
+   ret.append(os.EX_OK)
+
return max(ret)
 
 if __name__ == __main__:
-- 
1.8.1.5




Re: [gentoo-portage-dev] [PATCH] egencache: --write-timestamp to create metadata/timestamp.chk

2013-11-27 Thread Mike Frysinger
On Wednesday 27 November 2013 05:31:17 sebastianlut...@gmx.de wrote:
 + if options.write_timestamp:
 + timestamp_path = os.path.join(repo_path, metadata, 
 timestamp.chk)
 + try:
 + timestampfile = open(timestamp_path, w)
 + try:
 + timestampfile.write(
 + time.strftime(%a, %d %b %Y %H:%M:%S 
 +, 
time.gmtime()))
 + timestampfile.write(\n)
 + finally:
 + timestampfile.close()

use a with block, and merge those writes

with open(timestamp_path, 'w') as f:
f.write(time.strftime('%a, %d %b %Y %H:%M:%S +\n', time.gmtime()))
-mike


signature.asc
Description: This is a digitally signed message part.


Re: [gentoo-portage-dev] [PATCH] egencache: --write-timestamp to create metadata/timestamp.chk

2013-11-27 Thread Sebastian Luther
Am 27.11.2013 22:20, schrieb Mike Frysinger:
 On Wednesday 27 November 2013 05:31:17 sebastianlut...@gmx.de
 wrote:
 +if options.write_timestamp: +   timestamp_path =
 os.path.join(repo_path, metadata, timestamp.chk) +   try: +
 timestampfile = open(timestamp_path, w) +  try: +
 timestampfile.write( +   
 time.strftime(%a, %d %b %Y %H:%M:%S
 +,
 time.gmtime()))
 +timestampfile.write(\n) + 
 finally: +
 timestampfile.close()
 
 use a with block, and merge those writes
 
 with open(timestamp_path, 'w') as f: f.write(time.strftime('%a, %d
 %b %Y %H:%M:%S +\n', time.gmtime())) -mike
 

What if the f.write raises an exception?



Re: [gentoo-portage-dev] [PATCH] egencache: --write-timestamp to create metadata/timestamp.chk

2013-11-27 Thread Mike Frysinger
On Wednesday 27 November 2013 16:41:12 Sebastian Luther wrote:
 Am 27.11.2013 22:20, schrieb Mike Frysinger:
  use a with block, and merge those writes
  
  with open(timestamp_path, 'w') as f:
f.write(time.strftime('%a, %d
   %b %Y %H:%M:%S +\n', time.gmtime()))
 
 What if the f.write raises an exception?

then catch it ?  i don't understand the question.
-mike


signature.asc
Description: This is a digitally signed message part.