[Zope] - backing up Data.bbb

Jim Fulton jim.fulton@digicool.com
Mon, 18 Jan 1999 14:51:33 -0500


This is a multi-part message in MIME format.
--------------83B3AF4A3B22B8E9EE47F52F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Roman Milner wrote:
> 
>     Following a corrupted Data.bbb disaster I want to automate the
> backing up of my Data.bbb.  My question is - do I need to shut down
> zope before copying Data.bbb to ensure that it is closed properly?

Currently, yes, however, It should not be necessary to.

The issue is that Zope may partially write a record while
the database is backed up.  Currently, when Zope detects a 
partially written record on start up, it simply reports an
error.  I've made a change to BoboPOS.SimpleDB to recover if
the last record in a database had been partially written.

I'm attaching a new SimpleDB module that implements this
change. To use it, simply put it in your BoboPOS package
(lib/python/BoboPOS) in your Zope distribution and restart 
Zope.

>     If so, how can I shutdown zope properly from the command line?

You would need to use the Zope Client nachinery to make a web call.

Jim

--
Jim Fulton           mailto:jim@digicool.com
Technical Director   (888) 344-4332              Python Powered!
Digital Creations    http://www.digicool.com     http://www.python.org

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.
--------------83B3AF4A3B22B8E9EE47F52F
Content-Type: application/x-unknown-content-type-Python.File;
 name="SimpleDB.py"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filename="SimpleDB.py"

IyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMj
IyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjCiMKIyBab3BlIFB1YmxpYyBMaWNlbnNlIChaUEwp
IFZlcnNpb24gMC45LjQKIyAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0KIyAKIyBDb3B5cmlnaHQgKGMpIERpZ2l0YWwgQ3JlYXRpb25zLiAgQWxsIHJp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ICAgICAgICAgICAgICAgICAgIGV4Y2VwdDogcmFpc2UgSU9FcnJvciwgJ2NvdWxkIG5vdCBv
cGVuICcgKyBmaWxlX25hbWUKICAgICAgICAgICAgICAgICAgICBmaWxlLndyaXRlKHNlbGYu
cGFja2VkX3ZlcnNpb24pCiAgICAgICAgICAgICAgICAgICAgcmV2aXNpb25fdGltZT1Ob25l
CiAgICAgICAgICAgICAgICBpZiBub3QgY3JlYXRlOgogICAgICAgICAgICAgICAgICAgIHY9
ZmlsZS5yZWFkKGxlbihzZWxmLnBhY2tlZF92ZXJzaW9uKSkKICAgICAgICAgICAgICAgICAg
ICBpZiB2ICE9IHNlbGYucGFja2VkX3ZlcnNpb246CiAgICAgICAgICAgICAgICAgICAgICAg
IGlmIHY9PXNlbGYucGFja2VkX3ZlcnNpb24yOgogICAgICAgICAgICAgICAgICAgICAgICAg
ICAgaW1wb3J0IFNpbXBsZURCMjMKICAgICAgICAgICAgICAgICAgICAgICAgICAgIFNpbXBs
ZURCMjMuY29udmVydDIzKGZpbGUsZmlsZV9uYW1lKQogICAgICAgICAgICAgICAgICAgICAg
ICAgICAgZmlsZT1vcGVuKGZpbGVfbmFtZSwncitiJykKICAgICAgICAgICAgICAgICAgICAg
ICAgICAgIHY9ZmlsZS5yZWFkKGxlbihzZWxmLnBhY2tlZF92ZXJzaW9uKSkKICAgICAgICAg
ICAgICAgICAgICAgICAgICAgIGlmIHYgIT0gc2VsZi5wYWNrZWRfdmVyc2lvbjoKICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICByYWlzZSBzZWxmLkluY29tcGF0YWJsZUVycm9y
LCBmaWxlX25hbWUKICAgICAgICAgICAgICAgICAgICAgICAgZWxzZToKICAgICAgICAgICAg
ICAgICAgICAgICAgICAgIHJhaXNlIHNlbGYuSW5jb21wYXRhYmxlRXJyb3IsIGZpbGVfbmFt
ZQoKICAgICAgICBsb2NrX2ZpbGUoZmlsZSkKICAgICAgICBzZWxmLm5vdz1ub3c9cmV2aXNp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pZiBub3cg
PD0gc2VsZi5ub3c6CiAgICAgICAgICAgIG5vdz1zZWxmLm5vdyswLjAwMQoKICAgICAgICBp
bmRleD1zZWxmLmluZGV4CgogICAgICAgIHRyeTogcHJldj1pbmRleFtvaWRdCiAgICAgICAg
ZXhjZXB0OiBwcmV2PTAKCiAgICAgICAgaWYgdHlwZShvaWQpPT1JbnRUeXBlOgogICAgICAg
ICAgICBpaWQ9b2lkCiAgICAgICAgICAgIG09aW5mbwogICAgICAgIGVsc2U6CiAgICAgICAg
ICAgIGlpZCxtPW9pZAogICAgICAgICAgICBtPSIlcyAlcyIgJSAobSxpbmZvKQogICAgICAg
IAogICAgICAgIGxtPWZpbmQobSwnXHQnKQogICAgICAgIGlmIGxtID4gMDogcG09bVs6bG1d
CiAgICAgICAgZWxzZTogcG09bQogICAgICAgIGlmIHBtPT1zZWxmLmxhc3RtOiBtPXBtICAj
IFdlIHdhbnQgdG8gYXZvaWQgc3RvcmluZyBleHRyYSBpbmZvCiAgICAgICAgcGxlbj1sZW4o
cCkKICAgICAgICB0bGVuPTI4K3BsZW4rbGVuKG0pCiAgICAgICAgaD1wYWNrKCI+aWlkaWki
LGlpZCxwcmV2LG5vdyx0bGVuLHBsZW4pCiAgICAgICAgcG9zPXNlbGYucG9zCiAgICAgICAg
aW5kZXhbb2lkXT1wb3MKICAgICAgICBmaWxlLnNlZWsocG9zKQogICAgICAgIGZpbGUud3Jp
dGUoam9pbigoaCxwLG0saFsxNjoyMF0pLCcnKSkKICAgICAgICBmaWxlLmZsdXNoKCkKICAg
ICAgICBzZWxmLnBvcz1wb3MrdGxlbgogICAgICAgIHNlbGYubm93PW5vdwogICAgICAgIHNl
bGYubGFzdG09cG0KCiAgICBfX3NldGl0ZW1fXz1zdG9yZQoKICAgIGRlZiBhcHBlbmRfcmVj
b3JkKHNlbGYsIHJlY29yZCwgcG9zKToKICAgICAgICBmaWxlPXNlbGYuZmlsZQogICAgICAg
IGZpbGUuc2Vlayhwb3MpCiAgICAgIC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IGJ5IHRoaXMgdHJh
bnNhY3Rpb24gaGF2ZSBiZWVuIG1vZGlmaWVkIGJ5IGxhdGVyCiAgICAgICAgIyB0cmFuc2Fj
dGlvbnMuCgogICAgICAgIG1pbj1pbWF4PXBvcwogICAgICAgIHdoaWxlIHBvcyA+IDA6CiAg
ICAgICAgICAgIF9fdHJhY2ViYWNrX2luZm9fXyA9IHBvcwogICAgICAgICAgICBzZWVrKHBv
cykKICAgICAgICAgICAgaD1yZWFkKDI0KQogICAgICAgICAgICBpZiBsZW4oaCkgPCAyNDog
YnJlYWsKICAgICAgICAgICAgb2lkLHByZXYsc3RhcnQsdGxlbixwbGVuPXVucGFjaygiPmlp
ZGlpIixoKQogICAgICAgICAgICBpZiBub3Qgb2lkOiBicmVhawogICAgICAgICAgICBzZWVr
KHBvcyt0bGVuLTQpCiAgICAgICAgICAgIGlmIChyZWFkKDQpICE9IGhbMTY6MjBdIG9yCiAg
ICAgICAgICAgICAgICBwcmV2ID4gcG9zIG9yIHByZXYgPCAwIG9yIHRsZW4gPCBwbGVuKToK
ICAgICAgICAgICAgICAgIHJhaXNlIERhdGFiYXNlRXJyb3IsICgnQ29ycnVwdGVkIGRhdGEg
cmVjb3JkIGF0ICVzJyAlIHBvcykKICAgICAgICAgICAgbWxlbj10bGVuLTI4CiAgICAgICAg
ICAgIGlmIHBsZW4gPiAwOiBtbGVuPW1sZW4tcGxlbgogICAgICAgICAgICBtcG9zPXBvcyt0
bGVuLW1sZW4tNAogICAgICAgICAgICBfX3RyYWNlYmFja19pbmZvX18gPSBvaWQsIG1wb3MK
ICAgICAgICAgICAgc2VlayhtcG9zKQogICAgICAgICAgICBtPXJlYWQobWxlbikKICAgICAg
ICAgICAgbG09ZmluZChtLCdcdCcpCiAgICAgICAgICAgIGlmIGxtID4gMDogcG09bVs6bG1d
CiAgICAgICAgICAgIGVsc2U6IHBtPW0KICAgICAgICAgICAgaWYgcG0gIT0gcFQ6IGJyZWFr
CiAgICAgICAgICAgIGlmIG1ldGFfaW5kZXg6IG9pZD1vaWQsIG1ldGFfbmFtZQogICAgICAg
ICAgICBpcG9zPWluZGV4W29pZF0KICAgICAgICAgICAgaWYgaXBvcyA+IGltYXg6IGltYXg9
aXBvcwogICAgICAgICAgICBwb3M9cG9zK3RsZW4KICAgICAgICBpZiBpbWF4ID49IHBvczog
cmFpc2UgQ29uZmxpY3RFcnJvciwgKAogICAgICAgICAgICAiIiJBdHRlbXB0IHRvIHVuZG8g
YSB0cmFuc2FjdGlvbiBidXQgc29tZSBvZiB0aGUgZGF0YSB0aGF0IHdhcwogICAgICAgICAg
ICBtb2RpZmllZCBieSB0aGUgdHJhbnNhY3Rpb24gd2FzIGxhdGVyIG1vZGlmaWVkIGJ5IG90
aGVyCiAgICAgICAgICAgIHRyYW5zYWN0aW9ucy4gIiIiKQogICAgICAgIG1heD1wb3MKCiAg
ICAgICAgIyBPSywgbm93IGRvIHRoZSB1bmRvLgogICAgICAgIHBvcz1taW4KICAgICAgICB3
aGlsZSBwb3MgPj0gbWluIGFuZCBwb3MgPCBtYXg6CiAgICAgICAgICAgIF9fdHJhY2ViYWNr
X2luZm9fXyA9IHBvcwogICAgICAgICAgICBzZWVrKHBvcykKICAgICAgICAgICAgaD1yZWFk
KDI0KQogICAgICAgICAgICBpZiBsZW4oaCkgPCAyNDogYnJlYWsKICAgICAgICAgICAgb2lk
LHByZXYsc3RhcnQsdGxlbixwbGVuPXVucGFjaygiPmlpZGlpIixoKQogICAgICAgICAgICBp
aWQ9b2lkCiAgICAgICAgICAgIGlmIG1ldGFfaW5kZXg6IG9pZD1vaWQsIG1ldGFfbmFtZQog
ICAgICAgICAgICBzZWVrKHBvcykKICAgICAgICAgICAgd3JpdGUoJ1wwXDBcMFwwJykKICAg
ICAgICAgICAgaWYgaW5kZXhbb2lkXT09cG9zOgogICAgICAgICAgICAgICAgb2lkcy5hcHBl
bmQoaWlkKQogICAgICAgICAgICAgICAgaWYgcHJldiA+IDA6CiAgICAgICAgICAgICAgICAg
ICAgd2hpbGUgcHJldiA+IDA6CiAgICAgICAgICAgICAgICAgICAgICAgIF9fdHJhY2ViYWNr
X2luZm9fXyA9IG9pZCwgcHJldgogICAgICAgICAgICAgICAgICAgICAgICBzZWVrKHByZXYp
CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIHJlYWQoNCkhPSdcMFwwXDBcMCc6CiAgICAg
ICAgICAgICAgICAgICAgICAgICAgICBzZWxmLmluZGV4W29pZF09cHJldgogICAgICAgICAg
ICAgICAgICAgICAgICAgICAgYnJlYWsKICAgICAgICAgICAgICAgICAgICAgICAgcHJldiw9
dW5wYWNrKCI+aSIscmVhZCg0KSkKICAgICAgICAgICAgICAgIGlmIHByZXYgPD0gMDogZGVs
IGluZGV4W29pZF0KICAgICAgICAgICAgcG9zPXBvcyt0bGVuCiAgICAgICAgZmlsZS5mbHVz
aCgpCgogICAgICAgIGlmIGl0IGlzIG5vdCBOb25lOgogICAgICAgICAgICB0PXNlbGYuX3Ry
YW5zYWN0aW9ucwogICAgICAgICAgICBkZWwgdFtpdF0KCiAgICAgICAgcmV0dXJuIG9pZHMK
CiAgICBkZWYgb29wcyhzZWxmLHM9Tm9uZSxub3c9Tm9uZSk6CiAgICAgICAgJycnXAogICAg
ICAgIFVuZG8gYWxsIGNoYW5nZXMgbWFkZSB3aXRoaW4gdGhlIG1vc3QgcmVjZW50IHMgc2Vj
b25kcy4KICAgICAgICBPciwgdW5kbyB0aGUgbGFzdCBjaGFuZ2UsIGlmIHMgaXMgb21taXR0
ZWQuCiAgICAgICAgJycnCiAgICAgICAgIyBUaGUgY3VycmVudCBpbXBsZW1lbnRhdGlvbiBv
ZiB0aGlzIGlzIHN0dXBpZC4KICAgICAgICAjIEl0IHNob3VsZCBiZSBjaGFuZ2VkIHRvIHRh
a2UgYWR2YW50YWdlIG9mIHRoZSBmYWN0IHRoYXQKICAgICAgICAjIFdlIGNhbiBub3IgbWFy
Y2ggYmFja3dhcmQgZnJvbSB0aGUgZW5kIG9mIHRoZSBmaWxlCiAgICAgICAgaWYgbm93IGlz
IE5vbmU6CiAgICAgICAgICAgIG5vdz10aW1lLnRpbWUoKQogICAgICAgICAgICBpZiBub3cg
PD0gc2VsZi5ub3c6IHJldHVybiBbXQogICAgICAgIGluZGV4PXNlbGYuaW5kZXgKICAgICAg
ICBpdGVtcz1pbmRleC5pdGVtcygpCiAgICAgICAgZm91bmR1cHM9MAogICAgICAgIGZvdW5k
ZGVscz0wCiAgICAgICAgZmlsZT1zZWxmLmZpbGUKICAgICAgICBzZWVrPWZpbGUuc2Vlawog
ICAgICAgIHJlYWQ9ZmlsZS5yZWFkCgogICAgICAgIGlmIHMgaXMgTm9uZToKICAgICAgICAg
ICAgcz0wCiAgICAgICAgICAgIGZvciBvaWQscG9zIGluIGl0ZW1zOgogICAgICAgICAgICAg
ICAgX190cmFjZWJhY2tfaW5mb19fID0gb2lkLCBwb3MKICAgICAgICAgICAgICAgIHNlZWso
cG9zKzgpCiAgICAgICAgICAgICAgICB0LD11bnBhY2soIj5kIixyZWFkKDgpKQogICAgICAg
ICAgICAgICAgaWYgdCA+IHM6IHM9dAogICAgICAgICAgICBmb3Igb2lkLHBvcyBpbiBkaXRl
bXM6CiAgICAgICAgICAgICAgICBfX3RyYWNlYmFja19pbmZvX18gPSBvaWQsIHBvcwogICAg
ICAgICAgICAgICAgc2Vlayhwb3MrOCkKICAgICAgICAgICAgICAgIHQsPXVucGFjaygiPmQi
LHJlYWQoOCkpCiAgICAgICAgICAgICAgICBpZiB0ID4gczogcz1lbmQKICAgICAgICAgICAg
cz1ub3ctcwogICAgICAgIG1heHQ9bm93LXMKCiAgICAgICAgYWZmZWN0ZWQ9W10KICAgICAg
ICBtaW5wPU5vbmUKICAgICAgICBmb3Igb2lkLHBvcyBpbiBkaXRlbXM6CiAgICAgICAgICAg
IF9fdHJhY2ViYWNrX2luZm9fXyA9IG9pZCwgcG9zCiAgICAgICAgICAgIHNlZWsocG9zKzgp
CiAgICAgICAgICAgIHQsPXVucGFjaygiP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m
LmZpbGUKICAgICAgICByZWFkPWZpbGUucmVhZAogICAgICAgIHNlZWs9ZmlsZS5zZWVrCiAg
ICAgICAgd3JpdGU9ZmlsZS53cml0ZQogICAgICAgIGZsdXNoPWZpbGUuZmx1c2gKICAgICAg
ICBmb3IgcG9zIGluIGluZGV4LnN1YmluZGV4KHRuYW1lKS52YWx1ZXMoKToKICAgICAgICAg
ICAgd2hpbGUgcG9zID4gMDoKICAgICAgICAgICAgICAgIF9fdHJhY2ViYWNrX2luZm9fXyA9
IHBvcwogICAgICAgICAgICAgICAgc2Vlayhwb3MpCiAgICAgICAgICAgICAgICB3cml0ZSgn
XDBcMFwwXDAnKQogICAgICAgICAgICAgICAgZmx1c2goKQogICAgICAgICAgICAgICAgIyBJ
ZiB0aGVyZSBhcmUgcHJldmlvdXMgcmVjb3Jkcywgd2Ugd2FudCB0byBnZXQgdGhlbSB0b286
CiAgICAgICAgICAgICAgICBwb3MsPXVucGFjaygiPmkiLHJlYWQoNCkpCiAgICAgICAgaW5k
ZXgucmVtb3ZlU3ViaW5kZXgodG5hbWUpCgogICAgICAgIG1heHA9MAogICAgICAgIGZvciBz
dWJpbmRleCBpbiBpbmRleC5zdWJpbmRleGVzKCk6CiAgICAgICAgICAgIG1heHA9bWF4KG1h
eHAsbWF4KHN1YmluZGV4LnZhbHVlcygpKSkKICAgICAgICAKICAgICAgICBpZiBtYXhwOgog
ICAgICAgICAgICBfX3RyYWNlYmFja19pbmZvX18gPSBtYXhwCiAgICAgICAgICAgIHNlZWso
bWF4cCsxNikKICAgICAgICAgICAgdGxlbiw9dW5wYWNrKCI+aSIsZmlsZS5yZWFkKDQpKQog
ICAgICAgICAgICBtYXhwPW1heHArdGxlbgogICAgICAgIGVsc2U6CiAgICAgICAgICAgIG1h
eHA9bGVuKHNlbGYucGFja2VkX3ZlcnNpb24pCiAgICAgICAgZmlsZS5mbHVzaCgpCiAgICAg
ICAgaWYgbWF4cCA8IHNlbGYucG9zOgogICAgICAgICAgICB0cnk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ZSBmaXJzdCBy
ZWNvcmQuCiAgICAgICAgIwogICAgICAgICMgTm90ZSB0aGF0IHdlIGhhdmUgdG8gbWFpbnRh
aW4gYW4gaW52YXJpYW50IHRoYXQgdGhlIHJlY29yZAogICAgICAgICMgdGltZXMgaW4gYSBT
aW1wbGVEQiBtdXN0IGJlIGFzY2VuZGluZywgc28gd2Ugd2lsbCByZXNldCB0aGUKICAgICAg
ICAjIHJlY29yZCB0aW1lcyB0byBiZSBub3cgcGx1cyBhIHNtYWxsIGluY3JlbWVudCBuZWNl
c3NhcnkgdG8KICAgICAgICAjIGdpdmUgZWFjaCByZWNvcmQgYSB1bmlxdWUgdGltZS4KICAg
ICAgICAKICAgICAgICB0cnk6IGluZGV4PXNlbGYuaW5kZXguc3ViaW5kZXgodG5hbWUpCiAg
ICAgICAgZXhjZXB0OiByZXR1cm4gKCksKCkKICAgICAgICBmaWxlPXNlbGYuZmlsZQogICAg
ICAgIHNlZWs9ZmlsZS5zZWVrCiAgICAgICAgcmVhZD1maWxlLnJlYWQKICAgICAgICBiaW5k
ZXg9YmFzZS5pbmRleAogICAgICAgIGRicD1iYXNlLmN1cnJlbnRfcG9zKCkKICAgICAgICB0
aW5kZXg9e30KCiAgICAgICAgZGF0YT1bXQogICAgICAgIG9pZHM9W10KCiAgICAgICAgdD10
aW1lLnRpbWUoKQogICAgICAgIGFwcGVuZD1iYXNlLmFwcGVuZF9yZWNvcmQKCiAgICAgICAg
IyBDb3B5IHVwZGF0ZSByZWNvcmRzOgogICAgICAgIGZvciBvaWQgaW4gaW5kZXgua2V5cygp
OgoKICAgICAgICAgICAgcG9zPWluZGV4W29pZF0KICAgICAgICAgICAgX190cmFjZWJhY2tf
aW5mb19fID0gb2lkLCBwb3MKCiAgICAgICAgICAgICNzZWVrKHBvcys4KQogICAgICAgICAg
ICAjc3RhcnQsdGxlbj11bnBhY2soIj5kaSIscmVhZCgxMikpCiAgICAgICAgICAgIHNlZWso
cG9zKQogICAgICAgICAgICBoPXJlYWQoMjQpCiAgICAgICAgICAgIHJvaWQscHJldixzdGFy
dCx0bGVuLHBsZW49dW5wYWNrKCI+aWlkaWkiLGgpCiAgICAgICAgICAgIHNlZWsocG9zK3Rs
ZW4tNCkKICAgICAgICAgICAgaWYgKHJlYWQoNCkgIT0gaFsxNjoyMF0gb3IKICAgICAgICAg
ICAgICAgIHJvaWQgIT0gb2lkIG9yIHByZXYgPiBwb3Mgb3IgcHJldiA8IDAgb3IgdGxlbiA8
IHBsZW4pOgogICAgICAgICAgICAgICAgcmFpc2UgRGF0YWJhc2VFcnJvciwgKAogICAgICAg
ICAgICAgICAgICAgICdDb3JydXB0ZWQgZGF0YSByZWNvcmQgYXQgJXMgaW4gdHJhbnNhY3Rp
b24gZmlsZScgJSBwb3MpCiAgICAgICAgICAgIHNlZWsocG9zKzIwKQoKICAgICAgICAgICAg
cD1yZWFkKHRsZW4tMjApCiAgICAgICAgICAgIHRyeTogcHJldj1iaW5kZXhbb2lkXQogICAg
ICAgICAgICBleGNlcHQ6IHByZXY9MAogICAgICAgICAgICBpZiBpbmZvOgogICAgICAgICAg
ICAgICAgcGxlbiw9dW5wYWNrKCI+aSIscFs6NF0pCiAgICAgICAgICAgICAgICBtbGVuPXRs
ZW4tMjgKICAgICAgICAgICAgICAgIGlmIHBsZW4gPiAwOiBtbGVuPW1sZW4tcGxlbgogICAg
ICAgICAgICAgICAgbT1wWy00LW1sZW46LTRdCiAgICAgICAgICAgICAgICBsPWZpbmQobSwn
XHQnKQogICAgICAgICAgICAgICAgaWYgbCA+IDA6IG09bVs6bF0KICAgICAgICAgICAgICAg
IGluZm89IiVzXHQlcyIgJSAobSxpbmZvKQogICAgICAgICAgICAgICAgdGxlbj10bGVuK2xl
bihpbmZvKS1tbGVuCiAgICAgICAgICAgICAgICBwPXBbOi00LW1sZW5dK2luZm8rcGFjaygi
PmkiLHRsZW4pCiAgICAgICAgICAgICAgICBpbmZvPU5vbmUKCiAgICAgICAgICAgIHA9cGFj
aygiPmlpZGki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VsZi5maWxlX25hbWUrJy5pbmRleCcKICAg
ICAgICB0bXBfbmFtZT1pbmRleF9uYW1lKycudG1wJwoKICAgICAgICBmPW9wZW4odG1wX25h
bWUsJ3diJykKICAgICAgICBwPVBpY2tsZXIoZiwxKQoKICAgICAgICBpbmZvPXsnaW5kZXgn
OiBzZWxmLmluZGV4LCAncG9zJzogc2VsZi5wb3N9CiAgICAgICAgdHJ5OiAKICAgICAgICAg
ICAgdD1zZWxmLl90cmFuc2FjdGlvbnMKICAgICAgICAgICAgaW5mb1snX3RyYW5zYWN0aW9u
cyddPXQKICAgICAgICBleGNlcHQ6IHBhc3MKCiAgICAgICAgcC5kdW1wKGluZm8pCiAgICAg
ICAgZi5mbHVzaCgpCiAgICAgICAgZi5jbG9zZSgpCiAgICAgICAgdHJ5OgogICAgICAgICAg
ICB0cnk6IG9zLnVubGluayhpbmRleF9uYW1lKQogICAgICAgICAgICBleGNlcHQ6IHBhc3MK
ICAgICAgICAgICAgb3MucmVuYW1lKHRtcF9uYW1lLCBpbmRleF9uYW1lKQogICAgICAgIGV4
Y2VwdDogcGFzcwoKICAgIGRlZiByZXN0b3JlX2luZGV4KHNlbGYpOgogICAgICAgICIiIkxv
YWQgdGhlIGRhdGFiYXNlIGluZGV4IGZyb20gYSBmaWxlIHRvIHN1cHBvcnQgcXVpY2sgc3Rh
cnR1cAogICAgICAgICIiIgogICAgICAgIGZpbGVfbmFtZT1zZWxmLmZpbGVfbmFtZQogICAg
ICAgIGluZGV4X25hbWU9ZmlsZV9uYW1lKycuaW5kZXgnCiAgICAgICAgCiAgICAgICAgZj1v
cGVuKGluZGV4X25hbWUsJ3JiJykKICAgICAgICBwPVVucGlja2xlcihmKQoKICAgICAgICBp
bmZvPXAubG9hZCgpCiAgICAgICAgaWYgdHlwZShpbmZvKSBpcyB0eXBlKCgpKToKICAgICAg
ICAgICAgcD17J2luZGV4JzogaW5mb1swXSwgJ3Bvcyc6IGluZm9bMl19CiAgICAgICAgICAg
IHRyeTogcFsnX3RyYW5zYWN0aW9ucyddPWluZm9bM10KICAgICAgICAgICAgZXhjZXB0IElu
ZGV4RXJyb3I6IHBhc3MKICAgICAgICAgICAgaW5mbz1wCgogICAgICAgIGZpbGU9c2VsZi5m
aWxlCiAgICAgICAgZmlsZS5mbHVzaCgpCiAgICAgICAgZmlsZS5zZWVrKDAsMikKICAgICAg
ICBmaWxlX3NpemU9ZmlsZS50ZWxsKCkKICAgICAgICBzYXZlZF9wb3M9aW5mb1sncG9zJ10K
ICAgICAgICBpZiBzYXZlZF9wb3MgPD0gZmlsZV9zaXplOgogICAgICAgICAgICBpbmRleD1p
bmZvWydpbmRleCddCiAgICAgICAgICAgIGxhc3RfcmVjb3JkPWluZGV4Lm1heF92YWx1ZSgp
CiAgICAgICAgICAgIGZpbGUuc2VlayhsYXN0X3JlY29yZCkKICAgICAgICAgICAgb2lkPXVu
cGFjaygiPmkiLGZpbGUucmVhZCg0KSlbMF0KICAgICAgICAgICAgaW5kZXg9aW5mb1snaW5k
ZXgnXQogICAgICAgICAgICBpZiBpbmRleFtvaWRdPT1sYXN0X3JlY29yZDoKICAgICAgICAg
ICAgICAgIHBvcz1zYXZlZF9wb3MKICAgICAgICAgICAgICAgIGlmIHBvcyA8IGZpbGVfc2l6
ZToKICAgICAgICAgICAgICAgICAgICBpbmRleCxwb3M9cmVhZF9pbmRleChmaWxlLCBtZXRh
X2luZGV4PXNlbGYubWV0YV9pbmRleCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICBpbmRleD1pbmRleCwgcG9zPXBvcykKICAgICAgICAgICAgICAgIGluZm9b
J2luZGV4J10sIGluZm9bJ3BvcyddID0gaW5kZXgsIHBvcwogICAgICAgICAgICByZXR1cm4g
aW5mbwoKICAgICAgICByYWlzZSAnSW5kZXhFcnJvcicsICdpbmRleCBkYXRhIGluY29ycmVj
dCcKCiAgICBkZWYgdHJhbnNhY3Rpb25faW5mbyhzZWxmLCBzdGFydCwgZW5kLCBwcmVmaXg9
JycsIHRwcmVmaXg9JycsIHNpbmNlPTApOgogICAgICAgIGZpbGU9c2VsZi5maWxlCiAgICAg
ICAgc2Vlaz1maWxlLnNlZWsKICAgICAgICByZWFkPWZpbGUucmVhZAogICAgICAgIHVucGFj
az1zdHJ1Y3QudW5wYWNrCiAgICAgICAgc3BsaXQ9c3RyaW5nLnNwbGl0CiAgICAgICAgaT0w
CiAgICAgICAgcj1bXQogICAgICAgIHBvcz1zZWxmLnBvcwogICAgICAgIGxhc3Q9Tm9uZQog
ICAgICAgIGxhc3RtPSgpCiAgICAgICAgbGFzdHBvcz0wCiAgICAgICAgbHA9bGVuKHByZWZp
eCkKICAgICAgICBsdD1sZW4odHByZWZpeCkKICAgICAgICB3aGlsZSAxOgogICAgICAgICAg
ICBzZWVrKHBvcy00KQogICAgICAgICAgICB0bGVuLD11bnBhY2soIj5pIiwgcmVhZCg0KSkK
ICAgICAgICAgICAgcG9zPXBvcy10bGVuCiAgICAgICAgICAgIGlmIHBvcyA8IDA6IGJyZWFr
CiAgICAgICAgICAgIHNlZWsocG9zKQoKICAgICAgICAgICAgaD1yZWFkKDI0KQogICAgICAg
ICAgICBvaWQscHJldixzdGFydHQsdGxlbjEscGxlbj11bnBhY2soIj5paWRpaSIsaCkKICAg
ICAgICAgICAgaWYgc3RhcnR0IDw9IHNpbmNlOiBicmVhawogICAgICAgICAgICBpZiBub3Qg
b2lkOiBjb250aW51ZQogICAgICAgICAgICBpZiAodGxlbiAhPSB0bGVuMSBvcgogICAgICAg
ICAgICAgICAgcHJldiA+IHBvcyBvciBwcmV2IDwgMCBvciB0bGVuIDwgcGxlbik6CiAgICAg
ICAgICAgICAgICByYWlzZSBEYXRhYmFzZUVycm9yLCAoJ0NvcnJ1cHRlZCBkYXRhIHJlY29y
ZCBhdCAlcycgJSBwb3MpCiAgICAgICAgICAgIG5tbGVuPXBsZW4rMjQKICAgICAgICAgICAg
c2Vlayhwb3Mrbm1sZW4pCiAgICAgICAgICAgIG1sZW49dGxlbi1ubWxlbi00CiAgICAgICAg
ICAgIG09cmVhZChtbGVuKQogICAgICAgICAgICBpZiBtWzpsdF0gIT0gdHByZWZpeDogY29u
dGludWUKICAgICAgICAgICAgbT1zcGxpdChtLCdcdCcpCiAgICAgICAgICAgIHQ9bVswXQog
ICAgICAgICAgICBpZiB0ICE9IGxhc3Q6CiAgICAgICAgICAgICAgICBpZiBsZW4obGFzdG0p
ID4gMSBhbmQgbGFzdG1bMV1bOmxwXT09cHJlZml4OiAKICAgICAgICAgICAgICAgICAgICBp
ZiBpID49IHN0YXJ0IGFuZCBpIDwgZW5kOgogICAgICAgICAgICAgICAgICAgICAgICBsYXN0
bVswOjBdPVtsYXN0cG9zXQogICAgICAgICAgICAgICAgICAgICAgICByLmFwcGVuZChsYXN0
bSkKICAgICAgICAgICAgICAgICAgICBpPWkrMQogICAgICAgICAgICAgICAgICAgIGlmIGkg
Pj0gZW5kOiBicmVhawogICAgICAgICAgICAgICAgbGFzdD10CiAgICAgICAgICAgIGxhc3Rt
PW0KICAgICAgICAgICAgbGFzdHBvcz1wb3MKCiAgICAgICAgaWYgbGVuKGxhc3RtKSA+IDEg
YW5kIGxhc3RtWzFdWzpscF09PXByZWZpeCBhbmQgaSA+PSBzdGFydCBhbmQgaSA8IGVuZDoK
ICAgICAgICAgICAgbGFzdG1bMDowXT1bbGFzdHBvc10KICAgICAgICAgICAgci5hcHBlbmQo
bGFzdG0pCgogICAgICAgIHJldHVybiByCgogICAgZGVmIHJlY29yZChzZWxmLCBpZCk6CiAg
ICAgICAgIiIiUmV0dXJuIHRoZSByZWNvcmQgZGF0YSBmb3IgdGhlIGdpdmVuIGlkLgogICAg
ICAgICIiIgogICAgICAgIGZpbGU9c2VsZi5maWxlCiAgICAgICAgcmVhZD1maWxlLnJlYWQK
ICAgICAgICBwb3M9c2VsZi5pbmRleFtpZF0KICAgICAgICBmaWxlLnNlZWsocG9zKQogICAg
ICAgIGg9cmVhZCgyNCkKICAgICAgICBvaWRfLCBwc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ZS53cml0ZQogICAgICAgIGZp
bGU9c2VsZi5maWxlCiAgICAgICAgc2Vlaz1maWxlLnNlZWsKICAgICAgICByZWFkPWZpbGUu
cmVhZAoKICAgICAgICBleHBvcnRlZD17fQogICAgICAgIHdhc19leHBvcnRlZD1leHBvcnRl
ZC5oYXNfa2V5CiAgICAgICAgb2lkcz1bb2lkXQoKICAgICAgICB3aGlsZSBvaWRzOgogICAg
ICAgICAgICBpZD1vaWRzWy0xXQogICAgICAgICAgICBkZWwgb2lkc1stMV0KICAgICAgICAg
ICAgaWYgdHlwZShpZCkgaXMgVHVwbGVUeXBlOiBpZCwga2xhc3MgPSBpZAogICAgICAgICAg
ICBlbGlmIHR5cGUoaWQpIGlzIFN0cmluZ1R5cGU6IGlkPWF0b2koaWQpCgogICAgICAgICAg
ICBpZiB3YXNfZXhwb3J0ZWQoaWQpOgogICAgICAgICAgICAgICAgaWYgaWQ9PW9pZDoKICAg
ICAgICAgICAgICAgICAgICByYWlzZSAnRXhwb3J0RXJyb3InLCAoJ09iamVjdCAlcyByZWZl
cmVuY2VzIGl0c2VsZicgJSBpZCkKICAgICAgICAgICAgICAgIGNvbnRpbnVlCgogICAgICAg
ICAgICBpZiBpbmRleC5oYXNfa2V5KGlkKToKICAgICAgICAgICAgICAgIHBvcz1pbmRleFtp
ZF0KICAgICAgICAgICAgICAgIHNlZWsocG9zKQogICAgICAgICAgICAgICAgaD1yZWFkKDI0
KQogICAgICAgICAgICAgICAgb2lkXywgcHJldiwgc3RhcnQsIHRsZW4sIHBsZW4gPSB1bnBh
Y2soIj5paWRpaSIsIGgpCiAgICAgICAgICAgICAgICBpZiAob2lkXyAhPSBpZCBvciBwcmV2
IDwgMCBvciBwcmV2ID49IHBvcwogICAgICAgICAgICAgICAgICAgIG9yIHBsZW4gPiB0bGVu
IG9yIHBsZW4gPCAwKToKICAgICAgICAgICAgICAgICAgICByYWlzZSBEYXRhYmFzZUVycm9y
LCAnQ29ycnVwdGVkIGRhdGEgcmVjb3JkIGF0ICVzJyAlIHBvcwogICAgICAgICAgICAgICAg
cD1yZWFkKHBsZW4pCiAgICAgICAgICAgICAgICB0PXJlYWQodGxlbi1wbGVuLTI0KQogICAg
ICAgICAgICAgICAgaWYgdFstNDpdICE9IGhbMTY6MjBdOiAKICAgICAgICAgICAgICAgICAg
ICByYWlzZSBEYXRhYmFzZUVycm9yLCAnQ29ycnVwdGVkIGRhdGEgcmVjb3JkIGF0ICVzJyAl
IHBvcwogICAgICAgICAgICBlbHNlOgogICAgICAgICAgICAgICAgIyBIbSwgaG9wZWZ1bGx5
LCB3ZSBhcmUgYSBUREIgYW5kIGNhbiBmYWxsIGJhY2sgdG8gb3VyCiAgICAgICAgICAgICAg
ICAjIGJhc2UgZGIKICAgICAgICAgICAgICAgIGlmIGZhbGxiYWNrIGlzIE5vbmU6CiAgICAg
ICAgICAgICAgICAgICAgIyBUaGVyZSBpcyBubyBJRC4gIFdlIG11c3QgaGF2ZSBmYWxsZW4g
dmljdGVtIHRvIHRoZSBvbGQKICAgICAgICAgICAgICAgICAgICAjIHBhY2svdW5kbyBidWcu
CiAgICAgICAgICAgICAgICAgICAgY29udGludWUKICAgICAgICAgICAgICAgIGgsIHAsIHQg
PSBmYWxsYmFjayhpZCkKCiAgICAgICAgICAgIHdyaXRlKGhbOjRdKQogICAgICAgICAgICB3
cml0ZSgiXDBcMFwwXDAiKQogICAgICAgICAgICB3cml0ZShoWzg6XSkKICAgICAgICAgICAg
d3JpdGUocCkKICAgICAgICAgICAgd3JpdGUodCkKCiAgICAgICAgICAgIHU9VW5waWNrbGVy
KFN0cmluZ0lPKHApKQogICAgICAgICAgICB1LnBlcnNpc3RlbnRfbG9hZD1vaWRzCiAgICAg
ICAgICAgIHUubm9sb2FkKCkKICAgICAgICAgICAgdS5ub2xvYWQoKQoKICAgICAgICAgICAg
ZXhwb3J0ZWRbaWRdPTEKCiAgICBkZWYgaW1wb3J0b2lkKHNlbGYsIG5ld19vaWQsIGlucHV0
X2ZpbGUsIGlu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W4tcGxlbi0yNCkgIyBza2lwIG1ldGEtZGF0YSBhbmQgdHJhaWxpbmcgbGVuZ3Ro
CgogICAgICAgICAgICBfX3RyYWNlYmFja19pbmZvX189b2lkcywgb29pZCwgbm90IG9pZHMK
CiAgICAgICAgICAgIGlmIG9pZHM6CiAgICAgICAgICAgICAgICBvaWQ9b2lkc1tvb2lkXQog
ICAgICAgICAgICAgICAgaWYgdHlwZShvaWQpIGlzIFR1cGxlVHlwZTogb2lkPW9pZFswXQog
ICAgICAgICAgICBlbHNlOiBvaWRzW29vaWRdPXJldHVybl9vaWQ9b2lkPW5ld19vaWQoKQoK
ICAgICAgICAgICAgcGZpbGU9U3RyaW5nSU8ocCkKICAgICAgICAgICAgdW5waWNrbGVyPVVu
cGlja2xlcihwZmlsZSkKICAgICAgICAgICAgdW5waWNrbGVyLnBlcnNpc3RlbnRfbG9hZD1i
YWRfbG9hZAogICAgICAgICAgICB1bnBpY2tsZXIubG9hZCgpCiAgICAgICAgICAgIGwxPXBm
aWxlLnRlbGwoKQogICAgICAgICAgICB1bnBpY2tsZXIucGVyc2lzdGVudF9sb2FkPXBlcnNp
c3RlbnRfbG9hZAogICAgICAgICAgICBuZXdwPVN0cmluZ0lPKCkKICAgICAgICAgICAgbmV3
cC53cml0ZShwWzpsMV0pCiAgICAgICAgICAgIHBpY2tsZXI9UGlja2xlcihuZXdwLDEpCiAg
ICAgICAgICAgIHBpY2tsZXIucGVyc2lzdGVudF9pZD1wZXJzaXN0ZW50X2lkCiAgICAgICAg
ICAgIHBpY2tsZXIuZHVtcCh1bnBpY2tsZXIubG9hZCgpKQogICAgICAgICAgICBwPW5ld3Au
Z2V0dmFsdWUoKQogICAgICAgICAgICBwbGVuPWxlbihwKQogICAgICAgICAgICB0bGVuPXBs
ZW4rbGVuKGluZm8pKzI4CiAgICAgICAgICAgIGg9cGFjaygiPmlpZGlpIiwgb2lkLCAwLCBz
dGFydCwgdGxlbiwgcGxlbikKICAgICAgICAgICAgd3JpdGUoIiVzJXMlcyVzIiAlIChoLHAs
aW5mbyxoWzE2OjIwXSkpCiAgICAgICAgICAgIGluZGV4W29pZF09cG9zCiAgICAgICAgICAg
IHBvcz1zZWxmLnBvcz1wb3MrdGxlbgogICAgICAgICAgICBzdGFydD1zdGFydCswLjAwMgog
ICAgICAgICAgICBpZiBmaXJzdDoKICAgICAgICAgICAgICAgIGw9ZmluZChpbmZvLCAnXHQn
KQogICAgICAgICAgICAgICAgaWYgbCA+PSAwOiBpbmZvPWluZm9bOmxdCiAgICAgICAgICAg
ICAgICBmaXJzdD0wCgogICAgICAgIHJldHVybiByZXR1cm5fb2lkCgogICAgZGVmIF9fbGVu
X18oc2VsZik6IHJldHVybiBsZW4oc2VsZi5pbmRleCkKCiAgICBkZWYgaGFzX2tleShzZWxm
LGtleSk6IHJldHVybiBzZWxmLmluZGV4Lmhhc19rZXkoa2V5KQoKICAgIGRlZiBrZXlzKHNl
bGYpOiByZXR1cm4gc2VsZi5pbmRleC5rZXlzKCkKCiAgICBkZWYgbWF4X2tleShzZWxmKToK
ICAgICAgICBpbmRleD1zZWxmLmluZGV4CiAgICAgICAgdHJ5OiBtPWluZGV4Lm1heF9rZXko
KQogICAgICAgIGV4Y2VwdDogCiAgICAgICAgICAgIG09aW5kZXgua2V5cygpCiAgICAgICAg
ICAgIG09bSBhbmQgbWF4KG0pIG9yIDAKICAgICAgICByZXR1cm4gbQoKICAgIGRlZiBvYmpl
Y3RSZWZlcmVuY2VzSW4oc2VsZiwgb2lkKToKICAgICAgICBwPXNlbGZbb2lkXQogICAgICAg
IHU9VW5waWNrbGVyKFN0cmluZ0lPKHApKQogICAgICAgIHUucGVyc2lzdGVudF9sb2FkPWw9
W10KICAgICAgICB1Lm5vbG9hZCgpCiAgICAgICAgdHJ5OiB1Lm5vbG9hZCgpCiAgICAgICAg
ZXhjZXB0OiBwYXNzCiAgICAgICAgdHQ9dHlwZSgoKSkKICAgICAgICBmb3IgaSBpbiByYW5n
ZShsZW4obCkpOgogICAgIC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ICBleGNlcHQ6IHBhc3MgIyBCcm9rZW4gcmVmZXJl
bmNlLCBXYWFhYSEgTm8gcG9pbnQgaW4gZm9sbG93aW5nLgogICAgICAgIGVsc2U6CiAgICAg
ICAgICAgIHJvb3RkW29pZF09MQogICAgICAgICAgICBzZWVrKHBvcysyMCkKICAgICAgICAg
ICAgcGxlbiw9dW5wYWNrKCI+aSIscmVhZCg0KSkKICAgICAgICAgICAgcD1yZWFkKHBsZW4p
CiAgICAgICAgICAgIHU9VW5waWNrbGVyKFN0cmluZ0lPKHApKQogICAgICAgICAgICB1LnBl
cnNpc3RlbnRfbG9hZD1yb290bAogICAgICAgICAgICB1Lm5vbG9hZCgpCiAgICAgICAgICAg
IHRyeTogdS5ub2xvYWQoKQogICAgICAgICAgICBleGNlcHQ6CiAgICAgICAgICAgICAgICAj
IEhtLiAgV2UgZmFpbGVkIHRvIGRvIHNlY29uZCBsb2FkLiAgTWF5YmUgdGhlcmUgd2Fzbid0
IGEKICAgICAgICAgICAgICAgICMgc2Vjb25kIHBpY2tsZS4gIExldCdzIGNoZWNrOgogICAg
ICAgICAgICAgICAgZj1TdHJpbmdJTyhwKQogICAgICAgICAgICAgICAgdT1VbnBpY2tsZXIo
ZikKICAgICAgICAgICAgICAgIHUucGVyc2lzdGVudF9sb2FkPVtdCiAgICAgICAgICAgICAg
ICB1Lm5vbG9hZCgpCiAgICAgICAgICAgICAgICBpZiBsZW4ocCkgPiBmLnRlbGwoKTogcmFp
c2UgVmFsdWVFcnJvciwgJ0Vycm9yIHVucGlja2xpbmcsICVzJyAlIHAKCiAgICBpZiBub246
CiAgICAgICAgZm9yIG9pZCBpbiByb290ZC5rZXlzKCk6IGRlbCBpbmRleFtvaWRdCiAgICAg
ICAgZGVsIGluZGV4Wy0xXQogICAgICAgIHJldHVybiBpbmRleAogICAgZWxzZToKICAgICAg
ICByZXR1cm4gcm9vdGQKCgpkZWYgc3VicGFjayhzZWxmLHN0YXJ0X3RpbWU9Tm9uZSk6CiAg
IC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AgIG5ld2Zp
bGU9b3BlbihkZXN0X25hbWUsJ3diJykKICAgIHdyaXRlPW5ld2ZpbGUud3JpdGUKICAgIHdy
aXRlKE11bHRpcGxlUmV2aXNpb24ucGFja2VkX3ZlcnNpb24pCiAgICBpbmRleD1zZWxmLmlu
ZGV4CiAgICBuZXdpbmRleD1JbmRleCgpCiAgICBwYWNrPXN0cnVjdC5wYWNrCiAgICB1bnBh
Y2s9c3RydWN0LnVucGFjawogICAgcG9zPW5ld3Bvcz1sZW4oTXVsdGlwbGVSZXZpc2lvbi5w
YWNrZWRfdmVyc2lvbikKCiAgICB0cnk6CiAgICAgICAgdHJ5OiB1bnJlYWNoYWJsZT1yZWFj
aGFibGUoc2VsZiwgZmlsZSwgc3RhcnRfdGltZSwgbm9uPTEpLmhhc19rZXkKICAgICAgICBl
eGNlcHQ6IHVucmVhY2hhYmxlPXt9Lmhhc19rZXkKICAgIAogICAgICAgIHdoaWxlIDE6CiAg
ICAgICAgICAgICNoPXJlYWRBdCgyNCxwb3MpICMgMjQ9aGVhZGVyX3NpemUKICAgICAgICAg
ICAgc2Vlayhwb3MpCiAgICAgICAgICAgIGg9cmVhZCgyNCkKICAgICAgICAgICAgI3Jwb3M9
cG9zKzI0CiAgICAgICAgICAgIGlmIGxlbihoKSAhPSAgMjQ6CiAgICAgICAgICAgICAgICBv
aWQ9MAogICAgICAgICAgICAgICAgYnJlYWsKICAgICAgICAgICAgb2lkLHByZXYsc3RhcnQs
dGxlbixwbGVuPXVucGFjaygiPmlpZGlpIixoKQogICAgICAgICAgICBwPXBvcwogICAgICAg
ICAgICBwb3M9cG9zK3RsZW4KICAgICAgICAgICAgaWYgbm90IG9pZDogY29udGludWUgICAg
ICAgICAgICAgICMgQ2FzZSBBLgogICAgICAgICAgICBpZiBzdGFydCA+PSBzdGFydF90aW1l
OiBicmVhawogICAgICAgICAgICBpZiBpbmRleFtvaWRdICE9IHA6IGNvbnRpbnVlICAgICMg
Q2FzZSBCLgogICAgICAgICAgICBpZiB1bnJlYWNoYWJsZShvaWQpOiBjb250aW51ZSAgICAg
IyBDYXNlIEMuCiAgICAgICAgICAgIHByZXY9MAogICAgICAgICAgICBuZXdpbmRleFtvaWRd
PW5ld3BvcwogICAgICAgICAgICAjd3JpdGUocGFjaygiPmlpZGlpIixvaWQscHJldixzdGFy
dCx0bGVuLHBsZW4pKQogICAgICAgICAgICAjd3JpdGUocmVhZEF0KHRsZW4tMjQscnBvcykp
CiAgICAgICAgICAgIHdyaXRlKHBhY2soIj5paWRpaSIsb2lkLHByZXYsc3RhcnQsdGxlbixw
bGVuKStyZWFkKHRsZW4tMjQpKQogICAgICAgICAgICBuZXdwb3M9bmV3cG9zK3RsZW4KICAg
IAogICAgICAgIHdoaWxlIDE6CiAgICAgICAgICAgIGlmIG9pZDoKICAgICAgICAgICAgICAg
IHRyeTogcHJldj1uZXdpbmRleFtvaWRdCiAgICAgICAgICAgICAgICBleGNlcHQ6IHByZXY9
MAogICAgICAgICAgICAgICAgbmV3aW5kZXhbb2lkXT1uZXdwb3MKICAgICAgICAgICAgICAg
ICN3cml0ZShwYWNrKCI+aWlkaWkiLG9pZCxwcmV2LHN0YXJ0LHRsZW4scGxlbikpCiAgICAg
ICAgICAgICAgICAjd3JpdGUocmVhZEF0KHBsZW4scnBvcykpCiAgICAgICAgICAgICAgICB3
cml0ZShwYWNrKCI+aWlkaWkiLG9pZCxwcmV2LHN0YXJ0LHRsZW4scGxlbikrcmVhZCh0bGVu
LTI0KSkKICAgICAgICAgICAgICAgIG5ld3Bvcz1uZXdwb3MrdGxlbgogICAgICAgICAgICAj
aD1yZWFkQXQoMjQscG9zKSAjIDI0PWhlYWRlcl9zaXplCiAgICAgICAgICAgICNycG9zPXBv
cysyNAogICAgICAgICAgICBzZWVrKHBvcykKICAgICAgICAgICAgaD1yZWFkKDI0KQogICAg
ICAgICAgICBpZiBsZW4oaCkgIT0gIDI0OgogICAgICAgICAgICAgICAgb2lkPTAKICAgICAg
ICAgICAgICAgIGJyZW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bnNhY3Rpb25zPVtdCgogICAgbGFzdF90aW1lPTAKICAg
ICAKICAgIG1sYXN0PScnCiAgICB3aGlsZSAxOgogICAgICAgIF9fdHJhY2ViYWNrX2luZm9f
XyA9IHBvcwogICAgICAgIHNlZWsocG9zKQogICAgICAgIGg9cmVhZCgyNCkKICAgICAgICBp
ZiBsZW4oaCkgIT0gMjQ6IGJyZWFrCiAgICAgICAgdGxlbixwbGVuPXVucGFjaygiPmlpIixo
WzE2OjI0XSkKICAgICAgICBuZXdwb3M9cG9zK3RsZW4KICAgICAgICBpZiBuZXdwb3MgPiBm
aWxlX3NpemU6IGJyZWFrICAjIE11c3QgYmUgYSBiYWQgcmVjb3JkCiAgICAgICAgaWYgaFs6
NF0hPSdcMFwwXDBcMCc6CiAgICAgICAgICAgIG1sZW49dGxlbi0yOAogICAgICAgICAgICBp
ZiBwbGVuID4gMDogbWxlbj1tbGVuLXBsZW4KICAgICAgICAgICAgX190cmFjZWJhY2tfaW5m
b19fID0gcG9zCiAgICAgICAgICAgIHNlZWsocG9zK3RsZW4tbWxlbi00KQogICAgICAgICAg
ICBtPXJlYWQobWxlbikKICAgICAgICAgICAgbG09ZmluZChtLCdcdCcpCiAgICAgICAgICAg
IGlmIGxtID4gMDogcG09bVs6bG1dCiAgICAgICAgICAgIGVsc2U6IHBtPW0KICAgICAgICAg
ICAgaWYgbToKICAgICAgICAgICAgICAgIGlmIHBtICE9IG1sYXN0OgogICAgICAgICAgICAg
ICAgICAgIHRyYW5zYWN0aW9ucy5hcHBlbmQoKG0scG9zLHRsZW4pKQogICAgICAgICAgICAg
ICAgICAgIG1sYXN0PXBtCiAgICAgICAgICAgICAgICBlbHNlOgogICAgICAgICAgICAgICAg
ICAgIHQ9dHJhbnNhY3Rpb25zWy0xXQogICAgICAgICAgICAgICAgICAgIHRyYW5zYWN0aW9u
c1stMV09KHRbMF0sdFsxXSx0WzJdK3RsZW4pCiAgICAgICAgcG9zPW5ld3BvcwoKICAgIHJl
dHVybiB0cm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HRpbWUuCiAgICAiIiIgCgogICAgaWYgdHlwZShmaWxlKT09dHlwZSgn
Jyk6IGZpbGU9b3BlbihmaWxlLCdyYicpCiAgICBwb3M9bGVuKE11bHRpcGxlUmV2aXNpb24u
cGFja2VkX3ZlcnNpb24pCiAgICBzZWVrPWZpbGUuc2VlawogICAgcmVhZD1maWxlLnJlYWQK
ICAgIGN0aW1lPXRpbWUuY3RpbWUKICAgIHVucGFjaz1zdHJ1Y3QudW5wYWNrCiAgICB0dD10
eXBlKCgpKQogICAgIAogICAgd2hpbGUgMToKICAgICAgICBfX3RyYWNlYmFja19pbmZvX18g
PSBwb3MKICAgICAgICBzZWVrKHBvcykKICAgICAgICBoPXJlYWQoMjQpICMgMjQ9aGVhZGVy
X3NpemUKICAgICAgICBpZiBsZW4oaCkgIT0gIDI0OiBicmVhawogICAgICAgIG9pZCxwcmV2
LHN0YXJ0LHRsZW4scGxlbj11bnBhY2soIj5paWRpaSIsaCkKICAgICAgICBwcmludCAoIiVz
Olx0JXNcdCVzXHQlc1x0JXNcdCVzXHQiCiAgICAgICAgICAgICAgICUgKHBvcyxvaWQscHJl
dixjdGltZShzdGFydCksdGxlbixwbGVuKSksCiAgICAgICAgaWYgb2lkID4gMCBhbmQgcGxl
biA+IDA6CiAgICAgICAgICAgIHA9cmVhZChwbGVuKQogICAgICAgICAgICBwPVVucGlja2xl
cihTdHJpbmdJTyhwKSkKICAgICAgICAgICAgdHJ5OiBwPXAubG9hZCgpCiAgICAgICAgICAg
IGV4Y2VwdDogcD1Ob25lCiAgICAgICAgICAgIGlmIHR5cGUocCkgaXMgdHQ6IHA9cFswXS5f
X25hbWVfXwogICAgICAgICAgICBlbHNlOgogICAgICAgICAgICAgICAgdHJ5OiBwPXAuX19j
bGFzc19fLl9fbmFtZV9fCiAgICAgICAgICAgICAgICBleGNlcHQ6IHA9dHlwZShwKS5fX25h
bWVfXwogICAgICAgIGVsc2U6IHA9JycKICAgICAgICBtbGVuPXRsZW4tMjgKICAgICAg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