Exemple #1
0
def upload_file(local_path, cloud_path, is_zipped):
    """
        LOCALPATH is the path of a file to upload

        CLOUDPATH is the path with the name of a new file in your cloud
    """
    if is_zipped:
        STORAGE.upload_zip_file(local_path, cloud_path)
    else:
        STORAGE.upload_file(local_path, cloud_path)
Exemple #2
0
def get_storage(local_path=None, redis_index=None):
    """Project global definition data store backend"""
    from config import STORAGE
    if STORAGE["Method"] == "local":
        return LocalStorage(path=local_path or STORAGE.get("LocalPath"))
    elif STORAGE["Method"] == "redis":
        return RedisStorage(index=redis_index or STORAGE.get("RedisIndex"),
                            redis_url=STORAGE.get("RedisURL"))
    else:
        raise ValueError("Invalid storage method")
Exemple #3
0
 def __init__(self, db_type = None):
     self.db_dir = STORAGE.get('DB_DIR')
     if not db_type:
         self.db_name = STORAGE.get('MAIN_DB')
     elif db_type.startswith('job'):
         self.db_name = STORAGE.get('JOB_DB')
     elif db_type.startswith('test'):
         self.db_name = 'test.sqlite'
     elif db_type.startswith('mem'):
         self.db_name = ':memory:'
         self.db_dir = ''
     db_path = os.path.join(self.db_dir, self.db_name)
     #print 'Using:',db_path
     self.db_conn = sqlite3.connect(db_path)
     self.db_curr = self.db_conn.cursor()
Exemple #4
0
def get_dir(cloud_path):
    """
    Prints cloud folder contents

    :param cloud_path: Specify folder to show contents

    Yandex root folder = '/'; Dropbox root folder ''
    """
    resp = STORAGE.get_dir(cloud_path)
    try:
        for item in resp.json()['entries']:
            click.secho(item['path_display'])
    except KeyError:
        for item in resp.json()['_embedded']['items']:
            click.secho(item['path'])
Exemple #5
0
def create_dir(cloud_path):
    print(STORAGE.create_cloud_dir(cloud_path))
Exemple #6
0
def upload_dir(local_path, cloud_path, is_zipped):
    if is_zipped:
        STORAGE.upload_zip_dir(local_path, cloud_path)
    else:
        STORAGE.upload_dir(local_path, cloud_path)
Exemple #7
0
def download_file(local_path, cloud_path):
    click.secho('Downloading...', fg='green')
    STORAGE.download_file(local_path, cloud_path)
    click.secho('Success', fg='green')