cup.storage package

init for cup.storage

Submodules

cup.storage.obj module

description:

Object related storage

class cup.storage.obj.AFSObjectSystem(config)[source]

Bases: ObjectInterface

AFSObjectSystem implemented interface.

delete(path)[source]

delete a file

Parameters:

path – object path

Returns:

{
    'returncode': 0 for success, others for failure,
    'msg': 'if any'
}

get(path, localpath)[source]

get the object into localpath

Returns:

{
    'returncode': 0 for success, others for failure,
    'msg': 'if any'
}

head(path)[source]

get the object info

Returns:

{
    'returncode': 0 for success, others for failure,
    'msg': 'if any'
    'objectinfo': {
    size: 1024,
    .......
    }
}

mkdir(path)[source]

mkdir dir of a path

Returns:

{
    'returncode': 0 for success, others for failure,
    'msg': 'if any'
    'objectinfo': {
    size: 1024,
    .......
    }
}

put(dest, localfile)[source]
Parameters:
  • dest – system path

  • localfile – localfile

Returns:

{

‘returncode’: 0 for success, others for failure, ‘msg’: ‘if any’

}

rename(frompath, topath)[source]
rmdir(path)[source]

rmdir of a path

class cup.storage.obj.FTPObjectSystem(config)[source]

Bases: ObjectInterface

ftp object system, Plz notice all methods of FTPObjectSystem is NOT thread-safe! Be careful when you use it in a service of concurrency.

delete(path)[source]

delete file

get(path, localpath)[source]

get a file into localpath

head(path)[source]

get the file info

Returns:

{
    'returncode': 0 for success, others for failure,
    'msg': 'if any'
    'fileinfo': [
        "-rw-rw-r-- 1 work work   201 Nov  9 17:03 __init__.py"
    ]
}

is_file(path)[source]

path is file or not

mkdir(path, recursive=True)[source]
put(destfile, localfile)[source]
Parameters:
  • destfile – ftp path for the localfile

  • localfile – localfile

rename(frompath, topath)[source]

rename frompath to path

rmdir(path, recursive=True)[source]
class cup.storage.obj.LocalObjectSystem(kvconfig=None)[source]

Bases: ObjectInterface

local object system

delete(path)[source]

delete a file in local

get(path, localpath)[source]

get a file into localpath

head(path)[source]

get the object info

mkdir(path, recursive=True)[source]
put(dest, localfile)[source]

local object put == copy

rename(frompath, topath)[source]

rename from path to path

rmdir(path, recursive=True)[source]
class cup.storage.obj.S3ObjectSystem(config)[source]

Bases: ObjectInterface

s3 object system

create_bucket(bucket_name)[source]

create bucket

delete(path)[source]

delete a file

Parameters:

path – object path

Returns:

{

‘returncode’: 0 for success, others for failure, ‘msg’: ‘if any’

}

delete_bucket(bucket_name, forcely=False)[source]

delete bucket

Parameters:

forcely

if forcely is True, the bucket will be delete no matter it has

objects inside. Otherwise, you have to delete items inside, then delete the bucket

get(path, localpath)[source]

get the object into localpath

Returns:

{

‘returncode’: 0 for success, others for failure, ‘msg’: ‘if any’

}

head(path)[source]

get the object info

Returns:

{
    'returncode': 0 for success, others for failure,
    'msg': 'if any'
    'objectinfo': {
        size: 1024,
        .......
    }
}

head_bucket(bucket_name)[source]

create bucket

mkdir(path)[source]

mkdir dir of a path

Returns:

{
    'returncode': 0 for success, others for failure,
    'msg': 'if any',
    'objectinfo': {
        size: 1024,
        ..
    }
}

put(dest, localfile)[source]
Parameters:
  • dest – system path

  • localfile – localfile

Returns:

{
    'returncode': 0 for success, others for failure,
    'msg': 'if any'
}

rename(frompath, topath)[source]
rmdir(path)[source]

rmdir of a path