Skip to content
This repository was archived by the owner on Sep 17, 2019. It is now read-only.
This repository was archived by the owner on Sep 17, 2019. It is now read-only.

Refactor base driver #273

Open
Open
@dbarrosop

Description

@dbarrosop

This is something that I have been thinking for some time and now #272 gave me a reason to actually try to sell it.

The idea would be to do, instead of what we do today do, something like this:

class NetworkDriver(object):

    def open(self):
         logger.info("connecting to device with parameters blah")
         try:
              self._open()
         except Exception as e:
              logger.error("couldn't connect to device:\n{}".format(e))
              raise
   
     def _open(self):
           raise NotImplemented

class OurDriver(NetworkDriver):
      def _open(self):
           # here goes the code that we had before in the open() method

Used the logging example from #272 but this could help us implement workflows more consistently across platforms. Something like:

def a_method(self):
      try:
            r = self._do_something()
      except Exception as e:
            logger.error("Something horrible happened:\n{}".format(e))
            self._cleanup()
            raise
      if r == condition_a:
           return self._do_something_else()
      return r

Completely made up in case it wasn't obvious but the idea is that the base driver could implement the workflow, try error recoveries, etc. and the drivers could just implement small functions that do very specific things.

This depends on us agreeing to reunify all the drivers. Otherwise this is probably going to be too hard to implement, or rather it's going to be too work.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions