<s> from conans . client . paths import ConanPaths <EOL> import sys <EOL> import os <EOL> from conans . client . output import ConanOutput , Color <EOL> import argparse <EOL> from conans . errors import ConanException <EOL> import inspect <EOL> from conans . client . remote_manager import RemoteManager <EOL> from conans . client . userio import UserIO <EOL> from conans . client . rest . auth_manager import ConanApiAuthManager <EOL> from conans . client . rest . rest_client import RestApiClient <EOL> from conans . client . store . localdb import LocalDB <EOL> from conans . util . log import logger <EOL> from conans . model . ref import ConanFileReference <EOL> from conans . client . manager import ConanManager <EOL> from conans . paths import CONANFILE <EOL> import requests <EOL> from conans . client . rest . version_checker import VersionCheckerRequester <EOL> from conans import __version__ as CLIENT_VERSION <EOL> from conans . client . conf import MIN_SERVER_COMPATIBLE_VERSION <EOL> from conans . model . version import Version <EOL> from conans . client . migrations import ClientMigrator <EOL> import hashlib <EOL> from conans . util . files import rmdir , load <EOL> from argparse import RawTextHelpFormatter <EOL> import re <EOL> from conans . client . runner import ConanRunner <EOL> from conans . client . remote_registry import RemoteRegistry <EOL> class Extender ( argparse . Action ) : <EOL> '''<STR_LIT>''' <EOL> def __call__ ( self , parser , namespace , values , option_strings = None ) : <EOL> dest = getattr ( namespace , self . dest , None ) <EOL> if ( not hasattr ( dest , '<STR_LIT>' ) or dest == self . default ) : <EOL> dest = [ ] <EOL> setattr ( namespace , self . dest , dest ) <EOL> parser . set_defaults ( ** { self . dest : None } ) <EOL> try : <EOL> dest . extend ( values ) <EOL> except ValueError : <EOL> dest . append ( values ) <EOL> class Command ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , paths , user_io , runner , remote_manager ) : <EOL> assert isinstance ( user_io , UserIO ) <EOL> assert isinstance ( paths , ConanPaths ) <EOL> self . _conan_paths = paths <EOL> self . _user_io = user_io <EOL> self . _runner = runner <EOL> self . _manager = ConanManager ( paths , user_io , runner , remote_manager ) <EOL> def _parse_args ( self , parser ) : <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , help = '<STR_LIT>' ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , <EOL> help = '<STR_LIT>' , <EOL> nargs = <NUM_LIT:1> , action = Extender ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , <EOL> help = '<STR_LIT>' , <EOL> nargs = <NUM_LIT:1> , action = Extender ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , action = Extender , nargs = "<STR_LIT:*>" , <EOL> help = '''<STR_LIT>''' ) <EOL> def _get_tuples_list_from_extender_arg ( self , items ) : <EOL> if not items : <EOL> return [ ] <EOL> for item in items : <EOL> chunks = item . split ( "<STR_LIT:=>" ) <EOL> if len ( chunks ) != <NUM_LIT:2> : <EOL> raise ConanException ( "<STR_LIT>" % item ) <EOL> return [ ( item [ <NUM_LIT:0> ] , item [ <NUM_LIT:1> ] ) for item in [ item . split ( "<STR_LIT:=>" ) for item in items ] ] <EOL> def _detect_tested_library_name ( self ) : <EOL> conanfile_content = load ( CONANFILE ) <EOL> match = re . search ( '<STR_LIT>' , conanfile_content , re . MULTILINE ) <EOL> if match : <EOL> return "<STR_LIT>" % match . group ( <NUM_LIT:1> ) <EOL> self . _user_io . out . warn ( "<STR_LIT>" ) <EOL> return None <EOL> def _get_build_sources_parameter ( self , build_param ) : <EOL> if isinstance ( build_param , list ) : <EOL> if len ( build_param ) == <NUM_LIT:0> : <EOL> return [ "<STR_LIT:*>" ] <EOL> elif len ( build_param ) == <NUM_LIT:1> and build_param [ <NUM_LIT:0> ] == "<STR_LIT>" : <EOL> return False <EOL> elif len ( build_param ) == <NUM_LIT:1> and build_param [ <NUM_LIT:0> ] == "<STR_LIT>" : <EOL> return True <EOL> else : <EOL> return [ "<STR_LIT>" % ref_expr for ref_expr in build_param ] <EOL> else : <EOL> return False <EOL> def test ( self , * args ) : <EOL> """<STR_LIT>""" <EOL> parser = argparse . ArgumentParser ( description = self . test . __doc__ , prog = "<STR_LIT>" , <EOL> formatter_class = RawTextHelpFormatter ) <EOL> parser . add_argument ( "<STR_LIT:path>" , nargs = '<STR_LIT:?>' , default = "<STR_LIT>" , help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , help = '<STR_LIT>' ) <EOL> self . _parse_args ( parser ) <EOL> args = parser . parse_args ( * args ) <EOL> test_folder_name = args . folder or "<STR_LIT:test>" <EOL> root_folder = os . path . normpath ( os . path . join ( os . getcwd ( ) , args . path ) ) <EOL> test_folder = os . path . join ( root_folder , test_folder_name ) <EOL> if not os . path . exists ( test_folder ) : <EOL> raise ConanException ( "<STR_LIT>" ) <EOL> lib_to_test = self . _detect_tested_library_name ( ) <EOL> if args . build is None and lib_to_test : <EOL> args . build = [ lib_to_test ] <EOL> else : <EOL> args . build = self . _get_build_sources_parameter ( args . build ) <EOL> options = args . options or [ ] <EOL> settings = args . settings or [ ] <EOL> sha = hashlib . sha1 ( "<STR_LIT>" . join ( options + settings ) . encode ( ) ) . hexdigest ( ) <EOL> build_folder = os . path . join ( test_folder , "<STR_LIT>" , sha ) <EOL> rmdir ( build_folder ) <EOL> options = self . _get_tuples_list_from_extender_arg ( args . options ) <EOL> settings = self . _get_tuples_list_from_extender_arg ( args . settings ) <EOL> self . _manager . install ( reference = test_folder , <EOL> current_path = build_folder , <EOL> remote = args . remote , <EOL> options = options , <EOL> settings = settings , <EOL> build_mode = args . build ) <EOL> self . _manager . build ( test_folder , build_folder , test = True ) <EOL> def install ( self , * args ) : <EOL> """<STR_LIT>""" <EOL> parser = argparse . ArgumentParser ( description = self . install . __doc__ , prog = "<STR_LIT>" , <EOL> formatter_class = RawTextHelpFormatter ) <EOL> parser . add_argument ( "<STR_LIT>" , nargs = '<STR_LIT:?>' , default = "<STR_LIT>" , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , nargs = <NUM_LIT:1> , action = Extender , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( "<STR_LIT>" , action = '<STR_LIT:store_true>' , default = False , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , action = '<STR_LIT:store_true>' , default = False , <EOL> help = "<STR_LIT>" ) <EOL> self . _parse_args ( parser ) <EOL> args = parser . parse_args ( * args ) <EOL> current_path = os . getcwd ( ) <EOL> try : <EOL> reference = ConanFileReference . loads ( args . reference ) <EOL> except : <EOL> reference = os . path . normpath ( os . path . join ( current_path , args . reference ) ) <EOL> if args . all or args . package : <EOL> if args . all : <EOL> args . package = [ ] <EOL> if not args . reference or not isinstance ( reference , ConanFileReference ) : <EOL> raise ConanException ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . _manager . download ( reference , args . package , remote = args . remote ) <EOL> else : <EOL> args . build = self . _get_build_sources_parameter ( args . build ) <EOL> options = self . _get_tuples_list_from_extender_arg ( args . options ) <EOL> settings = self . _get_tuples_list_from_extender_arg ( args . settings ) <EOL> self . _manager . install ( reference = reference , <EOL> current_path = current_path , <EOL> remote = args . remote , <EOL> options = options , <EOL> settings = settings , <EOL> build_mode = args . build , <EOL> filename = args . file , <EOL> update = args . update ) <EOL> def info ( self , * args ) : <EOL> """<STR_LIT>""" <EOL> parser = argparse . ArgumentParser ( description = self . info . __doc__ , prog = "<STR_LIT>" , <EOL> formatter_class = RawTextHelpFormatter ) <EOL> parser . add_argument ( "<STR_LIT>" , nargs = '<STR_LIT:?>' , default = "<STR_LIT>" , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , help = '<STR_LIT>' ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , <EOL> help = '<STR_LIT>' , <EOL> nargs = <NUM_LIT:1> , action = Extender ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , <EOL> help = '<STR_LIT>' , <EOL> nargs = <NUM_LIT:1> , action = Extender ) <EOL> args = parser . parse_args ( * args ) <EOL> options = self . _get_tuples_list_from_extender_arg ( args . options ) <EOL> settings = self . _get_tuples_list_from_extender_arg ( args . settings ) <EOL> current_path = os . getcwd ( ) <EOL> try : <EOL> reference = ConanFileReference . loads ( args . reference ) <EOL> except : <EOL> reference = os . path . normpath ( os . path . join ( current_path , args . reference ) ) <EOL> self . _manager . install ( reference = reference , <EOL> current_path = current_path , <EOL> remote = args . remote , <EOL> options = options , <EOL> settings = settings , <EOL> build_mode = False , <EOL> info = True , <EOL> filename = args . file ) <EOL> def build ( self , * args ) : <EOL> """<STR_LIT>""" <EOL> parser = argparse . ArgumentParser ( description = self . build . __doc__ , prog = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT:path>" , nargs = "<STR_LIT:?>" , <EOL> help = '<STR_LIT>' , <EOL> default = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> args = parser . parse_args ( * args ) <EOL> current_path = os . getcwd ( ) <EOL> if args . path : <EOL> root_path = os . path . abspath ( args . path ) <EOL> else : <EOL> root_path = current_path <EOL> self . _manager . build ( root_path , current_path , filename = args . file ) <EOL> def package ( self , * args ) : <EOL> """<STR_LIT>""" <EOL> parser = argparse . ArgumentParser ( description = self . package . __doc__ , prog = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , help = '<STR_LIT>' ) <EOL> parser . add_argument ( "<STR_LIT>" , nargs = "<STR_LIT:?>" , default = "<STR_LIT>" , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , default = False , action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( "<STR_LIT>" , action = '<STR_LIT:store_true>' , <EOL> default = False , help = '<STR_LIT>' ) <EOL> args = parser . parse_args ( * args ) <EOL> try : <EOL> reference = ConanFileReference . loads ( args . reference ) <EOL> except : <EOL> raise ConanException ( "<STR_LIT>" ) <EOL> if not args . all and not args . package : <EOL> raise ConanException ( "<STR_LIT>" ) <EOL> self . _manager . package ( reference , args . package , args . only_manifest , args . all ) <EOL> def export ( self , * args ) : <EOL> """<STR_LIT>""" <EOL> parser = argparse . ArgumentParser ( description = self . export . __doc__ , prog = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT:user>" , help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , default = None , <EOL> help = '<STR_LIT>' <EOL> % CONANFILE ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , default = False , action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> args = parser . parse_args ( * args ) <EOL> current_path = args . path or os . getcwd ( ) <EOL> keep_source = args . keep_source <EOL> self . _manager . export ( args . user , current_path , keep_source ) <EOL> def remove ( self , * args ) : <EOL> """<STR_LIT>""" <EOL> parser = argparse . ArgumentParser ( description = self . remove . __doc__ , prog = "<STR_LIT>" ) <EOL> parser . add_argument ( '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , const = [ ] , nargs = '<STR_LIT:?>' , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , const = [ ] , nargs = '<STR_LIT:?>' , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , default = False , action = "<STR_LIT:store_true>" , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , default = False , <EOL> action = '<STR_LIT:store_true>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> args = parser . parse_args ( * args ) <EOL> if args . packages : <EOL> args . packages = args . packages . split ( "<STR_LIT:U+002C>" ) <EOL> if args . builds : <EOL> args . builds = args . builds . split ( "<STR_LIT:U+002C>" ) <EOL> self . _manager . remove ( args . pattern , package_ids_filter = args . packages , <EOL> build_ids = args . builds , <EOL> src = args . src , force = args . force , remote = args . remote ) <EOL> def copy ( self , * args ) : <EOL> """<STR_LIT>""" <EOL> parser = argparse . ArgumentParser ( description = self . copy . __doc__ , prog = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , default = "<STR_LIT>" , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( "<STR_LIT>" , default = "<STR_LIT>" , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , nargs = <NUM_LIT:1> , action = Extender , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( "<STR_LIT>" , action = '<STR_LIT:store_true>' , <EOL> default = False , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( "<STR_LIT>" , action = '<STR_LIT:store_true>' , <EOL> default = False , <EOL> help = '<STR_LIT>' ) <EOL> args = parser . parse_args ( * args ) <EOL> reference = ConanFileReference . loads ( args . reference ) <EOL> new_ref = ConanFileReference . loads ( "<STR_LIT>" % ( reference . name , <EOL> reference . version , <EOL> args . user_channel ) ) <EOL> if args . all : <EOL> args . package = [ ] <EOL> self . _manager . copy ( reference , args . package , new_ref . user , new_ref . channel , args . force ) <EOL> def user ( self , * parameters ) : <EOL> """<STR_LIT>""" <EOL> parser = argparse . ArgumentParser ( description = self . user . __doc__ , prog = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT:name>" , nargs = '<STR_LIT:?>' , default = None , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , help = '<STR_LIT>' ) <EOL> args = parser . parse_args ( * parameters ) <EOL> self . _manager . user ( args . remote , args . name , args . password ) <EOL> def search ( self , * args ) : <EOL> """<STR_LIT>""" <EOL> parser = argparse . ArgumentParser ( description = self . search . __doc__ , prog = "<STR_LIT>" ) <EOL> parser . add_argument ( '<STR_LIT>' , nargs = '<STR_LIT:?>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , default = False , <EOL> action = '<STR_LIT:store_true>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , default = False , <EOL> action = '<STR_LIT:store_true>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , default = False , <EOL> action = '<STR_LIT:store_true>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , help = '<STR_LIT>' , default = None ) <EOL> args = parser . parse_args ( * args ) <EOL> self . _manager . search ( args . pattern , <EOL> args . remote , <EOL> ignorecase = not args . case_sensitive , <EOL> verbose = args . verbose , <EOL> extra_verbose = args . extra_verbose , <EOL> package_pattern = args . package ) <EOL> def upload ( self , * args ) : <EOL> """<STR_LIT>""" <EOL> parser = argparse . ArgumentParser ( description = self . upload . __doc__ , <EOL> prog = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , default = None , help = '<STR_LIT>' ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , help = '<STR_LIT>' ) <EOL> parser . add_argument ( "<STR_LIT>" , action = '<STR_LIT:store_true>' , <EOL> default = False , help = '<STR_LIT>' ) <EOL> parser . add_argument ( "<STR_LIT>" , action = '<STR_LIT:store_true>' , <EOL> default = False , <EOL> help = '<STR_LIT>' ) <EOL> args = parser . parse_args ( * args ) <EOL> conan_ref = ConanFileReference . loads ( args . reference ) <EOL> package_id = args . package <EOL> if not conan_ref and not package_id : <EOL> raise ConanException ( "<STR_LIT>" ) <EOL> self . _manager . upload ( conan_ref , package_id , <EOL> args . remote , all_packages = args . all , force = args . force ) <EOL> def remote ( self , * args ) : <EOL> """<STR_LIT>""" <EOL> parser = argparse . ArgumentParser ( description = self . remote . __doc__ , prog = "<STR_LIT>" ) <EOL> subparsers = parser . add_subparsers ( dest = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> subparsers . add_parser ( '<STR_LIT:list>' , help = '<STR_LIT>' ) <EOL> parser_add = subparsers . add_parser ( '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser_add . add_argument ( '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser_add . add_argument ( '<STR_LIT:url>' , help = '<STR_LIT>' ) <EOL> parser_rm = subparsers . add_parser ( '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser_rm . add_argument ( '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser_upd = subparsers . add_parser ( '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser_upd . add_argument ( '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser_upd . add_argument ( '<STR_LIT:url>' , help = '<STR_LIT:url>' ) <EOL> subparsers . add_parser ( '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser_padd = subparsers . add_parser ( '<STR_LIT>' , help = "<STR_LIT>" ) <EOL> parser_padd . add_argument ( '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser_padd . add_argument ( '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser_prm = subparsers . add_parser ( '<STR_LIT>' , help = "<STR_LIT>" ) <EOL> parser_prm . add_argument ( '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser_pupd = subparsers . add_parser ( '<STR_LIT>' , help = "<STR_LIT>" ) <EOL> parser_pupd . add_argument ( '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser_pupd . add_argument ( '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> args = parser . parse_args ( * args ) <EOL> registry = RemoteRegistry ( self . _conan_paths . registry , self . _user_io . out ) <EOL> if args . subcommand == "<STR_LIT:list>" : <EOL> for r in registry . remotes : <EOL> self . _user_io . out . info ( "<STR_LIT>" % ( r . name , r . url ) ) <EOL> elif args . subcommand == "<STR_LIT>" : <EOL> registry . add ( args . remote , args . url ) <EOL> elif args . subcommand == "<STR_LIT>" : <EOL> registry . remove ( args . remote ) <EOL> elif args . subcommand == "<STR_LIT>" : <EOL> registry . update ( args . remote , args . url ) <EOL> elif args . subcommand == "<STR_LIT>" : <EOL> for ref , remote in registry . refs . items ( ) : <EOL> self . _user_io . out . info ( "<STR_LIT>" % ( ref , remote ) ) <EOL> elif args . subcommand == "<STR_LIT>" : <EOL> registry . add_ref ( args . reference , args . remote ) <EOL> elif args . subcommand == "<STR_LIT>" : <EOL> registry . remove_ref ( args . reference ) <EOL> elif args . subcommand == "<STR_LIT>" : <EOL> registry . update_ref ( args . reference , args . remote ) <EOL> def _show_help ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _user_io . out . writeln ( '<STR_LIT>' , <EOL> Color . BRIGHT_YELLOW ) <EOL> commands = self . _commands ( ) <EOL> for name in sorted ( self . _commands ( ) ) : <EOL> self . _user_io . out . write ( '<STR_LIT>' % name , Color . GREEN ) <EOL> self . _user_io . out . writeln ( commands [ name ] . __doc__ . split ( '<STR_LIT:\n>' , <NUM_LIT:1> ) [ <NUM_LIT:0> ] ) <EOL> def _commands ( self ) : <EOL> """<STR_LIT>""" <EOL> result = { } <EOL> for m in inspect . getmembers ( self , predicate = inspect . ismethod ) : <EOL> method_name = m [ <NUM_LIT:0> ] <EOL> if not method_name . startswith ( '<STR_LIT:_>' ) : <EOL> method = m [ <NUM_LIT:1> ] <EOL> if method . __doc__ and not method . __doc__ . startswith ( '<STR_LIT>' ) : <EOL> result [ method_name ] = method <EOL> return result <EOL> def run ( self , * args ) : <EOL> """<STR_LIT>""" <EOL> errors = False <EOL> try : <EOL> try : <EOL> command = args [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> commands = self . _commands ( ) <EOL> method = commands [ command ] <EOL> except KeyError as exc : <EOL> if command in [ "<STR_LIT>" , "<STR_LIT>" ] : <EOL> self . _user_io . out . success ( "<STR_LIT>" % CLIENT_VERSION ) <EOL> return False <EOL> self . _show_help ( ) <EOL> if command in [ "<STR_LIT>" , "<STR_LIT>" ] : <EOL> return False <EOL> raise ConanException ( "<STR_LIT>" % str ( exc ) ) <EOL> except IndexError as exc : <EOL> self . _show_help ( ) <EOL> return False <EOL> method ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> : ] ) <EOL> except ( KeyboardInterrupt , SystemExit ) as exc : <EOL> logger . error ( exc ) <EOL> errors = True <EOL> except ConanException as exc : <EOL> logger . error ( exc ) <EOL> errors = True <EOL> self . _user_io . out . error ( str ( exc ) ) <EOL> return errors <EOL> def migrate_and_get_paths ( base_folder , out , manager , storage_folder = None ) : <EOL> paths = ConanPaths ( base_folder , storage_folder , out ) <EOL> migrator = ClientMigrator ( paths , Version ( CLIENT_VERSION ) , out , manager ) <EOL> migrator . migrate ( ) <EOL> paths = ConanPaths ( base_folder , storage_folder , out ) <EOL> return paths <EOL> def get_command ( ) : <EOL> def instance_remote_manager ( paths ) : <EOL> requester = requests . Session ( ) <EOL> requester . proxies = paths . conan_config . proxies <EOL> version_checker_requester = VersionCheckerRequester ( requester , Version ( CLIENT_VERSION ) , <EOL> Version ( MIN_SERVER_COMPATIBLE_VERSION ) , <EOL> out ) <EOL> rest_api_client = RestApiClient ( out , requester = version_checker_requester ) <EOL> localdb = LocalDB ( paths . localdb ) <EOL> auth_manager = ConanApiAuthManager ( rest_api_client , user_io , localdb ) <EOL> remote_manager = RemoteManager ( paths , auth_manager , out ) <EOL> return remote_manager <EOL> if hasattr ( sys . stdout , "<STR_LIT>" ) and sys . stdout . isatty ( ) : <EOL> import colorama <EOL> colorama . init ( ) <EOL> color = True <EOL> else : <EOL> color = False <EOL> out = ConanOutput ( sys . stdout , color ) <EOL> user_io = UserIO ( out = out ) <EOL> user_folder = os . getenv ( "<STR_LIT>" , os . path . expanduser ( "<STR_LIT>" ) ) <EOL> try : <EOL> paths = ConanPaths ( user_folder , None , out ) <EOL> remote_manager = instance_remote_manager ( paths ) <EOL> manager = ConanManager ( paths , user_io , ConanRunner ( ) , remote_manager ) <EOL> paths = migrate_and_get_paths ( user_folder , out , manager ) <EOL> except Exception as e : <EOL> out . error ( str ( e ) ) <EOL> sys . exit ( True ) <EOL> manager = instance_remote_manager ( paths ) <EOL> command = Command ( paths , user_io , ConanRunner ( ) , manager ) <EOL> return command <EOL> def main ( args ) : <EOL> """<STR_LIT>""" <EOL> command = get_command ( ) <EOL> current_dir = os . getcwd ( ) <EOL> try : <EOL> import signal <EOL> def sigint_handler ( signal , frame ) : <EOL> print ( '<STR_LIT>' ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> signal . signal ( signal . SIGINT , sigint_handler ) <EOL> error = command . run ( args ) <EOL> finally : <EOL> os . chdir ( current_dir ) <EOL> sys . exit ( error ) </s>
