def post_ad(args, api=None): generator.run_program(args.ad_file) [data, image_files] = get_post_details(args.ad_file) get_username_if_needed(args, data) attempts = 1 while not check_ad(args) and attempts < 5: if attempts > 1: print("Failed ad post attempt #{}, trying again.".format(attempts)) attempts += 1 if not api: api = kijiji_api.KijijiApi() print('Authenticating user..') api.login(args.username, args.password) api.post_ad_using_data(data, image_files) if not check_ad(args): print('Ad has been taken down :(') print("Failed ad post attempt #{}, giving up.".format(attempts)) else: print('Ad is alive. Program will now exit.')
def generate_post_file(args): generator.run_program()