@@ -0,0 +1,1699 @@
+import os%0Aimport logging%0Aimport ConfigParser%0Aimport urllib2%0A%0Afrom libcloud.storage.types import Provider, ContainerDoesNotExistError, ObjectDoesNotExistError%0Afrom libcloud.storage.providers import get_driver%0A%0ACONFIG_PATH = '/etc/airtime/airtime.conf'%0A%0Aclass CloudStorageDownloader:%0A    def __init__(self):%0A        config = self.read_config_file(CONFIG_PATH)%0A        %0A        S3_CONFIG_SECTION = %22s3%22%0A        self._s3_bucket = config.get(S3_CONFIG_SECTION, 'bucket')%0A        self._s3_api_key = config.get(S3_CONFIG_SECTION, 'api_key')%0A        self._s3_api_key_secret = config.get(S3_CONFIG_SECTION, 'api_key_secret')%0A    %0A    def download_obj(self, dst, obj_name):%0A        cls = get_driver(Provider.S3)%0A        driver = cls(self._s3_api_key, self._s3_api_key_secret)%0A        #object_name = os.path.basename(urllib2.unquote(obj_url).decode('utf8'))%0A        try:%0A            cloud_obj = driver.get_object(container_name=self._s3_bucket,%0A                                    object_name=obj_name)%0A        except ObjectDoesNotExistError:%0A            logging.info(%22Could not find object: %25s%22 %25 obj_name)%0A            exit(-1)%0A        logging.info('Downloading: %25s to %25s' %25 (cloud_obj.name, dst))%0A        cloud_obj.download(destination_path=dst)%0A%0A    def read_config_file(self, config_path):%0A        %22%22%22Parse the application's config file located at config_path.%22%22%22%0A        config = ConfigParser.SafeConfigParser()%0A        try:%0A            config.readfp(open(config_path))%0A        except IOError as e:%0A            print %22Failed to open config file at %22 + config_path + %22: %22 + e.strerror %0A            exit(-1)%0A        except Exception:%0A            print e.strerror %0A            exit(-1)%0A%0A        return config

Modify Pypo -> Download files from cloud storage