Skip to content

NameError: name 'photos' is not defined in email.py when using --json flag #589

@MartinGundersen

Description

@MartinGundersen

When running ghunt email with flag --json gets error about photo not being defined.

To Reproduce
ghunt email someuser@gmail.com --json output.json

Expected behavior
Should return json, but CLI command stops due to error.

Traceback

[-] No public Google Calendar.
Traceback (most recent call last):
  File ".../ghunt", line 8, in <module>
    sys.exit(main())
  File ".../ghunt/ghunt.py", line 18, in main
    parse_and_run()
  File ".../ghunt/cli.py", line 63, in parse_and_run
    process_args(args)
  File ".../ghunt/cli.py", line 73, in process_args
    asyncio.run(email.hunt(None, args.email_address, args.json))
  File ".../ghunt/modules/email.py", line 142, in hunt
    "photos": photos,
NameError: name 'photos' is not defined

System (please complete the following information):

  • GHunt version: 2.3.4 (Spider Edition)
  • Python: 3.14.0
  • OS: macOS

Root cause
In ghunt/modules/email.py, the hunt() function references photos and reviews
in the JSON output block (line ~142), but neither variable is ever assigned.
gmaps.get_reviews() only returns (err, stats).

# line ~117
err, stats = await gmaps.get_reviews(as_client, target.personId)

# line ~141 — photos and reviews are undefined here
"maps": {
    "photos": photos,   # NameError
    "reviews": reviews, # NameError
    "stats": stats
},

Suggested fix
Add defaults after the gmaps.get_reviews() call:

err, stats = await gmaps.get_reviews(as_client, target.personId)
gmaps.output(err, stats, target.personId)
photos = None   # not yet fetched; see commented-out loop below
reviews = None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions