<s> from __future__ import print_function , unicode_literals <EOL> import argparse <EOL> import logging <EOL> import signal <EOL> import socket <EOL> from os import environ , walk , _exit as os_exit <EOL> from os . path import isfile , isdir , join <EOL> from six import text_type , PY2 <EOL> from six . moves . urllib . parse import unquote <EOL> from sys import argv as sys_argv , exit , stderr <EOL> from time import gmtime , strftime <EOL> from swiftclient import RequestException <EOL> from swiftclient . utils import config_true_value , generate_temp_url , prt_bytes <EOL> from swiftclient . multithreading import OutputManager <EOL> from swiftclient . exceptions import ClientException <EOL> from swiftclient import __version__ as client_version <EOL> from swiftclient . client import logger_settings as client_logger_settings , parse_header_string <EOL> from swiftclient . service import SwiftService , SwiftError , SwiftUploadObject , get_conn <EOL> from swiftclient . command_helpers import print_account_stats , print_container_stats , print_object_stats <EOL> try : <EOL> from shlex import quote as sh_quote <EOL> except ImportError : <EOL> from pipes import quote as sh_quote <EOL> BASENAME = '<STR_LIT>' <EOL> commands = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:list>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT:info>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def immediate_exit ( signum , frame ) : <EOL> stderr . write ( "<STR_LIT>" ) <EOL> os_exit ( <NUM_LIT:2> ) <EOL> st_delete_options = '''<STR_LIT>''' <EOL> st_delete_help = '''<STR_LIT>''' . strip ( "<STR_LIT:\n>" ) <EOL> def st_delete ( parser , args , output_manager ) : <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , dest = '<STR_LIT>' , <EOL> default = False , help = '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> dest = '<STR_LIT>' , default = False , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , type = int , <EOL> default = <NUM_LIT:10> , help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , type = int , <EOL> default = <NUM_LIT:10> , help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> ( options , args ) = parse_args ( parser , args ) <EOL> args = args [ <NUM_LIT:1> : ] <EOL> if ( not args and not options . yes_all ) or ( args and options . yes_all ) : <EOL> output_manager . error ( '<STR_LIT>' , <EOL> BASENAME , st_delete_options , <EOL> st_delete_help ) <EOL> return <EOL> if options . object_threads <= <NUM_LIT:0> : <EOL> output_manager . error ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> BASENAME , st_delete_options , <EOL> st_delete_help ) <EOL> return <EOL> if options . container_threads <= <NUM_LIT:0> : <EOL> output_manager . error ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> BASENAME , st_delete_options , <EOL> st_delete_help ) <EOL> return <EOL> _opts = vars ( options ) <EOL> _opts [ '<STR_LIT>' ] = options . object_threads <EOL> with SwiftService ( options = _opts ) as swift : <EOL> try : <EOL> if not args : <EOL> del_iter = swift . delete ( ) <EOL> else : <EOL> container = args [ <NUM_LIT:0> ] <EOL> if '<STR_LIT:/>' in container : <EOL> output_manager . error ( <EOL> '<STR_LIT>' <EOL> "<STR_LIT>" % <EOL> ( container . replace ( '<STR_LIT:/>' , '<STR_LIT:U+0020>' , <NUM_LIT:1> ) , container ) <EOL> ) <EOL> return <EOL> objects = args [ <NUM_LIT:1> : ] <EOL> if objects : <EOL> del_iter = swift . delete ( container = container , <EOL> objects = objects ) <EOL> else : <EOL> del_iter = swift . delete ( container = container ) <EOL> for r in del_iter : <EOL> c = r . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> o = r . get ( '<STR_LIT:object>' , '<STR_LIT>' ) <EOL> a = r . get ( '<STR_LIT>' ) <EOL> if r [ '<STR_LIT:action>' ] == '<STR_LIT>' : <EOL> if r [ '<STR_LIT:success>' ] : <EOL> objs = r . get ( '<STR_LIT>' , [ ] ) <EOL> for o , err in r . get ( '<STR_LIT:result>' , { } ) . get ( '<STR_LIT>' , [ ] ) : <EOL> o = unquote ( o ) <EOL> if PY2 : <EOL> o = o . encode ( '<STR_LIT>' ) . decode ( '<STR_LIT:utf-8>' ) <EOL> output_manager . error ( '<STR_LIT>' <EOL> . format ( o [ <NUM_LIT:1> : ] , err ) ) <EOL> try : <EOL> objs . remove ( o [ len ( c ) + <NUM_LIT:2> : ] ) <EOL> except ValueError : <EOL> pass <EOL> for o in objs : <EOL> if options . yes_all : <EOL> p = '<STR_LIT>' . format ( c , o ) <EOL> else : <EOL> p = o <EOL> output_manager . print_msg ( '<STR_LIT>' . format ( p , a ) ) <EOL> else : <EOL> for o in r . get ( '<STR_LIT>' , [ ] ) : <EOL> output_manager . error ( '<STR_LIT>' <EOL> . format ( c , o , r [ '<STR_LIT:error>' ] ) ) <EOL> else : <EOL> if r [ '<STR_LIT:success>' ] : <EOL> if options . verbose : <EOL> a = ( '<STR_LIT>' . format ( a ) <EOL> if a > <NUM_LIT:1> else '<STR_LIT>' ) <EOL> if r [ '<STR_LIT:action>' ] == '<STR_LIT>' : <EOL> if options . yes_all : <EOL> p = '<STR_LIT>' . format ( c , o ) <EOL> else : <EOL> p = o <EOL> elif r [ '<STR_LIT:action>' ] == '<STR_LIT>' : <EOL> p = '<STR_LIT>' . format ( c , o ) <EOL> elif r [ '<STR_LIT:action>' ] == '<STR_LIT>' : <EOL> p = c <EOL> output_manager . print_msg ( '<STR_LIT>' . format ( p , a ) ) <EOL> else : <EOL> p = '<STR_LIT>' . format ( c , o ) if o else c <EOL> output_manager . error ( '<STR_LIT>' <EOL> . format ( p , r [ '<STR_LIT:error>' ] ) ) <EOL> except SwiftError as err : <EOL> output_manager . error ( err . value ) <EOL> st_download_options = '''<STR_LIT>''' <EOL> st_download_help = '''<STR_LIT>''' . strip ( "<STR_LIT:\n>" ) <EOL> def st_download ( parser , args , output_manager ) : <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , dest = '<STR_LIT>' , <EOL> default = False , help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> default = '<STR_LIT>' , help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , dest = '<STR_LIT>' , <EOL> default = False , help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , type = int , <EOL> default = <NUM_LIT:10> , help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , type = int , default = <NUM_LIT:10> , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> default = False , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> default = [ ] , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , action = '<STR_LIT:store_true>' , dest = '<STR_LIT>' , <EOL> default = False , help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , action = '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> default = True , help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> ( options , args ) = parse_args ( parser , args ) <EOL> args = args [ <NUM_LIT:1> : ] <EOL> if options . out_file == '<STR_LIT:->' : <EOL> options . verbose = <NUM_LIT:0> <EOL> if options . out_file and len ( args ) != <NUM_LIT:2> : <EOL> exit ( '<STR_LIT>' ) <EOL> if not options . prefix : <EOL> options . remove_prefix = False <EOL> if options . out_directory and len ( args ) == <NUM_LIT:2> : <EOL> exit ( '<STR_LIT>' ) <EOL> if ( not args and not options . yes_all ) or ( args and options . yes_all ) : <EOL> output_manager . error ( '<STR_LIT>' , BASENAME , <EOL> st_download_options , st_download_help ) <EOL> return <EOL> if options . object_threads <= <NUM_LIT:0> : <EOL> output_manager . error ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , BASENAME , <EOL> st_download_options , st_download_help ) <EOL> return <EOL> if options . container_threads <= <NUM_LIT:0> : <EOL> output_manager . error ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , BASENAME , <EOL> st_download_options , st_download_help ) <EOL> return <EOL> _opts = vars ( options ) <EOL> _opts [ '<STR_LIT>' ] = options . object_threads <EOL> with SwiftService ( options = _opts ) as swift : <EOL> try : <EOL> if not args : <EOL> down_iter = swift . download ( ) <EOL> else : <EOL> container = args [ <NUM_LIT:0> ] <EOL> if '<STR_LIT:/>' in container : <EOL> output_manager . error ( <EOL> '<STR_LIT>' <EOL> "<STR_LIT>" % <EOL> ( container . replace ( '<STR_LIT:/>' , '<STR_LIT:U+0020>' , <NUM_LIT:1> ) , container ) <EOL> ) <EOL> return <EOL> objects = args [ <NUM_LIT:1> : ] <EOL> if not objects : <EOL> down_iter = swift . download ( container ) <EOL> else : <EOL> down_iter = swift . download ( container , objects ) <EOL> for down in down_iter : <EOL> if options . out_file == '<STR_LIT:->' and '<STR_LIT>' in down : <EOL> contents = down [ '<STR_LIT>' ] <EOL> for chunk in contents : <EOL> output_manager . print_raw ( chunk ) <EOL> else : <EOL> if down [ '<STR_LIT:success>' ] : <EOL> if options . verbose : <EOL> start_time = down [ '<STR_LIT>' ] <EOL> headers_receipt = down [ '<STR_LIT>' ] - start_time <EOL> auth_time = down [ '<STR_LIT>' ] - start_time <EOL> finish_time = down [ '<STR_LIT>' ] <EOL> read_length = down [ '<STR_LIT>' ] <EOL> attempts = down [ '<STR_LIT>' ] <EOL> total_time = finish_time - start_time <EOL> down_time = total_time - auth_time <EOL> _mega = <NUM_LIT> <EOL> if down [ '<STR_LIT>' ] : <EOL> time_str = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % ( <EOL> auth_time , headers_receipt , <EOL> total_time <EOL> ) <EOL> ) <EOL> else : <EOL> speed = float ( read_length ) / down_time / _mega <EOL> time_str = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % ( <EOL> auth_time , headers_receipt , <EOL> total_time , speed <EOL> ) <EOL> ) <EOL> path = down [ '<STR_LIT:path>' ] <EOL> if attempts > <NUM_LIT:1> : <EOL> output_manager . print_msg ( <EOL> '<STR_LIT>' , <EOL> path , time_str , attempts <EOL> ) <EOL> else : <EOL> output_manager . print_msg ( <EOL> '<STR_LIT>' , path , time_str <EOL> ) <EOL> else : <EOL> error = down [ '<STR_LIT:error>' ] <EOL> path = down [ '<STR_LIT:path>' ] <EOL> container = down [ '<STR_LIT>' ] <EOL> obj = down [ '<STR_LIT:object>' ] <EOL> if isinstance ( error , ClientException ) : <EOL> if error . http_status == <NUM_LIT> and options . skip_identical : <EOL> output_manager . print_msg ( <EOL> "<STR_LIT>" , path ) <EOL> continue <EOL> if error . http_status == <NUM_LIT> : <EOL> output_manager . error ( <EOL> "<STR_LIT>" , container , obj ) <EOL> continue <EOL> output_manager . error ( <EOL> "<STR_LIT>" , <EOL> container , obj , error ) <EOL> except SwiftError as e : <EOL> output_manager . error ( e . value ) <EOL> except Exception as e : <EOL> output_manager . error ( e ) <EOL> st_list_options = '''<STR_LIT>''' <EOL> st_list_help = '''<STR_LIT>''' . strip ( '<STR_LIT:\n>' ) <EOL> def st_list ( parser , args , output_manager ) : <EOL> def _print_stats ( options , stats ) : <EOL> total_count = total_bytes = <NUM_LIT:0> <EOL> container = stats . get ( "<STR_LIT>" , None ) <EOL> for item in stats [ "<STR_LIT>" ] : <EOL> item_name = item . get ( '<STR_LIT:name>' ) <EOL> if not options . long and not options . human : <EOL> output_manager . print_msg ( item . get ( '<STR_LIT:name>' , item . get ( '<STR_LIT>' ) ) ) <EOL> else : <EOL> if not container : <EOL> item_bytes = item . get ( '<STR_LIT>' ) <EOL> byte_str = prt_bytes ( item_bytes , options . human ) <EOL> count = item . get ( '<STR_LIT:count>' ) <EOL> total_count += count <EOL> try : <EOL> meta = item . get ( '<STR_LIT>' ) <EOL> utc = gmtime ( float ( meta . get ( '<STR_LIT>' ) ) ) <EOL> datestamp = strftime ( '<STR_LIT>' , utc ) <EOL> except TypeError : <EOL> datestamp = '<STR_LIT>' <EOL> if not options . totals : <EOL> output_manager . print_msg ( <EOL> "<STR_LIT>" , count , byte_str , <EOL> datestamp , item_name ) <EOL> else : <EOL> subdir = item . get ( '<STR_LIT>' ) <EOL> content_type = item . get ( '<STR_LIT>' ) <EOL> if subdir is None : <EOL> item_bytes = item . get ( '<STR_LIT>' ) <EOL> byte_str = prt_bytes ( item_bytes , options . human ) <EOL> date , xtime = item . get ( '<STR_LIT>' ) . split ( '<STR_LIT:T>' ) <EOL> xtime = xtime . split ( '<STR_LIT:.>' ) [ <NUM_LIT:0> ] <EOL> else : <EOL> item_bytes = <NUM_LIT:0> <EOL> byte_str = prt_bytes ( item_bytes , options . human ) <EOL> date = xtime = '<STR_LIT>' <EOL> item_name = subdir <EOL> if not options . totals : <EOL> output_manager . print_msg ( <EOL> "<STR_LIT>" , <EOL> byte_str , date , xtime , content_type , item_name ) <EOL> total_bytes += item_bytes <EOL> if options . long or options . human : <EOL> if not container : <EOL> output_manager . print_msg ( <EOL> "<STR_LIT>" , prt_bytes ( total_count , True ) , <EOL> prt_bytes ( total_bytes , options . human ) ) <EOL> else : <EOL> output_manager . print_msg ( <EOL> prt_bytes ( total_bytes , options . human ) ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , default = False , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> default = False , help = '<STR_LIT>' <EOL> "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> action = '<STR_LIT:store_true>' , default = False ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> options , args = parse_args ( parser , args ) <EOL> args = args [ <NUM_LIT:1> : ] <EOL> if options . delimiter and not args : <EOL> exit ( '<STR_LIT>' ) <EOL> _opts = vars ( options ) . copy ( ) <EOL> if _opts [ '<STR_LIT>' ] : <EOL> _opts . pop ( '<STR_LIT>' ) <EOL> _opts [ '<STR_LIT>' ] = True <EOL> if options . totals and not options . long and not options . human : <EOL> output_manager . error ( <EOL> "<STR_LIT>" ) <EOL> return <EOL> with SwiftService ( options = _opts ) as swift : <EOL> try : <EOL> if not args : <EOL> stats_parts_gen = swift . list ( ) <EOL> else : <EOL> container = args [ <NUM_LIT:0> ] <EOL> args = args [ <NUM_LIT:1> : ] <EOL> if "<STR_LIT:/>" in container or args : <EOL> output_manager . error ( <EOL> '<STR_LIT>' , BASENAME , <EOL> st_list_options , st_list_help ) <EOL> return <EOL> else : <EOL> stats_parts_gen = swift . list ( container = container ) <EOL> for stats in stats_parts_gen : <EOL> if stats [ "<STR_LIT:success>" ] : <EOL> _print_stats ( options , stats ) <EOL> else : <EOL> raise stats [ "<STR_LIT:error>" ] <EOL> except SwiftError as e : <EOL> output_manager . error ( e . value ) <EOL> st_stat_options = '''<STR_LIT>''' <EOL> st_stat_help = '''<STR_LIT>''' . strip ( '<STR_LIT:\n>' ) <EOL> def st_stat ( parser , args , output_manager ) : <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , default = False , <EOL> help = '<STR_LIT>' ) <EOL> options , args = parse_args ( parser , args ) <EOL> args = args [ <NUM_LIT:1> : ] <EOL> _opts = vars ( options ) <EOL> with SwiftService ( options = _opts ) as swift : <EOL> try : <EOL> if not args : <EOL> stat_result = swift . stat ( ) <EOL> if not stat_result [ '<STR_LIT:success>' ] : <EOL> raise stat_result [ '<STR_LIT:error>' ] <EOL> items = stat_result [ '<STR_LIT>' ] <EOL> headers = stat_result [ '<STR_LIT>' ] <EOL> print_account_stats ( items , headers , output_manager ) <EOL> else : <EOL> container = args [ <NUM_LIT:0> ] <EOL> if '<STR_LIT:/>' in container : <EOL> output_manager . error ( <EOL> '<STR_LIT>' <EOL> "<STR_LIT>" % <EOL> ( container . replace ( '<STR_LIT:/>' , '<STR_LIT:U+0020>' , <NUM_LIT:1> ) , container ) ) <EOL> return <EOL> args = args [ <NUM_LIT:1> : ] <EOL> if not args : <EOL> stat_result = swift . stat ( container = container ) <EOL> if not stat_result [ '<STR_LIT:success>' ] : <EOL> raise stat_result [ '<STR_LIT:error>' ] <EOL> items = stat_result [ '<STR_LIT>' ] <EOL> headers = stat_result [ '<STR_LIT>' ] <EOL> print_container_stats ( items , headers , output_manager ) <EOL> else : <EOL> if len ( args ) == <NUM_LIT:1> : <EOL> objects = [ args [ <NUM_LIT:0> ] ] <EOL> stat_results = swift . stat ( <EOL> container = container , objects = objects ) <EOL> for stat_result in stat_results : <EOL> if stat_result [ "<STR_LIT:success>" ] : <EOL> items = stat_result [ '<STR_LIT>' ] <EOL> headers = stat_result [ '<STR_LIT>' ] <EOL> print_object_stats ( <EOL> items , headers , output_manager <EOL> ) <EOL> else : <EOL> raise ( stat_result [ "<STR_LIT:error>" ] ) <EOL> else : <EOL> output_manager . error ( <EOL> '<STR_LIT>' , BASENAME , <EOL> st_stat_options , st_stat_help ) <EOL> except SwiftError as e : <EOL> output_manager . error ( e . value ) <EOL> st_post_options = '''<STR_LIT>''' <EOL> st_post_help = '''<STR_LIT>''' . strip ( '<STR_LIT:\n>' ) <EOL> def st_post ( parser , args , output_manager ) : <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT>' , dest = '<STR_LIT>' , default = [ ] , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> default = [ ] , help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> ( options , args ) = parse_args ( parser , args ) <EOL> args = args [ <NUM_LIT:1> : ] <EOL> if ( options . read_acl or options . write_acl or options . sync_to or <EOL> options . sync_key ) and not args : <EOL> exit ( '<STR_LIT>' ) <EOL> _opts = vars ( options ) <EOL> with SwiftService ( options = _opts ) as swift : <EOL> try : <EOL> if not args : <EOL> result = swift . post ( ) <EOL> else : <EOL> container = args [ <NUM_LIT:0> ] <EOL> if '<STR_LIT:/>' in container : <EOL> output_manager . error ( <EOL> '<STR_LIT>' <EOL> "<STR_LIT>" % <EOL> ( args [ <NUM_LIT:0> ] . replace ( '<STR_LIT:/>' , '<STR_LIT:U+0020>' , <NUM_LIT:1> ) , args [ <NUM_LIT:0> ] ) ) <EOL> return <EOL> args = args [ <NUM_LIT:1> : ] <EOL> if args : <EOL> if len ( args ) == <NUM_LIT:1> : <EOL> objects = [ args [ <NUM_LIT:0> ] ] <EOL> results_iterator = swift . post ( <EOL> container = container , objects = objects <EOL> ) <EOL> result = next ( results_iterator ) <EOL> else : <EOL> output_manager . error ( <EOL> '<STR_LIT>' , BASENAME , <EOL> st_post_options , st_post_help ) <EOL> return <EOL> else : <EOL> result = swift . post ( container = container ) <EOL> if not result [ "<STR_LIT:success>" ] : <EOL> raise ( result [ "<STR_LIT:error>" ] ) <EOL> except SwiftError as e : <EOL> output_manager . error ( e . value ) <EOL> st_upload_options = '''<STR_LIT>''' <EOL> st_upload_help = '''<STR_LIT>''' . strip ( '<STR_LIT:\n>' ) <EOL> def st_upload ( parser , args , output_manager ) : <EOL> parser . add_argument ( <EOL> '<STR_LIT:-c>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , dest = '<STR_LIT>' , <EOL> default = False , help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , action = '<STR_LIT:store_true>' , dest = '<STR_LIT>' , <EOL> default = False , help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> dest = '<STR_LIT>' , default = False , help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , type = int , default = <NUM_LIT:10> , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , type = int , default = <NUM_LIT:10> , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> default = [ ] , help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , action = '<STR_LIT:store_true>' , default = False , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , dest = '<STR_LIT:object_name>' , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , dest = '<STR_LIT>' , default = True , <EOL> action = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> options , args = parse_args ( parser , args ) <EOL> args = args [ <NUM_LIT:1> : ] <EOL> if len ( args ) < <NUM_LIT:2> : <EOL> output_manager . error ( <EOL> '<STR_LIT>' , BASENAME , st_upload_options , <EOL> st_upload_help ) <EOL> return <EOL> else : <EOL> container = args [ <NUM_LIT:0> ] <EOL> files = args [ <NUM_LIT:1> : ] <EOL> if options . object_name is not None : <EOL> if len ( files ) > <NUM_LIT:1> : <EOL> output_manager . error ( '<STR_LIT>' ) <EOL> return <EOL> else : <EOL> orig_path = files [ <NUM_LIT:0> ] <EOL> if options . segment_size : <EOL> try : <EOL> int ( options . segment_size ) <EOL> except ValueError : <EOL> try : <EOL> size_mod = "<STR_LIT>" . index ( options . segment_size [ - <NUM_LIT:1> ] . upper ( ) ) <EOL> multiplier = int ( options . segment_size [ : - <NUM_LIT:1> ] ) <EOL> except ValueError : <EOL> output_manager . error ( "<STR_LIT>" ) <EOL> return <EOL> options . segment_size = str ( ( <NUM_LIT> ** size_mod ) * multiplier ) <EOL> if int ( options . segment_size ) <= <NUM_LIT:0> : <EOL> output_manager . error ( "<STR_LIT>" ) <EOL> return <EOL> if options . object_threads <= <NUM_LIT:0> : <EOL> output_manager . error ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , BASENAME , st_upload_options , <EOL> st_upload_help ) <EOL> return <EOL> if options . segment_threads <= <NUM_LIT:0> : <EOL> output_manager . error ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , BASENAME , st_upload_options , <EOL> st_upload_help ) <EOL> return <EOL> _opts = vars ( options ) <EOL> _opts [ '<STR_LIT>' ] = options . object_threads <EOL> with SwiftService ( options = _opts ) as swift : <EOL> try : <EOL> objs = [ ] <EOL> dir_markers = [ ] <EOL> for f in files : <EOL> if isfile ( f ) : <EOL> objs . append ( f ) <EOL> elif isdir ( f ) : <EOL> for ( _dir , _ds , _fs ) in walk ( f ) : <EOL> if not ( _ds + _fs ) : <EOL> dir_markers . append ( _dir ) <EOL> else : <EOL> objs . extend ( [ join ( _dir , _f ) for _f in _fs ] ) <EOL> else : <EOL> output_manager . error ( "<STR_LIT>" % f ) <EOL> if options . object_name is not None : <EOL> objs = [ <EOL> SwiftUploadObject ( <EOL> o , object_name = o . replace ( <EOL> orig_path , options . object_name , <NUM_LIT:1> <EOL> ) <EOL> ) for o in objs <EOL> ] <EOL> dir_markers = [ <EOL> SwiftUploadObject ( <EOL> None , object_name = d . replace ( <EOL> orig_path , options . object_name , <NUM_LIT:1> <EOL> ) , options = { '<STR_LIT>' : True } <EOL> ) for d in dir_markers <EOL> ] <EOL> for r in swift . upload ( container , objs + dir_markers ) : <EOL> if r [ '<STR_LIT:success>' ] : <EOL> if options . verbose : <EOL> if '<STR_LIT>' in r and r [ '<STR_LIT>' ] > <NUM_LIT:1> : <EOL> if '<STR_LIT:object>' in r : <EOL> output_manager . print_msg ( <EOL> '<STR_LIT>' % <EOL> ( r [ '<STR_LIT:object>' ] , <EOL> r [ '<STR_LIT>' ] ) <EOL> ) <EOL> else : <EOL> if '<STR_LIT:object>' in r : <EOL> output_manager . print_msg ( r [ '<STR_LIT:object>' ] ) <EOL> elif '<STR_LIT>' in r : <EOL> output_manager . print_msg ( <EOL> '<STR_LIT>' % ( r [ '<STR_LIT>' ] , <EOL> r [ '<STR_LIT>' ] ) <EOL> ) <EOL> else : <EOL> error = r [ '<STR_LIT:error>' ] <EOL> if '<STR_LIT:action>' in r and r [ '<STR_LIT:action>' ] == "<STR_LIT>" : <EOL> if isinstance ( error , ClientException ) : <EOL> if ( r [ '<STR_LIT>' ] and <EOL> '<STR_LIT>' in r [ '<STR_LIT>' ] ) : <EOL> msg = '<STR_LIT>' % r [ '<STR_LIT>' ] [ '<STR_LIT>' ] . strip ( ) <EOL> else : <EOL> msg = '<STR_LIT:U+0020>' . join ( str ( x ) for x in ( <EOL> error . http_status , error . http_reason ) <EOL> ) <EOL> if error . http_response_content : <EOL> if msg : <EOL> msg += '<STR_LIT>' <EOL> msg += ( error . http_response_content <EOL> . decode ( '<STR_LIT:utf8>' ) [ : <NUM_LIT> ] ) <EOL> msg = '<STR_LIT>' % msg <EOL> else : <EOL> msg = '<STR_LIT>' % error <EOL> output_manager . warning ( <EOL> '<STR_LIT>' <EOL> "<STR_LIT>" , r [ '<STR_LIT>' ] , msg <EOL> ) <EOL> else : <EOL> output_manager . error ( "<STR_LIT:%s>" % error ) <EOL> too_large = ( isinstance ( error , ClientException ) and <EOL> error . http_status == <NUM_LIT> ) <EOL> if too_large and options . verbose > <NUM_LIT:0> : <EOL> output_manager . error ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> except SwiftError as e : <EOL> output_manager . error ( e . value ) <EOL> st_capabilities_options = "<STR_LIT>" <EOL> st_info_options = st_capabilities_options <EOL> st_capabilities_help = '''<STR_LIT>''' . strip ( '<STR_LIT:\n>' ) <EOL> st_info_help = st_capabilities_help <EOL> def st_capabilities ( parser , args , output_manager ) : <EOL> def _print_compo_cap ( name , capabilities ) : <EOL> for feature , options in sorted ( capabilities . items ( ) , <EOL> key = lambda x : x [ <NUM_LIT:0> ] ) : <EOL> output_manager . print_msg ( "<STR_LIT>" % ( name , feature ) ) <EOL> if options : <EOL> output_manager . print_msg ( "<STR_LIT>" ) <EOL> for key , value in sorted ( options . items ( ) , <EOL> key = lambda x : x [ <NUM_LIT:0> ] ) : <EOL> output_manager . print_msg ( "<STR_LIT>" % ( key , value ) ) <EOL> ( options , args ) = parse_args ( parser , args ) <EOL> if args and len ( args ) > <NUM_LIT:2> : <EOL> output_manager . error ( '<STR_LIT>' , <EOL> BASENAME , <EOL> st_capabilities_options , st_capabilities_help ) <EOL> return <EOL> _opts = vars ( options ) <EOL> with SwiftService ( options = _opts ) as swift : <EOL> try : <EOL> if len ( args ) == <NUM_LIT:2> : <EOL> url = args [ <NUM_LIT:1> ] <EOL> capabilities_result = swift . capabilities ( url ) <EOL> capabilities = capabilities_result [ '<STR_LIT>' ] <EOL> else : <EOL> capabilities_result = swift . capabilities ( ) <EOL> capabilities = capabilities_result [ '<STR_LIT>' ] <EOL> _print_compo_cap ( '<STR_LIT>' , { '<STR_LIT>' : capabilities [ '<STR_LIT>' ] } ) <EOL> del capabilities [ '<STR_LIT>' ] <EOL> _print_compo_cap ( '<STR_LIT>' , capabilities ) <EOL> except SwiftError as e : <EOL> output_manager . error ( e . value ) <EOL> st_info = st_capabilities <EOL> st_auth_help = '''<STR_LIT>''' . strip ( '<STR_LIT:\n>' ) <EOL> def st_auth ( parser , args , thread_manager ) : <EOL> ( options , args ) = parse_args ( parser , args ) <EOL> _opts = vars ( options ) <EOL> if options . verbose > <NUM_LIT:1> : <EOL> if options . auth_version in ( '<STR_LIT:1>' , '<STR_LIT:1.0>' ) : <EOL> print ( '<STR_LIT>' % sh_quote ( options . auth ) ) <EOL> print ( '<STR_LIT>' % sh_quote ( options . user ) ) <EOL> print ( '<STR_LIT>' % sh_quote ( options . key ) ) <EOL> else : <EOL> print ( '<STR_LIT>' % sh_quote ( <EOL> options . auth_version ) ) <EOL> print ( '<STR_LIT>' % sh_quote ( options . auth_version ) ) <EOL> print ( '<STR_LIT>' % sh_quote ( options . auth ) ) <EOL> for k , v in sorted ( _opts . items ( ) ) : <EOL> if v and k . startswith ( '<STR_LIT>' ) and k not in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> print ( '<STR_LIT>' % ( k . upper ( ) , sh_quote ( v ) ) ) <EOL> else : <EOL> conn = get_conn ( _opts ) <EOL> url , token = conn . get_auth ( ) <EOL> print ( '<STR_LIT>' % sh_quote ( url ) ) <EOL> print ( '<STR_LIT>' % sh_quote ( token ) ) <EOL> st_tempurl_options = '''<STR_LIT>''' <EOL> st_tempurl_help = '''<STR_LIT>''' . strip ( '<STR_LIT:\n>' ) <EOL> def st_tempurl ( parser , args , thread_manager ) : <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> dest = '<STR_LIT>' , default = False , <EOL> help = ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> ) <EOL> ( options , args ) = parse_args ( parser , args ) <EOL> args = args [ <NUM_LIT:1> : ] <EOL> if len ( args ) < <NUM_LIT:4> : <EOL> thread_manager . error ( '<STR_LIT>' , BASENAME , <EOL> st_tempurl_options , st_tempurl_help ) <EOL> return <EOL> method , seconds , path , key = args [ : <NUM_LIT:4> ] <EOL> try : <EOL> seconds = int ( seconds ) <EOL> except ValueError : <EOL> thread_manager . error ( '<STR_LIT>' ) <EOL> return <EOL> if method . upper ( ) not in [ '<STR_LIT:GET>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:POST>' , '<STR_LIT>' ] : <EOL> thread_manager . print_msg ( '<STR_LIT>' <EOL> '<STR_LIT>' % <EOL> method . upper ( ) ) <EOL> url = generate_temp_url ( path , seconds , key , method , <EOL> absolute = options . absolute_expiry ) <EOL> thread_manager . print_msg ( url ) <EOL> class HelpFormatter ( argparse . HelpFormatter ) : <EOL> def _format_action_invocation ( self , action ) : <EOL> if not action . option_strings : <EOL> default = self . _get_default_metavar_for_positional ( action ) <EOL> metavar , = self . _metavar_formatter ( action , default ) ( <NUM_LIT:1> ) <EOL> return metavar <EOL> else : <EOL> parts = [ ] <EOL> if action . nargs == <NUM_LIT:0> : <EOL> parts . extend ( action . option_strings ) <EOL> else : <EOL> default = self . _get_default_metavar_for_optional ( action ) <EOL> args_string = self . _format_args ( action , default ) <EOL> for option_string in action . option_strings : <EOL> parts . append ( '<STR_LIT>' % ( option_string , args_string ) ) <EOL> return '<STR_LIT:U+002CU+0020>' . join ( parts ) <EOL> def _get_default_metavar_for_optional ( self , action ) : <EOL> return action . dest . upper ( ) <EOL> def _get_default_metavar_for_positional ( self , action ) : <EOL> return action . dest <EOL> def parse_args ( parser , args , enforce_requires = True ) : <EOL> options , args = parser . parse_known_args ( args or [ '<STR_LIT>' ] ) <EOL> if enforce_requires and ( options . debug or options . info ) : <EOL> logging . getLogger ( "<STR_LIT>" ) <EOL> if options . debug : <EOL> logging . basicConfig ( level = logging . DEBUG ) <EOL> logging . getLogger ( '<STR_LIT>' ) . setLevel ( logging . WARNING ) <EOL> client_logger_settings [ '<STR_LIT>' ] = False <EOL> elif options . info : <EOL> logging . basicConfig ( level = logging . INFO ) <EOL> if args and options . help : <EOL> _help = globals ( ) . get ( '<STR_LIT>' % args [ <NUM_LIT:0> ] , <EOL> "<STR_LIT>" % args [ <NUM_LIT:0> ] ) <EOL> print ( _help ) <EOL> exit ( ) <EOL> if args and args [ <NUM_LIT:0> ] == '<STR_LIT>' : <EOL> return options , args <EOL> if options . auth_version == '<STR_LIT>' : <EOL> options . auth_version = '<STR_LIT:3>' <EOL> if ( not ( options . auth and options . user and options . key ) <EOL> and options . auth_version != '<STR_LIT:3>' ) : <EOL> options . auth_version = '<STR_LIT>' <EOL> if not options . auth and options . os_auth_url : <EOL> options . auth = options . os_auth_url <EOL> if not options . user and options . os_username : <EOL> options . user = options . os_username <EOL> if not options . key and options . os_password : <EOL> options . key = options . os_password <EOL> options . os_options = { <EOL> '<STR_LIT>' : options . os_user_id , <EOL> '<STR_LIT>' : options . os_user_domain_id , <EOL> '<STR_LIT>' : options . os_user_domain_name , <EOL> '<STR_LIT>' : options . os_tenant_id , <EOL> '<STR_LIT>' : options . os_tenant_name , <EOL> '<STR_LIT>' : options . os_project_id , <EOL> '<STR_LIT>' : options . os_project_name , <EOL> '<STR_LIT>' : options . os_project_domain_id , <EOL> '<STR_LIT>' : options . os_project_domain_name , <EOL> '<STR_LIT>' : options . os_service_type , <EOL> '<STR_LIT>' : options . os_endpoint_type , <EOL> '<STR_LIT>' : options . os_auth_token , <EOL> '<STR_LIT>' : options . os_storage_url , <EOL> '<STR_LIT>' : options . os_region_name , <EOL> } <EOL> if len ( args ) > <NUM_LIT:1> and args [ <NUM_LIT:0> ] == "<STR_LIT>" : <EOL> return options , args <EOL> if ( options . os_options . get ( '<STR_LIT>' ) and <EOL> options . os_options . get ( '<STR_LIT>' ) and <EOL> options . auth_version in ( '<STR_LIT>' , '<STR_LIT:3>' ) ) : <EOL> return options , args <EOL> if enforce_requires : <EOL> if options . auth_version == '<STR_LIT:3>' : <EOL> if not options . auth : <EOL> exit ( '<STR_LIT>' + <EOL> '<STR_LIT>' ) <EOL> if not ( options . user or options . os_user_id ) : <EOL> exit ( '<STR_LIT>' + <EOL> '<STR_LIT>' + <EOL> '<STR_LIT>' ) <EOL> if not options . key : <EOL> exit ( '<STR_LIT>' + <EOL> '<STR_LIT>' ) <EOL> elif not ( options . auth and options . user and options . key ) : <EOL> exit ( '''<STR_LIT>''' . strip ( '<STR_LIT:\n>' ) ) <EOL> return options , args <EOL> def main ( arguments = None ) : <EOL> argv = sys_argv if arguments is None else arguments <EOL> argv = [ a if isinstance ( a , text_type ) else a . decode ( '<STR_LIT:utf-8>' ) for a in argv ] <EOL> version = client_version <EOL> parser = argparse . ArgumentParser ( <EOL> add_help = False , formatter_class = HelpFormatter , usage = '''<STR_LIT>''' . strip ( '<STR_LIT:\n>' ) ) <EOL> parser . add_argument ( '<STR_LIT>' , action = '<STR_LIT:version>' , <EOL> version = '<STR_LIT>' % version ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' ) <EOL> default_auth_version = '<STR_LIT:1.0>' <EOL> for k in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> try : <EOL> default_auth_version = environ [ k ] <EOL> break <EOL> except KeyError : <EOL> pass <EOL> parser . add_argument ( '<STR_LIT>' , action = '<STR_LIT:store_true>' , dest = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = argparse . SUPPRESS ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , dest = '<STR_LIT>' , <EOL> default = False , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:count>' , dest = '<STR_LIT>' , <EOL> default = <NUM_LIT:1> , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , action = '<STR_LIT:store_true>' , dest = '<STR_LIT>' , <EOL> default = False , help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , action = '<STR_LIT:store_true>' , dest = '<STR_LIT:info>' , <EOL> default = False , help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> const = <NUM_LIT:0> , default = <NUM_LIT:1> , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> default = environ . get ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> dest = '<STR_LIT>' , <EOL> default = default_auth_version , <EOL> type = str , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT:user>' , <EOL> default = environ . get ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT:key>' , <EOL> default = environ . get ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , type = int , default = <NUM_LIT:5> , dest = '<STR_LIT>' , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> default_val = config_true_value ( environ . get ( '<STR_LIT>' ) ) <EOL> parser . add_argument ( '<STR_LIT>' , <EOL> action = "<STR_LIT:store_true>" , dest = "<STR_LIT>" , <EOL> default = default_val , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , <EOL> action = '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> default = True , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> os_grp = parser . add_argument_group ( "<STR_LIT>" ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = environ . get ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = environ . get ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = environ . get ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = environ . get ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = environ . get ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = environ . get ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = environ . get ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = environ . get ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = environ . get ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = environ . get ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = environ . get ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = environ . get ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = environ . get ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = environ . get ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = environ . get ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = environ . get ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = environ . get ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> help = argparse . SUPPRESS ) <EOL> os_grp . add_argument ( '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> default = environ . get ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> options , args = parse_args ( parser , argv [ <NUM_LIT:1> : ] , enforce_requires = False ) <EOL> if options . help or options . os_help : <EOL> if options . help : <EOL> parser . _action_groups . pop ( ) <EOL> parser . print_help ( ) <EOL> exit ( ) <EOL> if not args or args [ <NUM_LIT:0> ] not in commands : <EOL> parser . print_usage ( ) <EOL> if args : <EOL> exit ( '<STR_LIT>' % args [ <NUM_LIT:0> ] ) <EOL> exit ( ) <EOL> signal . signal ( signal . SIGINT , immediate_exit ) <EOL> with OutputManager ( ) as output : <EOL> parser . usage = globals ( ) [ '<STR_LIT>' % args [ <NUM_LIT:0> ] ] <EOL> try : <EOL> globals ( ) [ '<STR_LIT>' % args [ <NUM_LIT:0> ] ] ( parser , argv [ <NUM_LIT:1> : ] , output ) <EOL> except ClientException as err : <EOL> output . error ( str ( err ) ) <EOL> trans_id = ( err . http_response_headers or { } ) . get ( '<STR_LIT>' ) <EOL> if trans_id : <EOL> output . error ( "<STR_LIT>" , <EOL> parse_header_string ( trans_id ) ) <EOL> except ( RequestException , socket . error ) as err : <EOL> output . error ( str ( err ) ) <EOL> if output . get_error_count ( ) > <NUM_LIT:0> : <EOL> exit ( <NUM_LIT:1> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
