# Path: circlator/common.py
# class Error (Exception): pass
# def syscall(cmd, allow_fail=False, verbose=False):
# def syscall_get_stdout(cmd):
# def decode(x):
# def check_files_exist(filenames):


import shutil
import os
import re
import subprocess
from distutils.version import LooseVersion
from circlator import common
            print(self.name, '- checking which(' + self.path + ')', flush=True)

        self.from_which = shutil.which(self.path)

        if self.debug:
            print('   ... got: "', self.from_which, '"', sep='', flush=True)

        self._set_version()


    def in_path(self):
        '''Returns true iff it is in the path'''
        return self.from_which is not None


    def _set_version(self):
        self.version = None

        if self.debug:
            print(self.name, '- checking version ...')

        if not self.in_path():
            if self.debug:
                print(' ... not in path so cannot get version', flush=True)
                return

        cmd = self.exe() + ' ' + self.version_cmd
        if self.debug:
            print('Running this command to get version:', cmd)
        cmd_output = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()

# Path: circlator/common.py
# class Error (Exception): pass
# def syscall(cmd, allow_fail=False, verbose=False):
# def syscall_get_stdout(cmd):
# def decode(x):
# def check_files_exist(filenames):


# Path: circlator/program.py
import shutil
import os
import re
import subprocess
from distutils.version import LooseVersion
from circlator import common

            print(self.name, '- checking which(' + self.path + ')', flush=True)

        self.from_which = shutil.which(self.path)

        if self.debug:
            print('   ... got: "', self.from_which, '"', sep='', flush=True)

        self._set_version()


    def in_path(self):
        '''Returns true iff it is in the path'''
        return self.from_which is not None


    def _set_version(self):
        self.version = None

        if self.debug:
            print(self.name, '- checking version ...')

        if not self.in_path():
            if self.debug:
                print(' ... not in path so cannot get version', flush=True)
                return

        cmd = self.exe() + ' ' + self.version_cmd
        if self.debug:
            print('Running this command to get version:', cmd)
        cmd_output = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()

        cmd_output = common.decode(cmd_output[0]).split('\n')[:-1] + common.decode(cmd_output[1]).split('\n')[:-1]