public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH] egencache: --write-timestamp to create metadata/timestamp.chk
@ 2013-11-27 10:31 SebastianLuther
  2013-11-27 21:20 ` Mike Frysinger
  0 siblings, 1 reply; 6+ messages in thread
From: SebastianLuther @ 2013-11-27 10:31 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Sebastian Luther

From: Sebastian Luther <SebastianLuther@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 +0000", 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



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [gentoo-portage-dev] [PATCH] egencache: --write-timestamp to create metadata/timestamp.chk
  2013-11-27 10:31 [gentoo-portage-dev] [PATCH] egencache: --write-timestamp to create metadata/timestamp.chk SebastianLuther
@ 2013-11-27 21:20 ` Mike Frysinger
  2013-11-27 21:41   ` Sebastian Luther
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Frysinger @ 2013-11-27 21:20 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: SebastianLuther

[-- Attachment #1: Type: Text/Plain, Size: 596 bytes --]

On Wednesday 27 November 2013 05:31:17 SebastianLuther@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 +0000", 
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 +0000\n', time.gmtime()))
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-portage-dev] [PATCH] egencache: --write-timestamp to create metadata/timestamp.chk
  2013-11-27 21:20 ` Mike Frysinger
@ 2013-11-27 21:41   ` Sebastian Luther
  2013-11-27 21:45     ` Mike Frysinger
  0 siblings, 1 reply; 6+ messages in thread
From: Sebastian Luther @ 2013-11-27 21:41 UTC (permalink / raw
  To: gentoo-portage-dev

Am 27.11.2013 22:20, schrieb Mike Frysinger:
> On Wednesday 27 November 2013 05:31:17 SebastianLuther@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
>> +0000",
> 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 +0000\n', time.gmtime())) -mike
> 

What if the f.write raises an exception?


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-portage-dev] [PATCH] egencache: --write-timestamp to create metadata/timestamp.chk
  2013-11-27 21:41   ` Sebastian Luther
@ 2013-11-27 21:45     ` Mike Frysinger
  0 siblings, 0 replies; 6+ messages in thread
From: Mike Frysinger @ 2013-11-27 21:45 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Sebastian Luther

[-- Attachment #1: Type: Text/Plain, Size: 402 bytes --]

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 +0000\n', time.gmtime()))
> 
> What if the f.write raises an exception?

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

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [gentoo-portage-dev] [PATCH] egencache: --write-timestamp to create metadata/timestamp.chk
@ 2013-11-29 13:36 SebastianLuther
  2013-11-29 14:17 ` Mike Frysinger
  0 siblings, 1 reply; 6+ messages in thread
From: SebastianLuther @ 2013-11-29 13:36 UTC (permalink / raw
  To: gentoo-portage-dev

From: Sebastian Luther <SebastianLuther@gmx.de>

This is required to sync repositories using rsnyc.

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

diff --git a/bin/egencache b/bin/egencache
index 54c517e..c8d41bf 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,16 @@ 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:
+			with open(timestamp_path, "w") as f:
+				f.write(time.strftime("%a, %d %b %Y %H:%M:%S +0000\n", time.gmtime()))
+		except IOError:
+			ret.append(1)
+		else:
+			ret.append(os.EX_OK)
+
 	return max(ret)
 
 if __name__ == "__main__":
-- 
1.8.1.5



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [gentoo-portage-dev] [PATCH] egencache: --write-timestamp to create metadata/timestamp.chk
  2013-11-29 13:36 SebastianLuther
@ 2013-11-29 14:17 ` Mike Frysinger
  0 siblings, 0 replies; 6+ messages in thread
From: Mike Frysinger @ 2013-11-29 14:17 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: SebastianLuther

[-- Attachment #1: Type: Text/Plain, Size: 372 bytes --]

On Friday 29 November 2013 08:36:43 SebastianLuther@gmx.de wrote:
> +				f.write(time.strftime("%a, %d %b %Y %H:%M:%S +0000\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

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-11-29 14:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-27 10:31 [gentoo-portage-dev] [PATCH] egencache: --write-timestamp to create metadata/timestamp.chk SebastianLuther
2013-11-27 21:20 ` Mike Frysinger
2013-11-27 21:41   ` Sebastian Luther
2013-11-27 21:45     ` Mike Frysinger
  -- strict thread matches above, loose matches on Subject: below --
2013-11-29 13:36 SebastianLuther
2013-11-29 14:17 ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox