def __init__(self): self.config_file_path = get_config_path("main.conf") self.config = { "username": "******", "hostname": platform.node().split(".")[0], } try: self.config.update(json.loads(open(self.config_file_path).read())) except Exception as e: log.error("Error loading default config: %s" % str(e)) self.mn = MetaNet(self) self.repos = {} for filename in glob(get_config_path("*.state")): log.info("Loading state file: %s" % filename) repo = Repo(filename, config=self.config) self.repos[repo.uuid] = repo
def test_not_exist(self, mkdir): self.assertEqual( util.get_config_path("waffles-do-not-exist/waffle3.dat"), "/home/shish/.config/chunker/waffles-do-not-exist/waffle3.dat" ) self.assertEqual(mkdir.call_count, 1)
def test(self, mkdir): self.assertEqual( util.get_config_path("main.json"), "/home/shish/.config/chunker/main.json" )
def remove_state(self): p = get_config_path(self.uuid + ".state") if os.path.exists(p): os.unlink(p)
def save_state(self): """ Save the repository state to the default state location (eg ~/.config/chunker/<uuid>.state on unix) """ self.save(get_config_path(self.uuid + ".state"), state=True, compress=True)