<s> try : <EOL> import urllib3 . contrib . pyopenssl <EOL> urllib3 . contrib . pyopenssl . inject_into_urllib3 ( ) <EOL> except ImportError : <EOL> pass <EOL> import os <EOL> import sys <EOL> import argparse <EOL> import ConfigParser <EOL> import gnupg <EOL> import github3 <EOL> import gettor . core <EOL> from gettor . utils import ( get_bundle_info , get_file_sha256 , <EOL> find_files_to_upload ) <EOL> def upload_new_release ( github_repo , version , upload_dir ) : <EOL> """<STR_LIT>""" <EOL> release = target_repo . create_release ( <EOL> '<STR_LIT>' . format ( version ) , <EOL> target_commitish = "<STR_LIT>" , <EOL> name = '<STR_LIT>' . format ( version ) , <EOL> body = '<STR_LIT>' , <EOL> draft = True , <EOL> ) <EOL> for filename in find_files_to_upload ( upload_dir ) : <EOL> file_path = os . path . join ( upload_dir , filename ) <EOL> print ( "<STR_LIT>" . format ( filename ) ) <EOL> release . upload_asset ( '<STR_LIT>' , <EOL> filename , open ( file_path , '<STR_LIT:rb>' ) ) <EOL> return release <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> parser = argparse . ArgumentParser ( <EOL> description = '<STR_LIT>' <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , default = None , <EOL> help = '<STR_LIT>' <EOL> ) <EOL> args = parser . parse_args ( ) <EOL> config = ConfigParser . ConfigParser ( ) <EOL> config . read ( '<STR_LIT>' ) <EOL> tbb_version_path = config . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> tbb_version_config = ConfigParser . ConfigParser ( ) <EOL> tbb_version_config . read ( tbb_version_path ) <EOL> version = tbb_version_config . get ( '<STR_LIT:version>' , '<STR_LIT>' ) <EOL> github_access_token = config . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> tb_key = config . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> tb_path = config . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> core_path = config . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> github_user = config . get ( '<STR_LIT>' , '<STR_LIT:user>' ) <EOL> github_repo = config . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> gh = github3 . login ( token = github_access_token ) <EOL> target_repo = gh . repository ( github_user , github_repo ) <EOL> gpg = gnupg . GPG ( ) <EOL> key_data = open ( tb_key ) . read ( ) <EOL> import_result = gpg . import_keys ( key_data ) <EOL> fp = import_result . results [ <NUM_LIT:0> ] [ '<STR_LIT>' ] <EOL> readable_fp = '<STR_LIT:U+0020>' . join ( fp [ i : i + <NUM_LIT:4> ] for i in xrange ( <NUM_LIT:0> , len ( fp ) , <NUM_LIT:4> ) ) <EOL> for release in target_repo . releases ( ) : <EOL> if release . tag_name == '<STR_LIT>' . format ( version ) and not release . draft : <EOL> print ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" . format ( release . tag_name ) ) <EOL> break <EOL> else : <EOL> release = None <EOL> if args . links or release : <EOL> if not release : <EOL> print ( "<STR_LIT>" <EOL> "<STR_LIT>" . format ( version ) ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> else : <EOL> print ( '<STR_LIT>' ) <EOL> release = upload_new_release ( target_repo , version , tb_path ) <EOL> release . edit ( draft = False ) <EOL> core = gettor . core . Core ( core_path ) <EOL> core . create_links_file ( '<STR_LIT>' , readable_fp ) <EOL> print ( "<STR_LIT>" ) <EOL> for asset in release . assets ( ) : <EOL> url = asset . browser_download_url <EOL> if url . endswith ( '<STR_LIT>' ) : <EOL> continue <EOL> osys , arch , lc = get_bundle_info ( asset . name ) <EOL> sha256 = get_file_sha256 ( <EOL> os . path . abspath ( os . path . join ( tb_path , asset . name ) ) <EOL> ) <EOL> link = "<STR_LIT>" . format ( url , url + "<STR_LIT>" , sha256 ) <EOL> print ( "<STR_LIT>" . format ( url ) ) <EOL> core . add_link ( '<STR_LIT>' , osys , lc , link ) <EOL> print "<STR_LIT>" </s>
