<s> import subprocess <EOL> from datetime import datetime <EOL> from libcloud . storage . types import Provider , ContainerDoesNotExistError <EOL> from libcloud . storage . providers import get_driver <EOL> driver = get_driver ( Provider . CLOUDFILES_US ) ( '<STR_LIT:username>' , '<STR_LIT>' ) <EOL> directory = '<STR_LIT>' <EOL> cmd = '<STR_LIT>' % ( directory ) <EOL> object_name = '<STR_LIT>' % ( datetime . now ( ) . strftime ( '<STR_LIT>' ) ) <EOL> container_name = '<STR_LIT>' <EOL> try : <EOL> container = driver . get_container ( container_name = container_name ) <EOL> except ContainerDoesNotExistError : <EOL> container = driver . create_container ( container_name = container_name ) <EOL> pipe = subprocess . Popen ( cmd , bufsize = <NUM_LIT:0> , shell = True , stdout = subprocess . PIPE ) <EOL> return_code = pipe . poll ( ) <EOL> print '<STR_LIT>' <EOL> while return_code is None : <EOL> obj = container . upload_object_via_stream ( iterator = pipe . stdout , <EOL> object_name = object_name ) <EOL> return_code = pipe . poll ( ) <EOL> print '<STR_LIT>' % ( ( obj . size / <NUM_LIT> ) ) </s>
