#NEWLINE# @ app . route ( '/admin/cron/repo/' ) #NEWLINE# def gh_admin_top( ) : #NEWLINE# #INDENT# if ( config . PRODUCTION and ( 'X-Appengine-Cron' not in flask . request . headers ) ) : #NEWLINE# #INDENT# flask . abort ( 403 ) #NEWLINE# #UNINDENT# stars = ( util . param ( 'stars' , int ) or 10000 ) #NEWLINE# page = ( util . param ( 'page' , int ) or 1 ) #NEWLINE# per_page = ( util . param ( 'per_page' , int ) or 100 ) #NEWLINE# result = urlfetch . fetch ( ( 'https://api.github.com/search/repositories?q=stars:>=%s&sort=stars&order=asc&page=%d&per_page=%d' % ( stars , page , per_page ) ) ) #NEWLINE# if ( result . status_code == 200 ) : #NEWLINE# #INDENT# repos = json . loads ( result . content ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# flask . abort ( result . status_code ) #NEWLINE# #UNINDENT# for repo in repos [ 'items' ] : #NEWLINE# #INDENT# account = repo [ 'owner' ] #NEWLINE# account_db = model . Account . get_or_insert ( account [ 'login' ] , avatar_url = account [ 'avatar_url' ] . split ( '?' ) [ 0 ] , email = ( account [ 'email' ] if ( 'email' in account ) else '' ) , name = account [ 'login' ] , followers = ( account [ 'followers' ] if ( 'followers' in account ) else 0 ) , organization = ( account [ 'type' ] == 'Organization' ) , username = account [ 'login' ] ) #NEWLINE# #UNINDENT# return ( 'OK %d of %d' % ( len ( repos [ 'items' ] ) , repos [ 'total_count' ] ) )