Opened 4 years ago

Closed 4 years ago

#7832 closed defect (fixed)

Get some consistency in Controller default args

Reported by: atagar Owned by: atagar
Priority: High Milestone:
Component: Core Tor/Stem Version:
Severity: Keywords: controller
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

A major pain point of using TorCtl was that just about every method could raise an exception. This is 'proper' from a standpoint of correctness but made it a pita to use, causing folks (including me) to make wrapper libraries.

A few of our methods based on arm, like get_info() and get_conf(), have an optional 'default' argument that suppresses exceptions. This is great since it lets us have nice code like...

print "my version is %s" % controller.get_info('version', 'unknown')

... instead of...

try:
  my_version = controller.get_info('version')
except:
  my_version = 'unknown'

print "my version is %s" % my_version

However, as we've added more methods to the Controller class this has largely gone by the wayside. In some cases that makes sense, but we should look over our API to figure out what sort of class-wide conventions we want it to have with respect to defaults.

Child Tickets

Change History (1)

comment:1 Changed 4 years ago by atagar

  • Resolution set to fixed
  • Status changed from new to closed

Imho this is a pretty high priority thing so I took care of this while merging #7152...

https://gitweb.torproject.org/stem.git/commitdiff/ffdd61ea41ca844047ac57725639a7cf0e22d41d

Note: See TracTickets for help on using tickets.