#NEWLINE# def add( self , cmd , args , options ) : #NEWLINE# #INDENT# 'Add an individual serial number to a model.\n\nUsage:\n\texo [options] sn add <model> (--file=<file> | <sn>...)' #NEWLINE# pop = options [ 'pop' ] #NEWLINE# exoconfig = options [ 'config' ] #NEWLINE# ExoException = options [ 'exception' ] #NEWLINE# key = exoconfig . config [ 'vendortoken' ] #NEWLINE# if ( args [ '--file' ] is None ) : #NEWLINE# #INDENT# mlist = pop . serialnumber_add_batch ( key , args [ '<model>' ] , args [ '<sn>' ] ) #NEWLINE# print ( mlist . body ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# data = '' #NEWLINE# try : #NEWLINE# #INDENT# if ( args [ '--file' ] == '-' ) : #NEWLINE# #INDENT# data = sys . stdin . read ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# with open ( args [ '--file' ] ) as f : #NEWLINE# #INDENT# data = f . read ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except IOError as ex : #NEWLINE# #INDENT# raise ExoException ( 'Could not read {0}' . format ( args [ '--file' ] ) ) #NEWLINE# #UNINDENT# path = ( ( '/provision/manage/model/' + args [ '<model>' ] ) + '/' ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'Content-Type' : 'text/csv; charset=utf-8' , #NEWLINE# #UNINDENT# } #NEWLINE# mlist = pop . _request ( path , key , data , 'POST' , False , headers ) #NEWLINE# print ( mlist . body )