Module Expr Str Assign NameStore Str Import alias Import alias Import alias Import alias Import alias Import alias Import alias Import alias Import alias ImportFrom alias ImportFrom alias alias ImportFrom alias alias alias alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias alias alias ImportFrom alias ImportFrom alias ImportFrom alias Expr Call AttributeLoad NameLoad attr Str keyword NameLoad keyword Str Expr Call AttributeLoad NameLoad attr Str keyword NameLoad keyword NameLoad keyword Str Expr Call AttributeLoad NameLoad attr Str keyword NameLoad keyword NameLoad keyword Str Expr Call AttributeLoad NameLoad attr Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str keyword NameLoad keyword Num keyword Str Expr Call AttributeLoad NameLoad attr Str keyword Num keyword Str FunctionDef arguments args NameParam NameParam NameParam defaults body Assign NameStore Dict Str Str Str Str Str Str Str AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad Expr Yield Call AttributeLoad NameLoad attr AttributeLoad Call AttributeLoad NameLoad attr attr keyword NameLoad NameLoad Expr Call NameLoad decorator_list AttributeLoad NameLoad attr FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad AttributeLoad NameLoad attr attr Assign NameStore Yield Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad keyword Str Assign NameStore Call NameLoad Assign NameStore Call NameLoad For NameStore NameLoad body If BoolOpOr Call AttributeLoad NameLoad attr Str Call AttributeLoad NameLoad attr Str body Expr Call AttributeLoad NameLoad attr NameLoad orelse If BoolOpOr Call AttributeLoad NameLoad attr Str Call AttributeLoad NameLoad attr Str body Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Slice Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Str Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad Call NameLoad NameLoad Call NameLoad NameLoad NameLoad If UnaryOpNot NameLoad body Expr Call NameLoad Return Assign NameStore Call NameLoad Call NameLoad NameLoad Assign NameStore Dict Assign NameStore Dict For NameStore NameLoad body TryExcept body Assign NameStore Yield Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad Assign NameStore ListComp BinOpAdd NameLoad Str comprehension NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore BinOpAdd NameLoad Str If UnaryOpNot AttributeLoad AttributeLoad NameLoad attr attr body Expr Yield Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad Call NameLoad Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr Assign SubscriptStore NameLoad Index Str NameLoad Assign SubscriptStore NameLoad Index NameLoad NameLoad handlers ExceptHandler body Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad NameLoad Assign SubscriptStore NameLoad Index NameLoad NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Assign NameStore BinOpMod Str Call NameLoad NameLoad Assign NameStore BinOpAdd NameLoad Str FunctionDef arguments args NameParam defaults body Return Call AttributeLoad NameLoad attr NameLoad keyword BinOpMult AttributeLoad NameLoad attr AttributeLoad AttributeLoad NameLoad attr attr keyword Str decorator_list If NameLoad body AugAssignAdd NameStore BinOpMod Str Call NameLoad NameLoad AugAssignAdd NameStore BinOpMod Str Call NameLoad NameLoad For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr body AugAssignAdd NameStore Str AugAssignAdd NameStore BinOpMod Str TupleLoad Call NameLoad NameLoad NameLoad If NameLoad body Assign NameStore Call NameLoad NameLoad For NameStore Call AttributeLoad NameLoad attr body Expr Call AttributeLoad SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Str attr NameLoad AugAssignAdd NameStore BinOpMod Str TupleLoad Call NameLoad NameLoad Call NameLoad NameLoad For NameStore Call AttributeLoad NameLoad attr body AugAssignAdd NameStore Str AugAssignAdd NameStore BinOpMod Str Call NameLoad NameLoad For NameStore NameLoad body AugAssignAdd NameStore BinOpMod Str Call NameLoad SubscriptLoad NameLoad Index Str AugAssignAdd NameStore BinOpMod Str TupleLoad SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str Expr Yield Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Expr Call NameLoad decorator_list AttributeLoad NameLoad attr FunctionDef arguments args NameParam defaults body Assert CompareEq AttributeLoad NameLoad attr Str BinOpMod Str AttributeLoad NameLoad attr Expr Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Assign NameStore Call NameLoad NameLoad Str If AttributeLoad AttributeLoad NameLoad attr attr body Expr Call AttributeLoad NameLoad attr Call NameLoad orelse Expr Call AttributeLoad NameLoad attr Call NameLoad If AttributeLoad AttributeLoad NameLoad attr attr body Assign NameStore Yield Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr If CompareEq NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr Str Expr Call NameLoad Return TryFinally body TryExcept body Expr Yield Call AttributeLoad NameLoad attr NameLoad NameLoad handlers ExceptHandler body Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr finalbody Expr Yield Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call NameLoad decorator_list AttributeLoad NameLoad attr If CompareEq NameLoad Str body Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad
N/A N/A Symbolicate user crash logs.

This looks for unprocessed crash logs in s3://serverdata/merged_user_crashed/, symbolicates them, and sends a
summary email.

