本文整理汇总了Python中Site.Site.saveSettings方法的典型用法代码示例。如果您正苦于以下问题:Python Site.saveSettings方法的具体用法?Python Site.saveSettings怎么用?Python Site.saveSettings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Site.Site
的用法示例。
在下文中一共展示了Site.saveSettings方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: siteCreate
# 需要导入模块: from Site import Site [as 别名]
# 或者: from Site.Site import saveSettings [as 别名]
def siteCreate(self):
logging.info("Generating new privatekey...")
from Crypt import CryptBitcoin
privatekey = CryptBitcoin.newPrivatekey()
logging.info("----------------------------------------------------------------------")
logging.info("Site private key: %s" % privatekey)
logging.info(" !!! ^ Save it now, required to modify the site ^ !!!")
address = CryptBitcoin.privatekeyToAddress(privatekey)
logging.info("Site address: %s" % address)
logging.info("----------------------------------------------------------------------")
while True and not config.batch:
if raw_input("? Have you secured your private key? (yes, no) > ").lower() == "yes":
break
else:
logging.info("Please, secure it now, you going to need it to modify your site!")
logging.info("Creating directory structure...")
from Site import Site
from Site import SiteManager
SiteManager.site_manager.load()
os.mkdir("%s/%s" % (config.data_dir, address))
open("%s/%s/index.html" % (config.data_dir, address), "w").write("Hello %s!" % address)
logging.info("Creating content.json...")
site = Site(address)
site.content_manager.sign(privatekey=privatekey, extend={"postmessage_nonce_security": True})
site.settings["own"] = True
site.saveSettings()
logging.info("Site created!")
示例2: siteCreate
# 需要导入模块: from Site import Site [as 别名]
# 或者: from Site.Site import saveSettings [as 别名]
def siteCreate():
logging.info("Generating new privatekey...")
from Crypt import CryptBitcoin
privatekey = CryptBitcoin.newPrivatekey()
logging.info("----------------------------------------------------------------------")
logging.info("Site private key: %s" % privatekey)
logging.info(" !!! ^ Save it now, required to modify the site ^ !!!")
address = CryptBitcoin.privatekeyToAddress(privatekey)
logging.info("Site address: %s" % address)
logging.info("----------------------------------------------------------------------")
while True:
if raw_input("? Have you secured your private key? (yes, no) > ").lower() == "yes": break
else: logging.info("Please, secure it now, you going to need it to modify your site!")
logging.info("Creating directory structure...")
from Site import Site
os.mkdir("data/%s" % address)
open("data/%s/index.html" % address, "w").write("Hello %s!" % address)
logging.info("Creating content.json...")
site = Site(address)
site.content_manager.sign(privatekey=privatekey)
site.settings["own"] = True
site.saveSettings()
logging.info("Site created!")
示例3: need
# 需要导入模块: from Site import Site [as 别名]
# 或者: from Site.Site import saveSettings [as 别名]
def need(self, address, all_file=True):
from Site import Site
new = False
site = self.get(address)
if not site: # Site not exist yet
if not self.isAddress(address): return False # Not address: %s % address
logging.debug("Added new site: %s" % address)
site = Site(address)
self.sites[address] = site
if not site.settings["serving"]: # Maybe it was deleted before
site.settings["serving"] = True
site.saveSettings()
new = True
if all_file: site.download()
return site
示例4: need
# 需要导入模块: from Site import Site [as 别名]
# 或者: from Site.Site import saveSettings [as 别名]
def need(self, address, all_file=True, settings=None):
from Site import Site
site = self.get(address)
if not site: # Site not exist yet
# Try to find site with differect case
for recover_address, recover_site in self.sites.items():
if recover_address.lower() == address.lower():
return recover_site
if not self.isAddress(address):
return False # Not address: %s % address
self.log.debug("Added new site: %s" % address)
site = Site(address, settings=settings)
self.sites[address] = site
if not site.settings["serving"]: # Maybe it was deleted before
site.settings["serving"] = True
site.saveSettings()
if all_file: # Also download user files on first sync
site.download(check_size=True, blind_includes=True)
return site
示例5: Phantom_Ui
# 需要导入模块: from Site import Site [as 别名]
# 或者: from Site.Site import saveSettings [as 别名]
class Phantom_Ui(object):
def __init__(self):
self.error_msg = Error_Msg.Error_Msg()
self.run_method = Run_Method.Run_Method()
def create_phantom_site(self):
from Config import config
from Crypt import CryptBitcoin
from Site import Site
import os
config.parse(silent=True)
if not config.arguments:
config.parse()
self.private_key = CryptBitcoin.newPrivatekey()
self.address = CryptBitcoin.privatekeyToAddress(self.private_key)
try:
os.mkdir("%s/%s" % (config.data_dir, self.address))
open("%s/%s/index.html" % (config.data_dir, self.address), "w").write("Hello %s!" % self.address)
except Exception as e:
return self.error_msg.error_response("err_create_sitedir")
try:
self.site = Site(self.address)
self.site.content_manager.sign(privatekey=self.private_key, extend={"postmessage_nonce_security": True})
self.site.settings["own"] = True
self.site.saveSettings()
except Exception as e:
print e
return self.error_msg.error_response("err_create_site")
return {"jsonrpc": "2.0", "id": "1", "result": ["true", str(self.address), str(self.private_key)]}
def validate_postdata(self,postdata):
try:
"""
Convert the HTTP body json string into a dictionary. A non valid json string will return false.
"""
postparams = json.loads(postdata)
except Exception as e:
print e
return self.error_msg.error_response("invalid_json_req")
if 'jsonrpc' in postparams and not postparams['jsonrpc'] == '2.0':
return self.error_msg.error_response("invalid_json_ver")
if 'method' in postparams and len(postparams['method']) == 0:
return self.error_msg.error_response("no_method")
if not 'params' in postparams:
return self.error_msg.error_response("missing_params")
return postparams
def run_method(self,postparams):
self.res = self.run_method.execute(postparams)
return self.res
def get_shiftbase(self,postparams):
if len(postparams['params']) == 0:
try:
self.client = IPC_Client.Client()
self.res = self.client.get_shiftbase()
return self.res
except Exception as e:
return self.error_msg.error_response("ipc_call_error")
return self.error_msg.error_response("no_params_allowed")
def get_peercount(self,postparams):
if len(postparams['params']) == 0:
try:
self.client = IPC_Client.Client()
self.res = self.client.get_peercount()
if 'result' in self.res:
self.res['result'] = str(int(self.res['result'], 16))
return self.res
except Exception as e:
return self.error_msg.error_response("ipc_call_error")
return self.error_msg.error_response("no_params_allowed")
def get_blocknumber(self,postparams):
if len(postparams['params']) == 0:
try:
self.client = IPC_Client.Client()
self.res = self.client.get_blocknumber()
if 'result' in self.res:
self.res['result'] = str(int(self.res['result'], 16))
return self.res
except Exception as e:
#.........这里部分代码省略.........
示例6: Phantom_Ui
# 需要导入模块: from Site import Site [as 别名]
# 或者: from Site.Site import saveSettings [as 别名]
class Phantom_Ui(object):
def __init__(self):
self.error_msg = Error_Msg.Error_Msg()
self.run_method = Run_Method.Run_Method()
def create_phantom_site(self):
from Config import config
from Crypt import CryptBitcoin
from Site import Site
import os
self.config.parse(silent=True)
if not self.config.arguments:
self.config.parse()
self.privatekey = CryptBitcoin.newPrivatekey()
address = CryptBitcoin.privatekeyToAddress(self.privatekey)
try:
os.mkdir("%s/%s" % (self.config.data_dir, address))
open("%s/%s/index.html" % (self.config.data_dir, address), "w").write("Hello %s!" % address)
except Exception as e:
return self.error_msg.error_response("err_create_sitedir")
try:
self.site = Site(address)
self.site.content_manager.sign(privatekey=self.privatekey, extend={"postmessage_nonce_security": True})
self.site.settings["own"] = True
self.site.saveSettings()
except Exception as e:
return self.error_msg.error_response("err_create_site")
return {"jsonrpc": "2.0", "id": "1", "result": ["true", str(address), str(privatekey)]}
def validate_postdata(self,postdata):
try:
"""
Convert the HTTP body json string into a dictionary. A non valid json string will return false.
"""
postparams = json.loads(postdata)
except Exception as e:
return self.error_msg.error_response("invalid_json_req")
if 'jsonrpc' in postparams and not postparams['jsonrpc'] == '2.0':
return self.error_msg.error_response("invalid_json_ver")
if 'method' in postparams and len(postparams['method']) == 0:
return self.error_msg.error_response("no_method")
if not 'params' in postparams:
return self.error_msg.error_response("missing_params")
return postparams
def run_method(self,postparams):
self.res = self.run_method.execute(postparams)
return self.res
def get_shiftbase(self,postparams):
if len(postparams['params']) == 0:
try:
self.client = IPC_Client.Client()
self.res = self.client.get_shiftbase()
return self.res
except Exception as e:
return self.error_msg.error_response("ipc_call_error")
return self.error_msg.error_response("no_params_allowed")
def get_peercount(self,postparams):
if len(postparams['params']) == 0:
try:
self.client = IPC_Client.Client()
self.res = self.client.get_peercount()
if 'result' in self.res:
self.res['result'] = str(int(self.res['result'], 16))
return self.res
except Exception as e:
return self.error_msg.error_response("ipc_call_error")
return self.error_msg.error_response("no_params_allowed")
def get_blocknumber(self,postparams):
if len(postparams['params']) == 0:
try:
self.client = IPC_Client.Client()
self.res = self.client.get_blocknumber()
if 'result' in self.res:
#.........这里部分代码省略.........