<s> from biicode . client . shell . biistream import Color <EOL> from biicode . common . settings . osinfo import OSInfo <EOL> from biicode . client . setups . finders import finders <EOL> import os <EOL> from biicode . client . setups . conf . downloads_url import get_mingw_download_url <EOL> from biicode . client . setups . setup_tools import download , decompress , add2path <EOL> def install_gnu ( user_io , optional ) : <EOL> if _valid_gnu_version ( user_io ) : <EOL> return <EOL> if OSInfo . is_mac ( ) : <EOL> user_io . out . warn ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> os . system ( '<STR_LIT>' ) <EOL> user_io . request_string ( '<STR_LIT>' ) <EOL> elif OSInfo . is_linux ( ) : <EOL> user_io . out . warn ( '<STR_LIT>' ) <EOL> if OSInfo . is_debian_based_linux ( ) : <EOL> os . system ( '<STR_LIT>' ) <EOL> elif OSInfo . is_redhat_based_linux ( ) : <EOL> os . system ( '<STR_LIT>' ) <EOL> else : <EOL> return install_mingw ( user_io , optional ) <EOL> def _valid_gnu_version ( user_io ) : <EOL> version_gcc = finders . gnu_version ( '<STR_LIT>' ) <EOL> if version_gcc : <EOL> user_io . out . writeln ( '<STR_LIT>' % version_gcc , front = Color . GREEN ) <EOL> version_gpp = finders . gnu_version ( '<STR_LIT>' ) <EOL> if version_gpp : <EOL> user_io . out . writeln ( '<STR_LIT>' % version_gpp , front = Color . GREEN ) <EOL> if version_gcc and version_gpp : <EOL> return True <EOL> return False <EOL> def install_mingw ( user_io , optional ) : <EOL> install = True <EOL> if optional : <EOL> user_io . out . writeln ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , front = Color . CYAN ) <EOL> install = user_io . request_boolean ( '<STR_LIT>' , True ) <EOL> if install : <EOL> user_io . out . writeln ( '<STR_LIT>' , front = Color . GREEN ) <EOL> filename = download ( get_mingw_download_url ( ) , '<STR_LIT>' ) <EOL> user_io . out . info ( "<STR_LIT>" ) <EOL> decompress ( filename , '<STR_LIT>' ) <EOL> mingwpath = '<STR_LIT>' <EOL> mingwpath = mingwpath . replace ( '<STR_LIT:/>' , '<STR_LIT:\\>' ) <EOL> add2path ( mingwpath ) <EOL> user_io . out . success ( "<STR_LIT>" % mingwpath ) <EOL> return True </s>
