def test_save_parse_apprc_escaping(self): expected = { "A": "B", "C": "C D", "b": "888", "B": "9\"1", "D": "X=y", "F": "a(a) + (", "MY_awesome_BIG_name": "some'thin'g'", "JSON": '[{"a": "b", "c": {"d": "f"}}]', "SLASHED": "a\\a escaped \\\" some \\\"", "EXEC": "a: `echo hey` b: $(echo again)", "MULTILINE": "my\nmulti\"line\", with ' quotes ' yay'\nvariable'\n'", } path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures", "written_apprc") try: save_apprc_file(expected, file_path=path) envs = parse_apprc_file(path) for k, v in envs.items(): if k not in expected: envs.pop(k) self.assertEqual(envs, expected) finally: os.remove(path)
def run_action(args): client = Client(args.url, args.token) envs = None try: envs = client.register_unit(args.app_name) tasks.save_apprc_file(envs) except ConnectionError: envs = tasks.parse_apprc_file() yaml_data = tasks.load_app_yaml() tasks.write_circus_conf(envs=envs) tasks.run_restart_hooks('before', yaml_data, envs=envs) tasks.execute_start_script(args.start_cmd, envs=envs, with_shell=False) tasks.run_restart_hooks('after', yaml_data, envs=envs)
def run_action(args): client = Client(args.url, args.token) envs = None try: envs, supported_tsuru = client.register_unit(args.app_name) save_apprc_file(envs, supported_tsuru) except ConnectionError: envs = tasks.parse_apprc_file() yaml_data = tasks.load_app_yaml() tasks.write_circus_conf(envs=envs) tasks.run_restart_hooks('before', yaml_data, envs=envs) tasks.execute_start_script(args.start_cmd, envs=envs, with_shell=False) tasks.run_restart_hooks('after', yaml_data, envs=envs) remove_temp_env_file()
def test_parse_apprc_file(self): path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures", "apprc") envs = parse_apprc_file(path) expected = { "A": "B", "C": "C D", "b": "888", "B": "9\"1", "D": "X=y", "F": "a(a", "MY_awesome_BIG_name": "something", } for k, v in envs.items(): if k not in expected: envs.pop(k) self.assertEqual(envs, expected)