<s> from __future__ import print_function <EOL> import os <EOL> import time <EOL> import six <EOL> import pyrax <EOL> import pyrax . exceptions as exc <EOL> import pyrax . utils as utils <EOL> pyrax . set_setting ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> creds_file = os . path . expanduser ( "<STR_LIT>" ) <EOL> pyrax . set_credential_file ( creds_file ) <EOL> cf = pyrax . cloudfiles <EOL> cont_name = pyrax . utils . random_ascii ( <NUM_LIT:8> ) <EOL> cont = cf . create_container ( cont_name ) <EOL> with utils . SelfDeletingTempDirectory ( ) as tmpfolder : <EOL> for idx in six . moves . range ( <NUM_LIT> ) : <EOL> fname = "<STR_LIT>" % idx <EOL> pth = os . path . join ( tmpfolder , fname ) <EOL> with open ( pth , "<STR_LIT:w>" ) as tmp : <EOL> tmp . write ( "<STR_LIT>" ) <EOL> subfolder_path = os . path . join ( tmpfolder , "<STR_LIT>" ) <EOL> os . mkdir ( subfolder_path ) <EOL> for idx in six . moves . range ( <NUM_LIT:7> ) : <EOL> fname = "<STR_LIT>" % idx <EOL> pth = os . path . join ( subfolder_path , fname ) <EOL> with open ( pth , "<STR_LIT:w>" ) as tmp : <EOL> tmp . write ( "<STR_LIT>" * <NUM_LIT:100> ) <EOL> ignore = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> print ( "<STR_LIT>" ) <EOL> upload_key , total_bytes = cf . upload_folder ( tmpfolder , cont , ignore = ignore ) <EOL> print ( "<STR_LIT>" , total_bytes ) <EOL> uploaded = <NUM_LIT:0> <EOL> while uploaded < total_bytes : <EOL> uploaded = cf . get_uploaded ( upload_key ) <EOL> print ( "<STR_LIT>" % ( ( uploaded * <NUM_LIT> ) / total_bytes ) ) <EOL> time . sleep ( <NUM_LIT:1> ) <EOL> folder_name = os . path . basename ( tmpfolder ) <EOL> print ( ) <EOL> print ( "<STR_LIT>" , folder_name ) <EOL> nms = cf . get_container_object_names ( cont , prefix = folder_name ) <EOL> print ( "<STR_LIT>" , len ( nms ) ) <EOL> print ( "<STR_LIT:\n>" . join ( nms ) <EOL> ) <EOL> cont . delete ( True ) </s>
