def populate_userdir(fargs): predefined_locations = ['www', 'secure-www'] userdir, checkmodes = fargs locations = [] try: userdir = os.path.abspath(userdir) if not validate_directory(userdir, checkmodes): return locations public_html_location = userdir + '/public_html' if validate_directory(public_html_location, checkmodes): logging.debug('Appending to locations: %s', public_html_location) locations.append(public_html_location) sites_location = userdir + '/sites' if validate_directory(sites_location, checkmodes): for site in os.listdir(sites_location): sitedir = sites_location + '/' + site if checkmodes: if not check_dir_execution_bit(sitedir): continue for predefined_directory in predefined_locations: sites_location_last = sitedir + '/' + predefined_directory if validate_directory(sites_location_last, checkmodes): logging.debug('Appending to locations: %s', sites_location_last) locations.append(sites_location_last) except Exception: logging.error(traceback.format_exc()) return locations
def populate_userdir(fargs): predefined_locations = ['www', 'secure-www'] userdir, checkmodes = fargs locations = [] try: userdir = os.path.abspath(userdir) if not validate_directory(userdir, checkmodes): return locations public_html_location = userdir + '/public_html' if validate_directory(public_html_location, checkmodes): logging.debug('Appending to locations: %s', public_html_location) locations.append(public_html_location) sites_location = userdir + '/sites' if validate_directory(sites_location, checkmodes): for site in os.scandir(sites_location): site = site.name sitedir = sites_location + '/' + site if checkmodes: if not check_dir_execution_bit(sitedir): continue for predefined_directory in predefined_locations: sites_location_last = sitedir + '/' + predefined_directory if validate_directory(sites_location_last, checkmodes): logging.debug('Appending to locations: %s', sites_location_last) locations.append(sites_location_last) except Exception: logging.error(traceback.format_exc()) return locations
def populate_userdir(fargs): predefined_locations = ["www", "secure-www"] userdir, checkmodes = fargs locations = [] try: userdir = os.path.abspath(userdir) if not validate_directory(userdir, checkmodes): return locations public_html_location = userdir + "/public_html" if validate_directory(public_html_location, checkmodes): logging.debug("Appending to locations: %s", public_html_location) locations.append(public_html_location) sites_location = userdir + "/sites" if validate_directory(sites_location, checkmodes): for site in scandir.scandir(sites_location): site = site.name sitedir = sites_location + "/" + site if checkmodes: if not check_dir_execution_bit(sitedir): continue for predefined_directory in predefined_locations: sites_location_last = sitedir + "/" + predefined_directory if validate_directory(sites_location_last, checkmodes): logging.debug("Appending to locations: %s", sites_location_last) locations.append(sites_location_last) except Exception: logging.error(traceback.format_exc()) return locations
def populate_directory(fargs): """ Populates queue for workers. Consumes lots of disk I/O. """ directory, checkmodes = fargs start_time = time.time() try: if not validate_directory(directory, checkmodes): return time.time() - start_time logging.debug('Populating: %s', directory) for filename in filepaths_in_dir(directory, checkmodes): for appname in database.issues: for loc in database.locations(appname, with_lists=False): if filename.endswith(loc): queue.put((filename, loc, appname)) except Exception: logging.error(traceback.format_exc()) return time.time() - start_time