#NEWLINE# @ signalcommand #NEWLINE# def handle( self , * args , **options ) : #NEWLINE# #INDENT# self . style = color_style ( ) #NEWLINE# self . options = options #NEWLINE# if options [ 'requirements' ] : #NEWLINE# #INDENT# req_files = options [ 'requirements' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if os . path . exists ( 'requirements.txt' ) : #NEWLINE# #INDENT# req_files = [ 'requirements.txt' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if os . path . exists ( 'requirements' ) : #NEWLINE# #INDENT# req_files = [ 'requirements/{0}' . format ( f ) for f in os . listdir ( 'requirements' ) if ( os . path . isfile ( os . path . join ( 'requirements' , f ) ) and f . lower ( ) . endswith ( '.txt' ) ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise CommandError ( 'Requirements not found' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# from pip.download import PipSession #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# raise CommandError ( 'Pip version 6 or higher is required' ) #NEWLINE# #UNINDENT# self . reqs = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# with PipSession ( ) as session : #NEWLINE# #INDENT# for filename in req_files : #NEWLINE# #INDENT# for req in parse_requirements ( filename , session = session ) : #NEWLINE# #INDENT# if ( LooseVersion ( pip . __version__ ) > LooseVersion ( '6.0.8' ) ) : #NEWLINE# #INDENT# self . reqs [ req . name ] = { #NEWLINE# #INDENT# 'pip_req' : req , #NEWLINE# 'url' : req . link , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . reqs [ req . name ] = { #NEWLINE# #INDENT# 'pip_req' : req , #NEWLINE# 'url' : req . url , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if options [ 'github_api_token' ] : #NEWLINE# #INDENT# self . github_api_token = options [ 'github_api_token' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if os . environ . get ( 'GITHUB_API_TOKEN' ) : #NEWLINE# #INDENT# self . github_api_token = os . environ . get ( 'GITHUB_API_TOKEN' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . github_api_token = None #NEWLINE# #UNINDENT# #UNINDENT# self . check_pypi ( ) #NEWLINE# if HAS_REQUESTS : #NEWLINE# #INDENT# self . check_github ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# print ( self . style . ERROR ( 'Cannot check github urls. The requests library is not installed. ( pip install requests )' ) ) #NEWLINE# #UNINDENT# self . check_other ( )