REQUIREMENTS:
- run on OSX for dependencies (mdfind, dwarfdump, atos)
- have the build dSyms on the local filesystem (default is ~/Dropbox/viewfinder/{dSYMs,dSYMs.uuid}

TODO: it would be great if we had a way to dump all symbols, allowing us to run this anywhere.

This grabs the 'client_logs_analysis' dynamodb lock to ensure we do not run at the same time as get_client_logs.py.

Usage:
# Symbolicate new crash logs and email summary
python -m viewfinder.backend.logs.symbolicate_user_crashes --devbox
# Don't write symbolicated files to S3 and log the summary email instead of sending.
python -m viewfinder.backend.logs.symbolicate_user_crashes --devbox --dry_run=True --send_email=False

Other options:
-require_lock: default=True: hold the job:client_logs_analysis lock during processing.
-send_email: default=True: email crash summaries (if any)
-email: recipient for summary emails
-show_at_most: default=2: show at most this many full crash logs in summary email

 N/A __author__ marc@emailscrubbed.com (Marc Berhault) N/A cStringIO N/A json N/A logging N/A numpy N/A os N/A re N/A sys N/A time N/A traceback collections defaultdict tornado gen options viewfinder.backend.base constants main statistics util viewfinder.backend.base.dotdict DotDict viewfinder.backend.db db_client viewfinder.backend.db.job Job viewfinder.backend.logs logs_util viewfinder.backend.services.email_mgr EmailManager LoggingEmailManager SendGridEmailManager viewfinder.backend.storage.object_store ObjectStore viewfinder.backend.storage store_utils viewfinder.clients.ios.scripts.symbolicator Symbolicator N/A N/A N/A options define dry_run default True help Do not update dynamodb metrics table N/A N/A N/A options define require_lock type bool default True help attempt to grab the job:client_logs_analysis lock before running. Exit if acquire fails. N/A N/A N/A options define send_email type bool default True help Email crash summary N/A N/A N/A options define email default crash-reports+client@emailscrubbed.com help Email address to notify N/A N/A N/A options define show_at_most type int default 100 help Show at most this many symbolicated crashes in email summary N/A N/A N/A options define s3_url_expiration_days default 14 help Time to live in days for S3 URLs SendEmail N/A N/A title text callback N/A N/A N/A args N/A from fromname to subject text crash-reports+client@emailscrubbed.com Symbolicator N/A N/A options options email title text N/A N/A N/A N/A gen Task N/A N/A N/A EmailManager Instance SendEmail description title args N/A N/A callback N/A N/A gen engine RunOnce N/A N/A client callback N/A N/A N/A merged_store N/A N/A ObjectStore GetInstance N/A N/A logs_util UserCrashLogsPaths MERGED_LOGS_BUCKET N/A files N/A N/A N/A gen Task N/A store_utils ListAllKeys merged_store prefix merged_user_crashes N/A crash_files N/A set N/A symbolicated_files N/A set N/A f files N/A N/A N/A N/A N/A f endswith .crash N/A N/A f endswith .crash.gz N/A N/A N/A N/A crash_files add f N/A N/A N/A N/A N/A f endswith .crash.symbol N/A N/A f endswith .crash.gz.symbol N/A N/A N/A N/A symbolicated_files add N/A f N/A -7 N/A missing N/A N/A crash_files difference symbolicated_files N/A 
  A sample list of files to test with. Should probably go away in favor of cmdline.
  missing = [
  'merged_user_crashes/8339/2013-07-25/dev-18194-01-17-14.918-2.0.1.61.crash',
  'merged_user_crashes/7872/2013-07-24/dev-17246-17-46-07.277-2.0.1.61.crash',
  'merged_user_crashes/8246/2013-07-25/dev-17947-00-07-59.215-2.0.1.61.crash',
  'merged_user_crashes/8246/2013-07-25/dev-17947-00-08-17.822-2.0.1.61.crash',
  'merged_user_crashes/8342/2013-07-25/dev-18136-00-58-09.061-2.0.1.61.crash',
  'merged_user_crashes/2286/2013-07-24/dev-17163-15-19-11.778-2.1.0.70.dev.jailbroken.crash',
  'merged_user_crashes/8768/2013-07-25/dev-18941-06-04-18.591-2.0.2.69.crash',
  'merged_user_crashes/8339/2013-07-25/dev-18194-01-18-17.613-2.0.1.61.crash',
  'merged_user_crashes/8074/2013-07-24/dev-17645-23-19-33.700-2.0.1.61.crash',
  'merged_user_crashes/8320/2013-07-25/dev-18096-01-31-49.906-2.0.1.61.crash',
  'merged_user_crashes/8246/2013-07-25/dev-17947-00-09-11.781-2.0.1.61.crash',
  'merged_user_crashes/8751/2013-07-25/dev-18910-05-54-43.572-2.0.2.69.crash',
  'merged_user_crashes/8246/2013-07-25/dev-17947-00-09-19.120-2.0.1.61.crash',
  'merged_user_crashes/8341/2013-07-25/dev-18134-00-46-50.904-2.0.1.61.crash',
  'merged_user_crashes/8316/2013-07-25/dev-18080-02-14-49.269-2.0.1.61.crash',
  'merged_user_crashes/8743/2013-07-25/dev-18898-05-40-50.450-2.0.1.61.crash',
  'merged_user_crashes/8074/2013-07-24/dev-17645-23-12-56.844-2.0.1.61.crash',
  'merged_user_crashes/2286/2013-07-24/dev-17163-15-19-20.884-2.1.0.70.dev.jailbroken.crash',
  'merged_user_crashes/8093/2013-07-24/dev-17650-23-29-34.198-2.0.1.61.crash',
  'merged_user_crashes/8339/2013-07-25/dev-18194-01-17-40.123-2.0.1.61.crash',
  'merged_user_crashes/8074/2013-07-24/dev-17645-23-19-41.996-2.0.1.61.crash'
  ]
   N/A N/A N/A logging info N/A Found %d crash logs, %d missing: %r N/A N/A len crash_files N/A len missing missing N/A N/A missing N/A N/A N/A callback N/A N/A missing_crashes N/A sorted N/A list missing N/A processed_crashes N/A N/A failures N/A N/A f missing_crashes N/A N/A N/A N/A contents N/A N/A N/A gen Task N/A merged_store Get f N/A lines N/A N/A l N/A l N/A N/A contents split N/A sym N/A Symbolicator N/A N/A N/A sym process_one_file lines N/A newfile N/A f .symbol N/A N/A N/A N/A options options dry_run N/A N/A N/A N/A N/A gen Task N/A merged_store Put newfile N/A N/A sym FullOutput N/A N/A N/A logging info N/A Wrote %d bytes to %s N/A N/A len N/A N/A sym FullOutput newfile N/A out_dict N/A N/A sym OutputDict N/A N/A out_dict N/A filename newfile N/A N/A processed_crashes N/A newfile out_dict N/A N/A N/A N/A msg N/A N/A traceback format_exc N/A N/A N/A logging error N/A Failed to process %s: %s N/A f msg N/A N/A failures N/A f msg N/A N/A N/A logging info N/A Successfully processed crashes: %r N/A N/A processed_crashes keys N/A N/A N/A logging info N/A Symbolicate failures: %r failures N/A title N/A %d new client crashes N/A len missing_crashes N/A text N/A title _S3URL N/A N/A filename N/A N/A N/A N/A N/A merged_store GenerateUrl filename expires_in N/A N/A constants SECONDS_PER_DAY N/A N/A options options s3_url_expiration_days content_type text/plain N/A N/A failures N/A N/A title N/A  (%d failed during processing) N/A len failures N/A text N/A 
Processing failures: %d
 N/A len failures N/A N/A f tb N/A N/A failures iteritems N/A N/A text --------------------------
 N/A text N/A Non-symbolicated file: %s
%s
 N/A N/A _S3URL f tb N/A processed_crashes N/A N/A deduped_crashes N/A defaultdict list N/A v N/A N/A processed_crashes values N/A N/A N/A N/A N/A deduped_crashes N/A N/A v N/A crashed_thread_backtrace append v N/A text N/A 
%d symbolicated crashes, %d after deduping

 N/A N/A len processed_crashes N/A len deduped_crashes N/A crash_set N/A N/A deduped_crashes values N/A N/A text --------------------------
 N/A text N/A %d crashes after deduping. Full symbolicated files:
 N/A len crash_set N/A c crash_set N/A N/A text N/A %s
 N/A _S3URL N/A c N/A filename N/A text N/A 
First crash:
%s%s%s
 N/A N/A c N/A preamble N/A c N/A crashed_thread_title N/A c N/A crashed_thread_backtrace N/A N/A N/A N/A gen Task SendEmail title text N/A N/A callback N/A N/A gen engine Start N/A N/A callback N/A N/A N/A N/A N/A sys platform darwin N/A This script can only run on OSX. You are using %s N/A sys platform N/A Grab a lock on job:client_logs_analysis and call RunOnce. N/A client N/A N/A N/A db_client DBClient Instance N/A job N/A Job client client_logs_analysis N/A N/A N/A options options send_email N/A N/A N/A N/A EmailManager SetInstance N/A SendGridEmailManager N/A N/A N/A N/A EmailManager SetInstance N/A LoggingEmailManager N/A N/A N/A options options require_lock N/A N/A got_lock N/A N/A N/A gen Task N/A job AcquireLock N/A N/A got_lock False N/A N/A N/A N/A logging warning Failed to acquire job lock: exiting. N/A N/A callback N/A N/A N/A N/A N/A N/A N/A N/A N/A gen Task RunOnce client N/A N/A N/A N/A N/A N/A logging error N/A N/A traceback format_exc N/A N/A N/A N/A N/A gen Task N/A job ReleaseLock N/A N/A callback N/A N/A gen engine N/A N/A __name__ __main__ N/A N/A N/A N/A sys exit N/A N/A main InitAndRun Start