def write_db(): print("\n[fazip] Creating the database...") host, user, pwd = fazip.get_mysql_info() db = fazip.connect_to_db(user, pwd, host) fazip.remove_db(db) fazip.create_db(db) fazip.create_table_db(db) master = set_master_pass() fazip.set_password_zip(db, master) print("[fazip] Done!")
def do_configuration(login=False): host, user, pwd = fazip.get_mysql_info() db = fazip.connect_to_db(user, pwd, host) options = { 'exit_menu': 0, 'list_users': 1, 'add_user': 2, 'edit_user': 3, 'remove_user': 4, 'change_pass': 5 } if not login: pwd = getpass.getpass("Enter password: "******"[fazip] Access denied") sys.exit() print_menu(options) try: selection = int(input("\n[fazip]> ")) except Exception: selection = -1 print("[fazip] Seriously? That's not a number -.-") if options['exit_menu'] <= selection <= options['change_pass']: if selection == options['add_user']: do_add_user(db) elif selection == options['edit_user']: do_edit_user(db) elif selection == options['remove_user']: do_remove_user(db) elif selection == options['list_users']: do_list_users(db) elif selection == options['exit_menu']: sys.exit() elif selection == options['change_pass']: do_change_pass(db) db.close() else: print("[fazip] Wrong answer") do_configuration(True)
def knows_old_password(): host, user, pwd = fazip.get_mysql_info() db = fazip.connect_to_db(user, pwd, host) pwd = getpass.getpass("[fazip] Enter your old master pass: ") return pwd == fazip.get_password_zip(db)
def exists_fazip_db(): host, user, pwd = fazip.get_mysql_info() db = fazip.connect_to_db(user, pwd, host) return fazip.exists_db(db)
def do_extraction(zipname): host, user, pwd = fazip.get_mysql_info() db = fazip.connect_to_db(user, pwd, host) fazip.unzip_files(db, zipname) db.close()
def do_compression(zipname, files): host, user, pwd = fazip.get_mysql_info() db = fazip.connect_to_db(user, pwd, host) str_files = " ".join(files) fazip.zip_files(db, zipname, str_files) db.close()