@staticmethod
def _communicate(subproc, inputstr=None):
    """
        Encode the input given to the subprocess if any
        :param subproc:
        :param inputstr:
        :return: A tuple of (stdout, stderr)
        """
    if inputstr is None:
        return subproc.communicate()
    if not inputstr:
        inputstr = ''
    return subproc.communicate(inputstr.encode())
