Beispiel #1
0
def make(directory, params=False, dependencies=False):
    print("Building project in " + directory)
    if not bool(params):
        params = {}
    if not bool(dependencies):
        dependencies = {}
    if bool(dependencies):
        install_distro_dependencies(dependencies)
    params_str = " ".join(
        ["{0}={1}".format(key, val) for key, val in params.items()])

    make_loc = which('make')
    if make_loc is None:
        raise Exception("'MAKE' IS NOT INSTALLED ON SYSTEM")
        sys.exit(1)

    login_file_name = os.path.join(sys_config.log_folder, 'make.txt')
    fs.require_full_path(login_file_name)
    with open(login_file_name, 'a+') as log_file:
        TemporaryDir.enter(os.path.abspath(directory))
        process = subprocess.Popen(['make ', params_str],
                                   stderr=log_file,
                                   stdout=log_file,
                                   shell=True)
        process.communicate()
        if process.returncode != 0:
            raise Exception("'MAKE' finished with status-code " +
                            str(process.returncode))
            sys.exit(1)
    TemporaryDir.leave()
Beispiel #2
0
def make(directory, params=False, dependencies=False):
    print("Building project in " + directory)
    if not bool(params):
        params = {}
    if not bool(dependencies):
        dependencies = {}
    if bool(dependencies):
        install_distro_dependencies(dependencies)
    params_str = " ".join(["{0}={1}".format(key, val) for key, val in params.items()])

    make_loc = which('make')
    if make_loc is None:
        raise Exception("'MAKE' IS NOT INSTALLED ON SYSTEM")
        sys.exit(1)

    login_file_name = os.path.join(sys_config.log_folder, 'make.txt')
    fs.require_full_path(login_file_name)
    with open(login_file_name, 'a+') as log_file:
        TemporaryDir.enter(os.path.abspath(directory))
        process = subprocess.Popen(['make ', params_str], stderr=log_file, stdout=log_file, shell=True)
        process.communicate()
        if process.returncode != 0:
            raise Exception("'MAKE' finished with status-code " + str(process.returncode))
            sys.exit(1)
    TemporaryDir.leave()
Beispiel #3
0
    def run(self):
        log_filename = os.path.join(sys_config.log_folder, 'cmake.log')

        fs.require_full_path(log_filename)
        with open(log_filename, "a+") as cmake_log:
            self.remove_cache()
            command = [self.cmake_path]

            command.extend(self.get_exec_flags())
            if bool(self.build_directory):
                os.makedirs(self.build_directory)
            ret_code = subprocess.call(command, shell=True, stderr=cmake_log, stdout=cmake_log)
            if ret_code:
                raise Exception('"CMAKE RUN" finished with result code ' + str(ret_code))
                sys.exit(1)
Beispiel #4
0
def extract_tar(archive, destination=False):
    archiver_loc = which('tar')
    if not os.path.exists(destination):
        os.makedirs(destination)
    if archiver_loc is None:
        raise Exception("TAR IS NOT INSTALLED ON SYSTEM")
        sys.exit(1)
    exec_command = [archiver_loc, '-xzvf', archive]
    log_filename = os.path.join(sys_config.log_folder, 'untar.log')
    fs.require_full_path(log_filename)
    if destination:
        exec_command.append('-C "{}"'.format(destination))
    with open(log_filename, 'a+') as log_file:
        process = subprocess.Popen(" ".join(exec_command), shell=True, stdout=log_file, stderr=log_file)
        process.communicate()
        if process.returncode:
            raise Exception("TAR EXTRACTION WAS FINISHED WITH CODE: " + str(process.returncode))
            sys.exit(1)
Beispiel #5
0
    def extract(self, destination):

        if not os.path.isfile(self.archive_name):
            raise Exception('Archive is not exists')

        if not os.path.isdir(destination):
            os.makedirs(destination)

        exec_command = '{archiver} x "{location}" -o"{destination}" -y'.format(archiver=self.path_to_7z,
                                                                               location=self.archive_name,
                                                                               destination=destination)
        log_filename = os.path.join(sys_config.log_folder, '7z.log')
        fs.require_full_path(log_filename)
        with open(log_filename, 'a+') as log_file:
            process = subprocess.Popen(exec_command, shell=True, stdout=log_file, stderr=log_file)
            process.communicate()
            result_code = process.returncode
            if result_code != 0:
                raise Exception("Extracting file error")
Beispiel #6
0
def extract_zip(archive, destination=''):
    fs.require_full_path(destination)
    print('Extract by zip: %s -> %s' % (archive, destination))
    with ZipFile(archive, 'r') as archive:
        archive.extractall(destination,)
Beispiel #7
0
def download_file(url, destination=''):
    print('Downloading file %s to %s' % (url, destination))
    fs.require_full_path(destination)
    fname, _ = urlretrieve(url, destination)
    return fname
Beispiel #8
0
 def create_project_path(self):
     require_full_path(self.project_dir)
Beispiel #9
0
 def __init__(self, directory, log_file=None):
     self.git_path = Repo.install_git()
     self.directory = os.path.abspath(directory)
     self.rel_dir = directory
     fs.require_full_path(log_file)
     self.log_std = open(log_file, 'a+') if log_file else open(os.devnull)
Beispiel #10
0
 def __init__(self, directory, log_file=None):
     self.git_path = Repo.install_git()
     self.directory = os.path.abspath(directory)
     self.rel_dir = directory
     fs.require_full_path(log_file)
     self.log_std = open(log_file, 'a+') if log_file else open(os.devnull)