def upload(path, uid, package, version, typ, key): zipfilename = '%s-%s.zip' % (str(package), str(version)) zipfilepath = os.path.join('/tmp', zipfilename) zip_dir(path, zipfilepath) with open(zipfilepath) as f: buf = f.read() os.remove(zipfilepath) addr = get_frontend() rpcclient = RPCClient(addr, FRONTEND_PORT, uid, key) ret = rpcclient.request('upload', uid=uid, package=package, version=version, buf=buf, typ=typ) if ret: return True else: log_err('util', 'failed to upload, uid=%s, package=%s, version=%s, typ=%s' % (str(uid), str(package), str(version), str(typ))) return False
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
def upload(path, uid, package, version, typ, key): zipfilename = get_filename(package, version) zipfilepath = os.path.join('/tmp', zipfilename) zip_dir(path, zipfilepath) with open(zipfilepath) as f: buf = f.read() os.remove(zipfilepath) addr = _get_frontend() rpcclient = RPCClient(addr, FRONTEND_PORT, uid, key) ret = rpcclient.request('upload', uid=uid, package=package, version=version, buf=buf, typ=typ) if ret: return True else: log_err( 'util', 'failed to upload, uid=%s, package=%s, version=%s, typ=%s' % (str(uid), str(package), str(version), str(typ))) return False