<s> from django . core . management . base import CommandError , BaseCommand <EOL> from optparse import make_option <EOL> import os <EOL> from dimagi . utils . post import post_data <EOL> class Command ( BaseCommand ) : <EOL> option_list = BaseCommand . option_list + ( <EOL> make_option ( '<STR_LIT>' , action = '<STR_LIT:store>' , <EOL> dest = '<STR_LIT>' , default = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , type = '<STR_LIT:string>' ) , <EOL> make_option ( '<STR_LIT>' , action = '<STR_LIT:store_true>' , dest = '<STR_LIT>' , default = False , <EOL> help = '<STR_LIT>' ) , <EOL> make_option ( '<STR_LIT>' , action = '<STR_LIT:store_true>' , dest = '<STR_LIT>' , default = False , <EOL> help = '<STR_LIT>' ) , <EOL> ) <EOL> help = "<STR_LIT>" <EOL> args = '<STR_LIT>' <EOL> label = "<STR_LIT>" <EOL> def handle ( self , * args , ** options ) : <EOL> if len ( args ) < <NUM_LIT:2> : <EOL> raise CommandError ( '<STR_LIT>' % self . args ) <EOL> file = args [ <NUM_LIT:0> ] <EOL> url = args [ <NUM_LIT:1> ] <EOL> rest = args [ <NUM_LIT:2> : ] <EOL> method = options . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> use_chunked = options . get ( '<STR_LIT>' , False ) <EOL> is_odk = options . get ( '<STR_LIT>' , False ) <EOL> if file is None or url is None : <EOL> raise CommandError ( '<STR_LIT>' % self . args ) <EOL> if not os . path . exists ( file ) : <EOL> raise CommandError ( "<STR_LIT>" ) <EOL> attachments = [ ] <EOL> for attach_path in rest : <EOL> if not os . path . exists ( attach_path ) : <EOL> raise CommandError ( "<STR_LIT>" % attach_path ) <EOL> else : <EOL> attachments . append ( ( attach_path . replace ( '<STR_LIT:.>' , '<STR_LIT:_>' ) , attach_path ) ) <EOL> if method == '<STR_LIT>' : <EOL> use_curl = True <EOL> elif method == '<STR_LIT>' : <EOL> use_curl = False <EOL> print post_data ( None , url , path = file , use_curl = use_curl , use_chunked = use_chunked , <EOL> is_odk = is_odk , attachments = attachments ) </s>
