def __init__(self, config=None): if config is None: config = get_config_from_file("config.ini") self.config = config # Seed the trust stores Sync(self.config).seed() self.cert_processor = CertProcessor(config)
def __call__(self, parser, *args, **kwargs): """Lists are configured supernova environments.""" config = utils.get_config_from_file() for section in config.sections(): envheader = '-- %s ' % section print envheader.ljust(86, '-') for param, value in sorted(config.items(section)): print ' %s: %s' % (param.upper().ljust(21), value) parser.exit()
def main(): argument_parser = argparse.ArgumentParser("IRC Chat Server") argument_parser.add_argument( "-configuration", help="Configuration File Path", type=str, default=os.getcwd() + "/conf/chatserver.conf" ) argument_parser.add_argument( "-port", help="Port for the IRC Chat Server", type=str, required=True ) argument_parser.add_argument( "-db", help="Path for folder containing txt files", type=str, default=None ) arguments = argument_parser.parse_args() config_object = utils.get_config_from_file(getattr(arguments, "configuration")) # Get the Port and DB Path setting from either the ArgumentParser instance - if it doesn't # exist there, default to config object def get_from_args_or_config(arguments, config_object, key): value = getattr(arguments, key) if value is None: if key == "db": key = "dbpath" value = config_object.get(key) return value try: port = int(get_from_args_or_config(arguments, config_object, "port")) except ValueError: port = None if port is None: print("Port is not provided as an argument or config, or is invalid") return db_path = get_from_args_or_config(arguments, config_object, "db") if db_path is None or not os.path.exists(db_path): print("DB path is not provided as an argument or config, or doesn't exist") return global start_server start_server = start_server_closure(Server( port=port, db=DB(db_path=db_path) )) start_server()
def main(): def m(t): return { "offline": OfflineNavigator, "dete": DETE, "dete_circle": DeteCircle, "dete_circle_binary": DeteCircleBinary, }.get(t) parser = argparse.ArgumentParser() parser.add_argument("--config_path", "-c", default="./configs/config.json") args = parser.parse_args() config_path = args.config_path conf = get_config_from_file(config_path) rn = m(conf["type"])(conf) rn.explore()
def __init__(self, config=None): if config is None: config = get_config_from_file("config.ini") self.config = config user_gnupg_path = config.get("gnupg", "user") admin_gnupg_path = config.get("gnupg", "admin") if not os.path.isabs(user_gnupg_path): user_gnupg_path = os.path.abspath( os.path.join(os.path.dirname(__file__), user_gnupg_path)) if not os.path.isabs(admin_gnupg_path): admin_gnupg_path = os.path.abspath( os.path.join(os.path.dirname(__file__), admin_gnupg_path)) create_dir_if_missing(user_gnupg_path) create_dir_if_missing(admin_gnupg_path) self.user_gpg = gnupg.GPG(gnupghome=user_gnupg_path) self.admin_gpg = gnupg.GPG(gnupghome=admin_gnupg_path) self.user_gpg.encoding = "utf-8" self.admin_gpg.encoding = "utf-8"
required=True) argument_parser.add_argument( "-p", help="Port of the IRC Chat Server which the client should connect to", type=int) argument_parser.add_argument("-c", help="Path of the Configuration file", type=str, required=True) argument_parser.add_argument("-t", help="Test File", type=str) argument_parser.add_argument("-L", help="Log file name, for log messages", type=str) arguments = argument_parser.parse_args() config_object = utils.get_config_from_file(getattr(arguments, "c")) hostname_setting = getattr(arguments, "hostname") if hostname_setting is None: hostname_setting = config_object.get("last_server_used") if hostname_setting is None: raise RuntimeError( "No host setting from parameters or config file") username_setting = getattr(arguments, "u") port_setting = getattr(arguments, "p") if port_setting is None: port_setting = int(config_object.get("port")) if port_setting is None: raise RuntimeError(
import sys from src.leetcode import Leetcode from utils import get_config_from_file, CONFIG_FILE def run(leetcode): quizs = [int(i) for i in sys.argv[1:]] print(quizs) print('download problems id is: {list}'.format(list=quizs)) leetcode.run(quizs) if __name__ == '__main__': CONFIG = get_config_from_file(CONFIG_FILE) leetcode = Leetcode(CONFIG) run(leetcode)
tmp_list = list() for num in range(points_num_per_round[i]): theta = num * delta_theta tmp_list.append( Point( center_point[0] + tmp_radius * math.cos(theta), center_point[1] + tmp_radius * math.sin(theta), center_point[2], )) points_per_round.append(tmp_list) return points_per_round if __name__ == "__main__": from utils import get_config_from_file print("start test".center(100, "*")) dete = DeteCircleBinary( get_config_from_file("../configs/dete_circle_binary_extra.json")) dete.explore() # print("test of change h".center(100, "*")) # l = [Point(1,1,1), Point(0,0,0)] # center = Point(0,0,0) # def change_h(p_list, point): # list.sort(p_list, key=lambda p: (p.x - point.x) ** 2 + (p.y - point.y) ** 2) # for p in p_list: # p.h = -1 # change_h(l, center) # for p in l: # print(p.h)
@app.route("/ca", methods=["GET"]) def get_ca_cert(): cert = handler.cert_processor.get_ca_cert() cert = cert.public_bytes(serialization.Encoding.PEM).decode("UTF-8") return ( json.dumps({"issuer": handler.config.get("ca", "issuer"), "cert": cert}), 200, ) @app.route("/crl", methods=["GET"]) def get_crl(): crl = handler.cert_processor.get_crl() return crl.public_bytes(serialization.Encoding.PEM).decode("UTF-8") @app.route("/version", methods=["GET"]) def get_version(): return json.dumps({"version": version}), 200 return app if __name__ == "__main__": config_path = os.getenv("CONFIG_PATH", None) if config_path: config = get_config_from_file(config_path) else: config = get_config_from_file("config.ini") app = create_app(config) app.run(port=config.get("mtls", "port", fallback=4000))
else: camera_pos = add(p, [0, 0, -2 * d]) camera = vector_to_yaw_and_pitch( angular_bisector(camera_pos, p1, p2, p3)) camera.update({"position": camera_pos}) return camera @staticmethod def show_explore_path(root): center = root triangles = root.dfs() all_points = [center.pc, center.childs[0].p2] for triangle in triangles: if triangle.parent.is_root: all_points.extend([triangle.p3, triangle.pc]) else: all_points.extend([triangle.pc]) x = [p.x for p in all_points] y = [p.y for p in all_points] l = plt.plot(x, y, "ro") l = plt.plot(x, y) plt.setp(l, markersize=1) plt.savefig("./path.png") if __name__ == "__main__": from utils import get_config_from_file dete = DETE(get_config_from_file("../configs/config.json")) dete.explore()
def __init__(self, config=None): if config is None: config = get_config_from_file("config.ini") self.config = config self.cert_processor = CertProcessor(config) self.seed()
return Triangle(center, p1, p2) @staticmethod def show_explore_path(points_per_round): all_points = list() for points_list in points_per_round: all_points.extend(points_list) x = [p.x for p in all_points] y = [p.y for p in all_points] l = plt.plot(x, y) plt.setp(l, markersize=1) plt.savefig("./dete_circle_path.png") if __name__ == "__main__": from utils import get_config_from_file print("start test".center(100, "*")) dete = DeteCircle(get_config_from_file("../configs/dete_circle.json")) dete.explore() # print("test of change h".center(100, "*")) # l = [Point(1,1,1), Point(0,0,0)] # center = Point(0,0,0) # def change_h(p_list, point): # list.sort(p_list, key=lambda p: (p.x - point.x) ** 2 + (p.y - point.y) ** 2) # for p in p_list: # p.h = -1 # change_h(l, center) # for p in l: # print(p.h)
ROUND_NUM = self._config.get("round_num", 1) START_PITCH = self._config.get("start_pitch", -45) END_PITCH = self._config.get("end_pitch", 45) delta_theta = 2 * math.pi / (TOTAL_NUM / ROUND_NUM) delta_height = height / (TOTAL_NUM - 1) delta_pitch = (END_PITCH - START_PITCH) / TOTAL_NUM for i in range(TOTAL_NUM): theta = delta_theta * i x = x0 + radius * math.sin(theta) y = y0 + radius * math.cos(theta) z = bottom + i * delta_height pitch = START_PITCH + i * delta_pitch views.append({ "position": Vector3r(x, y, z), "yaw": -1 * (0.5 * math.pi + theta), "pitch": pitch / 180 * math.pi, }) else: print("OfflineNavigator: unknown type of safety_surface (%s)" % self._safety_surface["type"]) return views if __name__ == "__main__": from utils import get_config_from_file config = get_config_from_file("./configs/config.json") rn = OfflineNavigator(config) rn.explore()