ulordapi.udfs

udfs

class ulordapi.udfs.udfs.Udfs[source]

udfs class,including some operations about daemon program

get_pid()[source]

get daemon pid

Returns:daemon pid
get_udfs()[source]

get udfs path according to the os

Returns:udfs path
modify_config()[source]

modify udfs config

start(daemon=None)[source]

start udfs.if daemon is true, the udfs is a daemon,else the udfs is starting the current thread.

Parameters:daemon (bool) – if wait
start_command(cmd)[source]

start external command

Parameters:cmd (str/list) – shell command
Returns:popen
start_init()[source]

init udfs, sleep 3 microsecond to wait the command finished.

stop()[source]

kill the udfs daemon

class ulordapi.udfs.udfs.UdfsHelper(host='127.0.0.1', port='5001')[source]

download and upload files from Ulord

cat(udfshash)[source]

Retrieves the contents of a file identified by hash. :param udfshash: udfs hash :type udfshash:str :return: str(File contents)

downloadfile(localfile)[source]

query the localfile from DB and then download from the udfs

Parameters:localfile (str) – a file path
Returns:True os False
downloadhash(filehash, filepath=None, Debug=False)[source]

download file from the UDFS according to the udfs hash

Parameters:
  • filehash (str) – file udfs hash
  • filepath (str) – the path to save the file
  • Debug (bool) – if Debug print the cost time
Returns:

True or False

list(filehash)[source]

list the udfshash chunks

Parameters:filehash (str) – a udfs hash
Returns:a list chunks of the udfs hash
resumableDownload(filehash, filename=None)[source]

resumable download

Parameters:
  • filehash (str) – file UDFS hash
  • filename (str) – file path to save the file
Returns:

True or False

update(host='127.0.0.1', port='5001')[source]

update udfs dameon connection

Parameters:
  • host (str) – udfs daemon host
  • port (str/int) – udfs daemon port
upload_file(local_file)[source]

upload the file to the udfs

Parameters:local_file (str) – a local file path
Returns:Hash or False
upload_stream(stream)[source]

upload the stream to the ulord

Parameters:stream (unicode) – stream data
Returns: