本文整理汇总了Python中classes.Registry.Registry.set方法的典型用法代码示例。如果您正苦于以下问题:Python Registry.set方法的具体用法?Python Registry.set怎么用?Python Registry.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类classes.Registry.Registry
的用法示例。
在下文中一共展示了Registry.set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from classes.Registry import Registry [as 别名]
# 或者: from classes.Registry.Registry import set [as 别名]
def __init__(self):
config = configparser.ConfigParser()
config.read(os.getcwd() + '/' + 'config.ini')
try:
db = mysql.connector.connect(
host=config['db']['host'],
user=config['db']['user'],
password=config['db']['pass'],
database=config['db']['database']
)
db.autocommit = True
except mysql.connector.errors.ProgrammingError as e:
print " ERROR: Can`t connect to MySQL server! ({0})".format(str(e))
exit(0)
try:
mc = MongoClient(host=config['mongo']['host'], port=int(config['mongo']['port']))
mongo_collection = getattr(mc, config['mongo']['collection'])
except pymongo.errors.ConnectionFailure as e:
print " ERROR: Can`t connect to MongoDB server! ({0})".format(str(e))
exit(0)
R = Registry()
R.set('config', config)
R.set('db', db)
R.set('mongo', mongo_collection)
R.set('wr_path', os.getcwd())
R.set('data_path', os.getcwd() + '/data/')
R.set('http', Http())
R.set('proxies', Proxies())
R.set(
'ndb',
Database(config['db']['host'], config['db']['user'], config['db']['pass'], config['db']['database'])
)
R.set(
'fuzzer_evil_value',
file_get_contents(Registry().get('wr_path') + "/bases/fuzzer-evil-value.txt").strip()
)
R.set('proxy_many_died', False)
R.set('positive_limit_stop', False)
if " ".join(sys.argv).count('selenium') and int(config['selenium']['virtual_display']):
display = Display(visible=0, size=(800, 600))
display.start()
R.set('display', display)
示例2: setup_class
# 需要导入模块: from classes.Registry import Registry [as 别名]
# 或者: from classes.Registry.Registry import set [as 别名]
def setup_class(self):
config = configparser.ConfigParser()
config.read('config.ini')
try:
db = mysql.connector.connect(
host=config['db']['host'],
user=config['db']['user'],
password=config['db']['pass'],
database=config['db']['database']
)
db.autocommit = True
except mysql.connector.errors.ProgrammingError as e:
print " ERROR: Can`t connect to MySQL server! ({0})".format(str(e))
exit(0)
try:
mc = MongoClient(host=config['mongo']['host'], port=int(config['mongo']['port']))
mongo_collection = getattr(mc, config['mongo']['collection'])
except pymongo.errors.ConnectionFailure as e:
print " ERROR: Can`t connect to MongoDB server! ({0})".format(str(e))
exit(0)
R = Registry()
R.set('config', config)
R.set('db', db)
R.set('mongo', mongo_collection)
R.set('wr_path', wrpath)
R.set('data_path', wrpath + '/data/')
R.set('ndb',
Database(config['db']['host'], config['db']['user'], config['db']['pass'], config['db']['database']))
R.set('proxies', Proxies())
self.db = R.get('ndb')