def getSetConfig(question, section, option, reader=getWithDefault): value = CONFIG.get(section, option) if CONFIG.isTrue("global", "accept_defaults"): putMessage(question + " : using <" + value + ">") return value new_value = reader(question, value) CONFIG.set(section, option, new_value) return new_value
def test_run1(): """ Test tradebot on a really easy to identify short trade on a tight time interval """ CONFIG.set('trade_bot', 'period_range', '1500') tb = TradeBot( pair='AUD_USD', timeframe='D', start='2018-01-22 22:00:00', end='2018-02-06 22:00:00') tl = tb.run() assert len(tl.tlist) == 2
def postConfigure(self): self.setSecuredURL() self.cset("db_jndi", "ETADB") url = self.cget("url") # configure database connection for callbacks murl = "jdbc:mysql://" + CONFIG.get("db", "host") + ":" + CONFIG.get("db", "port") + "/" + self.cget("db_name") + "?autoReconnect=true" self.cset("callback_db_url", murl) epcis_url = CONFIG.get("epcis", "url") if not epcis_url.endswith("/"): epcis_url += "/" CONFIG.set("epcis", "query_url", epcis_url + "query") CONFIG.set("epcis", "capture_url", epcis_url + "capture") CONFIG.set("epcilon", "subscription_url", url + "ided_query") CONFIG.set("epcilon", "iota_ided", "True")
def postConfigure(self): # set default urls (for DSeTa) url = self.setSecuredURL() CONFIG.set("ds_policies", "xacml_url", url + "xi") # set policies directories (for DSeTa) policies_dir = CONFIG.get("ds_policies", "dir") admin_dir = (policies_dir + "/admin/").replace("//", "/") capture_dir = (policies_dir + "/capture/").replace("//", "/") query_dir = (policies_dir + "/query/").replace("//", "/") CONFIG.set("ds_policies", "admin_dir", admin_dir) CONFIG.set("ds_policies", "capture_dir", capture_dir) CONFIG.set("ds_policies", "query_dir",query_dir) if (self.cisTrue("deploy_policies")): utils.putWait("Initializing policies in " + policies_dir) utils.sh_mkdir_p(policies_dir) if utils.sh_exec("tar -C " + policies_dir + " --strip-components=1 -xaf resources/ds_policies.tar"): utils.putDoneOK() else: utils.putDoneFail()
def submit(self): CONFIG.set('server', 'key_path', self.key_path.get()) CONFIG.set('server', 'server_dns', self.server_dns.get()) save_config()
def world_config(self): server_dns = CONFIG.get('server', 'server_dns') world_name = self.inp_world_name.input.get() CONFIG.set('world', 'world_name', world_name) save_config() return server_dns, world_name
def cset(self, option_name, value): CONFIG.set(self.section_name, option_name, value) return value
# coding: utf-8 import unittest import difflib import json from os.path import join import sqlalchemy from sqlalchemy_utils import (database_exists, create_database, drop_database) from config import CONFIG CONFIG.set('common', 'is_testing', 'True') CONFIG.set('database', 'conn_string', CONFIG.get('database', 'test_conn_string')) from amarak.connections.alchemy.tables import Base from amarak.connections.alchemy import AlchemyConnection from amarak.connections.rest import RestConnection from protocols.rest import * class TestRestConnection(RestConnection): def __init__(self, client): super(TestRestConnection, self).__init__(self) self.url = '/' self.client = client def _loads_or_show(self, url, data, response): try: return json.loads(response) except ValueError: raise ValueError([url, data, response])
def postConfigure(self): url = self.setURL() qurl = self.cset("query_url", url + "query") self.cset("capture_url", url + "capture") self.cset("db_jndi", "EPCISDB") CONFIG.set("epcilon", "subscription_url", qurl)
def postConfigure(self): self.setSecuredURL() self.cset("db_jndi", "DSETADB") CONFIG.set("epcilon", "ds_url", self.cget("url")) CONFIG.set("epcilon", "iota_ided", "True")