def pack_turret(turret, temp_files, base_config_path, path=None):
    """pack a turret into a tar file based on the turret configuration

    :param dict turret_config: the turret configuration to pack
    :param str tmp_config_file: the path of the temp config file
    :param str base_config_path: the base directory of the main configuration file
    """
    file_name = turret['name']
    files = temp_files[:]
    for fname in turret.get('extra_files', []):
        if os.path.isabs(fname) or path is None:
            files.append(fname)
        else:
            files.append(os.path.join(path, fname))
    if path is not None:
        file_name = os.path.join(path, file_name)
    tar_file = tarfile.open(file_name + ".tar.gz", 'w:gz')

    for f in files:
        tar_file.add(os.path.abspath(f), arcname=os.path.basename(f))

    script_path = os.path.join(os.path.abspath(base_config_path), turret['script'])
    tar_file.add(script_path, arcname=turret['script'])

    for f in tar_file.getnames():
        print("Added %s" % f)
    tar_file.close()
    print("Archive %s created" % (tar_file.name))
    print("=========================================")
def pack_turret ( turret , temp_files , base_config_path , path = None ) : file_name = turret [ 'name' ] files = temp_files [ : ] for fname in turret . get ( 'extra_files' , [ ] ) : if os . path . isabs ( fname ) or path is None : files . append ( fname ) else : files . append ( os . path . join ( path , fname ) ) if path is not None : file_name = os . path . join ( path , file_name ) tar_file = tarfile . open ( file_name + ".tar.gz" , 'w:gz' ) for f in files : tar_file . add ( os . path . abspath ( f ) , arcname = os . path . basename ( f ) ) script_path = os . path . join ( os . path . abspath ( base_config_path ) , turret [ 'script' ] ) tar_file . add ( script_path , arcname = turret [ 'script' ] ) for f in tar_file . getnames ( ) : print ( "Added %s" % f ) tar_file . close ( ) print ( "Archive %s created" % ( tar_file . name ) ) print ( "=========================================" )
pack a turret into a tar file based on the turret configuration

    :param dict turret_config: the turret configuration to pack
    :param str tmp_config_file: the path of the temp config file
    :param str base_config_path: the base directory of the main configuration file