MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / siteCreate

Method siteCreate

src/main.py:146–177  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

144 # Site commands
145
146 def siteCreate(self):
147 logging.info("Generating new privatekey...")
148 from Crypt import CryptBitcoin
149 privatekey = CryptBitcoin.newPrivatekey()
150 logging.info("----------------------------------------------------------------------")
151 logging.info("Site private key: %s" % privatekey)
152 logging.info(" !!! ^ Save it now, required to modify the site ^ !!!")
153 address = CryptBitcoin.privatekeyToAddress(privatekey)
154 logging.info("Site address: %s" % address)
155 logging.info("----------------------------------------------------------------------")
156
157 while True and not config.batch:
158 if input("? Have you secured your private key? (yes, no) > ").lower() == "yes":
159 break
160 else:
161 logging.info("Please, secure it now, you going to need it to modify your site!")
162
163 logging.info("Creating directory structure...")
164 from Site.Site import Site
165 from Site import SiteManager
166 SiteManager.site_manager.load()
167
168 os.mkdir("%s/%s" % (config.data_dir, address))
169 open("%s/%s/index.html" % (config.data_dir, address), "w").write("Hello %s!" % address)
170
171 logging.info("Creating content.json...")
172 site = Site(address)
173 site.content_manager.sign(privatekey=privatekey, extend={"postmessage_nonce_security": True})
174 site.settings["own"] = True
175 site.saveSettings()
176
177 logging.info("Site created!")
178
179 def siteSign(self, address, privatekey=None, inner_path="content.json", publish=False, remove_missing_optional=False):
180 from Site.Site import Site

Callers

nothing calls this directly

Calls 5

saveSettingsMethod · 0.95
SiteClass · 0.90
loadMethod · 0.45
writeMethod · 0.45
signMethod · 0.45

Tested by

no test coverage detected