def process_import_request(username, path, timestamp, logger_handler):
items = []<EOL>error_protocol = []<EOL>global logger<EOL>logger = logger_handler<EOL>user_conf = passwd_reader.read_user_config(username)<EOL>logger.info("<STR_LIT>")<EOL>recursive_chmod(path, <NUM_LIT>)<EOL>try:<EOL><INDENT>for root, dirs, files in os.walk(path):<EOL><INDENT>for dn in dirs + [path]:<EOL><INDENT>dn = os.path.join(root, dn)<EOL>dir_list = [dn + "<STR_LIT:/>" + fn for fn in os.listdir(dn)]<EOL>files = _filter_files(dir_list)<EOL>logger.info("<STR_LIT>" % dn)<EOL>items.extend(<EOL>_process_directory(<EOL>files,<EOL>user_conf,<EOL>error_protocol,<EOL>)<EOL>)<EOL><DEDENT><DEDENT>if conf_merger(user_conf, "<STR_LIT>"):<EOL><INDENT>logger.debug("<STR_LIT>")<EOL>logger.info("<STR_LIT>")<EOL>items = _isbn_pairing(items)<EOL><DEDENT>items = _process_items(items, user_conf, error_protocol)<EOL>logger.info("<STR_LIT>")<EOL>all_dirs = []<EOL>for root, dirs, files in os.walk(path):<EOL><INDENT>all_dirs.extend(<EOL>[os.path.join(root, x) for x in dirs]<EOL>)<EOL><DEDENT>for dn in sorted(all_dirs, reverse=True):<EOL><INDENT>content = os.listdir(dn)<EOL>if not content:<EOL><INDENT>logger.debug("<STR_LIT>" % dn)<EOL>shutil.rmtree(dn)<EOL><DEDENT>else:<EOL><INDENT>logger.debug("<STR_LIT>" % dn)<EOL>logger.debug("<STR_LIT>" % "<STR_LIT>".join(content))<EOL><DEDENT><DEDENT><DEDENT>finally:<EOL><INDENT>logger.info("<STR_LIT>")<EOL>recursive_chmod(path, <NUM_LIT>)<EOL>logger.info("<STR_LIT>" % settings.LOCK_FILENAME)<EOL>create_lock_file(path + "<STR_LIT:/>" + settings.LOCK_FILENAME)<EOL>if error_protocol:<EOL><INDENT>logger.error(<EOL>"<STR_LIT>" % len(error_protocol)<EOL>)<EOL>err_path = path + "<STR_LIT:/>" + settings.USER_ERROR_LOG<EOL>with open(err_path, "<STR_LIT:w>") as fh:<EOL><INDENT>fh.write("<STR_LIT:\n>".join(error_protocol))<EOL><DEDENT>logger.error("<STR_LIT>" % err_path)<EOL><DEDENT>import_log = _create_import_log(items)<EOL>if import_log and conf_merger(user_conf, "<STR_LIT>"):<EOL><INDENT>logger.debug("<STR_LIT>")<EOL>imp_path = path + "<STR_LIT:/>" + settings.USER_IMPORT_LOG<EOL>with open(imp_path, "<STR_LIT:w>") as f:<EOL><INDENT>if error_protocol:<EOL><INDENT>f.write("<STR_LIT>")<EOL>f.write("<STR_LIT>")<EOL>f.write(<EOL>"<STR_LIT>" % settings.USER_ERROR_LOG<EOL>)<EOL>f.write("<STR_LIT>")<EOL>f.write("<STR_LIT:\n>".join(error_protocol))<EOL>f.write("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>f.write("<STR_LIT>")<EOL>f.write("<STR_LIT>")<EOL><DEDENT>f.write("<STR_LIT:\n>".join(import_log))<EOL><DEDENT>logger.info("<STR_LIT>" % imp_path)<EOL><DEDENT><DEDENT>return ImportRequest(<EOL>username=username,<EOL>requests=items,<EOL>import_log="<STR_LIT:\n>".join(import_log),<EOL>error_log="<STR_LIT:\n>".join(error_protocol)<EOL>)<EOL>
React to import request. Look into user's directory and react to files
user uploaded there.

Behavior of this function can be set by setting variables in
:mod:`ftp.settings`.

Args:
    username (str): Name of the user who triggered the import request.
    path (str): Path to the file, which triggered import request.
    timestamp (float): Timestamp of the event.
    logger_handler (object): Python logger. See :py:mod:`logging` for
                             details.

Returns:
    ::class:`.ImportRequest`.