def test_mkdir_p_raise_exception(self): tmp_foo_bar_rules = os.path.join(self.temp_dir, 'foo', 'bar', 'rules') mkdir_p(tmp_foo_bar_rules) tmp_file = os.path.join(tmp_foo_bar_rules, 'file') f = open(tmp_file, 'w') f.close() mkdir_p(tmp_file)
def test_mkdir_p(self): tmp_foo = os.path.join(self.temp_dir, 'foo') tmp_foo_bar = os.path.join(self.temp_dir, 'foo', 'bar') tmp_foo_bar_rules = os.path.join(self.temp_dir, 'foo', 'bar', 'rules') mkdir_p(tmp_foo_bar_rules) ok_(os.path.exists(tmp_foo)) ok_(os.path.exists(tmp_foo_bar)) ok_(os.path.exists(tmp_foo_bar_rules))
def backup(args): if args.repos: provider = get_provider_from_config(args.config) today = datetime.datetime.now().date() abs_date_dir = get_abs_date_dir(args.archive_dir, today) mkdir_p(args.staging_dir) mkdir_p(args.archive_dir) mkdir_p(abs_date_dir) repo_objs = get_repo_objs_from_provider(provider, args.repos) if repo_objs: for repo in repo_objs: repo_dir_to_create = os.path.join(args.staging_dir, repo.name) bundle_dir_to_create = os.path.join(abs_date_dir, repo.name) mkdir_p(repo_dir_to_create) mkdir_p(bundle_dir_to_create) bundle_file_to_create = os.path.join( bundle_dir_to_create, "{}.bundle".format(repo.name)) subprocess.check_call( ["git", "clone", "--no-hardlinks", "--mirror", repo.clone_url, repo_dir_to_create]) os.chdir(repo_dir_to_create) subprocess.check_call( ["git", "bundle", "create", bundle_file_to_create, "--all"]) create_tarball([bundle_dir_to_create], repo.name, abs_date_dir) # cleanup rm_rf(bundle_dir_to_create) else: logging.error("Please provide repos to backup.")
def backup(args): if args.repos: provider = get_provider_from_config(args.config) today = datetime.datetime.now().date() abs_date_dir = get_abs_date_dir(args.archive_dir, today) mkdir_p(args.staging_dir) mkdir_p(args.archive_dir) mkdir_p(abs_date_dir) repo_objs = get_repo_objs_from_provider(provider, args.repos) if repo_objs: for repo in repo_objs: repo_dir_to_create = os.path.join(args.staging_dir, repo.name) bundle_dir_to_create = os.path.join(abs_date_dir, repo.name) mkdir_p(repo_dir_to_create) mkdir_p(bundle_dir_to_create) bundle_file_to_create = os.path.join( bundle_dir_to_create, "{}.bundle".format(repo.name)) subprocess.check_call([ "git", "clone", "--no-hardlinks", "--mirror", repo.clone_url, repo_dir_to_create ]) os.chdir(repo_dir_to_create) subprocess.check_call([ "git", "bundle", "create", bundle_file_to_create, "--all" ]) create_tarball([bundle_dir_to_create], repo.name, abs_date_dir) # cleanup rm_rf(bundle_dir_to_create) else: logging.error("Please provide repos to backup.")
def test_mkdir_p_should_not_raise_exception(self): tmp_foo_bar_rules = os.path.join(self.temp_dir, 'foo', 'bar', 'rules') mkdir_p(tmp_foo_bar_rules) mkdir_p(tmp_foo_bar_rules)