Esempio n. 1
0
File: upload.py Progetto: llfde/dpm
def upload(name, username, password, version, src, src_type):
    zipfilename = '%s-%s.zip' % (name, version)
    zipfilepath = os.path.join('/tmp', zipfilename)
    zip_dir(src, zipfilepath)
    
    parent_path =  os.path.dirname(src)
    with open(zipfilepath) as f:
        buf = f.read()
    
    # delete the zip file 
    os.remove(zipfilepath)
    
    rpcclient = RPCClient('127.0.0.1', 9001)
    ret  = rpcclient.request('upload', [username], {'name':name, 'version':version, 'src_type':src_type, 'buf':buf})
    if ret:
        return True
    return False
Esempio n. 2
0
def download_src(username, src_name, src_type):   
    rpcclient = RPCClient('127.0.0.1', 9001)
    ret  = rpcclient.request('download_src', [username], {'src_name':src_name, 'src_type':src_type})
    
    tmp_name = make_tmp_name()
    if not os.path.isdir(TMP_DIR):
        os.makedirs(TMP_DIR)
    tmpdir_path = os.path.join(TMP_DIR, tmp_name)
    if not os.path.isdir(tmpdir_path):os.mkdir(tmpdir_path)
    src_path = os.path.join(tmpdir_path, src_name)  
    print 'install.download_src() is : %s' % src_path  
    with open(src_path, 'wb') as f:
        f.write(ret)
    
    res_src_name = src_name[:-4]
    res_src_path = os.path.join(tmpdir_path, res_src_name)
    unzip_file(src_path, res_src_path)
    
    if ret:
        return res_src_path
    return None
Esempio n. 3
0
File: install.py Progetto: llfde/dpm
def download_src(username, src_name, src_type):
    rpcclient = RPCClient('127.0.0.1', 9001)
    ret = rpcclient.request('download_src', [username], {
        'src_name': src_name,
        'src_type': src_type
    })

    tmp_name = make_tmp_name()
    if not os.path.isdir(TMP_DIR):
        os.makedirs(TMP_DIR)
    tmpdir_path = os.path.join(TMP_DIR, tmp_name)
    if not os.path.isdir(tmpdir_path): os.mkdir(tmpdir_path)
    src_path = os.path.join(tmpdir_path, src_name)
    print 'install.download_src() is : %s' % src_path
    with open(src_path, 'wb') as f:
        f.write(ret)

    res_src_name = src_name[:-4]
    res_src_path = os.path.join(tmpdir_path, res_src_name)
    unzip_file(src_path, res_src_path)

    if ret:
        return res_src_path
    return None