MCPcopy Create free account
hub / github.com/adobe/Marinus / main

Function main

python3_cron_scripts/common_crawl_graph.py:218–331  ·  view source on GitHub ↗

Begin main...

(logger=None)

Source from the content-addressed store, hash-verified

216
217
218def main(logger=None):
219 """
220 Begin main...
221 """
222 if logger is None:
223 logger = LoggingUtil.create_log(__name__)
224
225 parser = argparse.ArgumentParser(
226 description="Search the Common Crawl graph dataset for new domains"
227 )
228 parser.add_argument(
229 "--url", metavar="URL", help="The URL for the latest vertices file"
230 )
231 parser.add_argument(
232 "--save_location",
233 metavar="LOCATION",
234 default="./files",
235 help="The directory for saving files",
236 )
237 args = parser.parse_args()
238
239 CURRENT_FILE = CURRENT_FILE_LIST
240
241 if args.url != None:
242 CURRENT_FILE = args.url
243
244 now = datetime.now()
245 print("Starting: " + str(now))
246 logger.info("Starting...")
247
248 mongo_connector = MongoConnector.MongoConnector()
249 dns_manager = DNSManager.DNSManager(mongo_connector)
250 jobs_manager = JobsManager.JobsManager(mongo_connector, "common_crawl_graph")
251 jobs_manager.record_job_start()
252
253 reversed_zones = ZoneManager.get_reversed_zones(mongo_connector)
254
255 alphabet = list(string.digits + string.ascii_lowercase)
256
257 # Create a dictionary of the zones grouped by their first letter
258 # This will allow us to reduce the number of comparisons in the alphabetized CC files.
259 grouped_zones = {}
260 for letter in alphabet:
261 grouped_zones[letter] = []
262
263 for zone in reversed_zones:
264 first_letter = zone[0]
265 grouped_zones[first_letter].append(zone)
266
267 save_location = args.save_location
268 if not save_location.endswith("/"):
269 save_location = save_location + "/"
270
271 compressed_download_list = download_file(logger, CURRENT_FILE, save_location)
272 try:
273 subprocess.check_call(["gunzip", "-f", compressed_download_list])
274 except Exception as e:
275 logger.error("Could not unzip download list")

Callers 1

Calls 9

record_job_startMethod · 0.95
record_job_errorMethod · 0.95
record_job_completeMethod · 0.95
get_first_and_last_lineFunction · 0.85
get_zone_sublistFunction · 0.85
parse_fileFunction · 0.85
create_logMethod · 0.80
get_reversed_zonesMethod · 0.80
download_fileFunction · 0.70

Tested by

no test coverage detected