import subprocess as sub

import logbook


class Process(object):
    """
    Helper class for running processes

    """

    def __init__(self, cmd):
        self.cmd = cmd

        self.proc = None
        self.success = None
        self.log = logbook.Logger(self.__class__.__name__)

    def setup(self):
        """
        Setup the Popen object used in execution

        """

        self.log.info('Spawning handler for {0}...'.format(self.cmd))

        self.popen = sub.Popen(
            self.cmd.split(),
            stdout=sub.PIPE,
            stderr=sub.PIPE,
        )

    def run(self):
        self.log.info('Executing {0}'.format(self.cmd))

        while not self.popen.poll():
            # TODO: Gracefully handle stderr as well
            line = self.popen.stdout.readline()

            if not line:
                break

            self.log.info(line.decode('utf-8').rstrip())

        exit = self.popen.wait()
        self.log.info('Exitcode {0}'.format(exit))

        self.success = exit == 0
        if not self.success:
            self.log.error(self.popen.stderr.read())

@@ -183,19 +183,20 @@
   self.p
-roc
+open
  = None%0A
@@ -266,26 +266,11 @@
 elf.
-__class__.__name__
+cmd
 )%0A%0A 
@@ -381,20 +381,21 @@
 elf.log.
-info
+debug
 ('Spawni
@@ -401,44 +401,24 @@
 ing 
-handler for %7B0%7D...'.format(self.cmd)
+process handler'
 )%0A%0A 
@@ -579,28 +579,29 @@
    self.log.
-info
+debug
 ('Executing 
@@ -603,30 +603,9 @@
 ting
- %7B0%7D'.format(self.cmd)
+'
 )%0A%0A 
@@ -898,20 +898,21 @@
 elf.log.
-info
+debug
 ('Exitco

Change logging setup for Process()