def f6(): opt = libdar.archive_options_read() passwd ="*****@*****.**" secu_pass = libdar.secu_string(passwd, len(passwd)) entrepot = libdar.entrepot_libcurl(ui, libdar.mycurl_protocol.proto_ftp, "anonymous", secu_pass, "ftp.dm3c.org", "", False, "", "", "", 5) print(entrepot.get_url()) opt.set_entrepot(entrepot) opt.set_info_details(True) arch2 = libdar.archive(ui, libdar.path("/dar.linux.free.fr/"), "exemple", "dar", opt) opt2 = libdar.archive_options_test() opt2.set_display_treated(True, False) arch2.op_test(opt2)
def f4(): opt = libdar.archive_options_read() arch1 = libdar.archive(ui, sauv_path, arch_name, ext, opt); opt = libdar.archive_options_test() # defining which file to test bases on filename (set_selection) mask_file1 = libdar.simple_mask("*.*", True) mask_file2 = libdar.regular_mask(".*\.pub$", True) mask_filenames = libdar.ou_mask() # doing the logical OR between what we will add to it: mask_filenames.add_mask(mask_file1) mask_filenames.add_mask(mask_file2) opt.set_selection(mask_filenames) # reducing the testing in subdirectories tree1 = libdar.simple_path_mask("/etc/ssh", False) tree2 = libdar.simple_path_mask("/etc/grub.d", False) tree = libdar.et_mask() # doing the loical AND betwen what we will add to it: tree.add_mask(libdar.not_mask(tree1)) tree.add_mask(libdar.not_mask(tree2)) opt.set_subtree(tree) opt.set_info_details(True) opt.set_display_skipped(True) arch1.op_test(opt)
def f3(): opt = libdar.archive_options_read() opt.set_info_details(True) arch1 = libdar.archive(ui, sauv_path, arch_name, ext, opt) list_dir(arch1) stats = arch1.get_stats() display_entree_stats(stats, ui)
def f5(): opt = libdar.archive_options_read() arch1 = libdar.archive(ui, sauv_path, arch_name, ext, opt); tree1 = libdar.simple_path_mask("/etc/ssh", False) tree2 = libdar.simple_path_mask("/etc/grub.d", False) tree = libdar.ou_mask() tree.add_mask(tree1) tree.add_mask(tree2) opt = libdar.archive_options_diff() opt.set_subtree(tree) opt.set_info_details(True) opt.set_display_treated(True, False) opt.set_ea_mask(libdar.bool_mask(True)) opt.set_furtive_read_mode(False) arch1.op_diff(libdar.path("/etc"), opt) rest = libdar.path("./Restore") try: os.rmdir(rest.display()) except: pass os.mkdir(rest.display()) opt = libdar.archive_options_extract() # the overwriting policy can receive # objects from many different crit_action_* classes # - crit_constant_action() used here does always the same # action on Data and EA+FSA when a conflict arise that # would lead to overwriting # - testing(criterium) the action depends on the evaluation # of the provided criterium (see below) # - crit_chain() + add(crit_action) performs the different # crit_actions added in sequence the first one that provides # an action for Data and/or EA+FSA is retained. If no action # is left undefined the following crit_action of the chain are # not evaluated # # for the testing crit_action inherited class, we need to provide # a criterium object. Here too there is a set of inherited classes # that come to help: # - crit_in_place_is_inode # - crit_in_place_is_dir # - crit_in_place_is_file # - ... # - crit_not (to take the negation of the given criterium) # - crit_or + add_crit() + add_crit() ... makes the logical OR # - crit_and + add_crit() + add_crit()... for the logical AND # - crit_invert for the in_place/to_be_added inversion # Read the manual page about overwriting policy for details # but in substance the criterum return true of false for each # file in conflict and the object if class testing that uses # this criterium applies the action given as "go_true" or the # action given as "go_false" in regard of the provided result over_policy = libdar.crit_constant_action(libdar.over_action_data.data_preserve, libdar.over_action_ea.EA_preserve) opt.set_overwriting_rules(over_policy) # fsa_scope is a std::set in C++ side and translates to a # python set on python side. Use the add() method to add # values to the set: fsa_scope = set() fsa_scope.add(libdar.fsa_family.fsaf_hfs_plus) fsa_scope.add(libdar.fsa_family.fsaf_linux_extX) opt.set_fsa_scope(fsa_scope) stats = libdar.statistics() arch1.op_extract(rest, opt, stats) display_stats(stats)