ulordapi¶
udfs¶
config¶
-
class
ulordapi.config.
Config
(*args, **kwargs)[source]¶ Bases:
dict
config class.Based on the dict.Update key-value,including subdict.
daemonCLI¶
errcode¶
-
ulordapi.errcode.
return_result
(errcode=0, reason=None, result=None)[source]¶ update errcode,reason,result and then return
Parameters: - errcode (int) – errcode
- reason (str/dict) – reason, change it to the dict and update original reason
- result (str/dict) – result, change it to the dict and update original result
Returns: errcode result
manage¶
-
class
ulordapi.manage.
Ads
(**kwargs)[source]¶ Bases:
ulordapi.manage.Resource
Advertisement.Viewer will get a few ulord from the author when they view it.
-
UPID
¶
-
amount
¶
-
body
¶
-
claimID
¶
-
date
¶
-
description
¶
-
id
¶
-
resource_type
¶
-
title
¶
-
userid
¶
-
views
¶
-
-
class
ulordapi.manage.
Content
(**kwargs)[source]¶ Bases:
ulordapi.manage.Resource
Content,viewer need to pay a few ulord to view.
-
UPID
¶
-
amount
¶
-
body
¶
-
claimID
¶
-
date
¶
-
description
¶
-
id
¶
-
resource
¶
-
resource_type
¶
-
title
¶
-
userid
¶
-
views
¶
-
-
class
ulordapi.manage.
Resource
(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Model
Resource table: create resource table
-
UPID
¶
-
amount
¶
-
body
¶
-
claimID
¶
-
date
¶
-
description
¶
-
id
¶
-
resource
¶
-
resource_type
¶
-
title
¶
-
userid
¶
-
views
¶
-
-
class
ulordapi.manage.
Tag
(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Model
tag table
-
id
¶
-
pre1
¶
-
pre2
¶
-
resource
¶
-
tagname
¶
-
-
class
ulordapi.manage.
User
(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Model
User table: create user database.
-
activity
¶
-
balance
¶
-
boughts
¶
-
cellphone
¶
-
email
¶
-
hash_password
(password)[source]¶ Hash user’s password and save hash result.
Parameters: password (str) – user’s password
-
id
¶
-
password_hash
¶
-
pay_password
¶
-
timestamp
¶
-
token
¶
-
username
¶
-
verify_password
(password)[source]¶ verify password
Parameters: password (str) – user’s password Returns: True or False.
-
wallet
¶
-
up¶
-
class
ulordapi.up.
UlordHelper
(appkey=None, ulord_secret=None)[source]¶ Bases:
object
a helper to request the ulord paltform
-
calculate_sign
(dt=None)[source]¶ encrypt the request data according to the secret
Parameters: dt (dict) – data need to be encrypted, Default is None Returns: Usign
-
checkisbought
(payer, claim_ids)[source]¶ query the personal balance from the ulord platform
Parameters: - payer (str) – payer wallet name
- claim_ids (list) – resource claim id
Returns: errcode.You can query from the errcode dict.
-
delete
(id, password)[source]¶ delete resource on the ulord-platform
Parameters: - id (int) – resource ulord-platform DB ID
- password (str) – user wallet password
Returns: errcode.You can query from the errcode dict.
-
get
(url)[source]¶ get from the ulord-platform
Parameters: url (str) – request’s url Returns: return result.You can query the errcode.
-
paytouser
(username)[source]¶ activity send some ulords to the user
Parameters: username (str) – user wallet name Returns: errcode.You can query from the errcode dict.
-
post
(url, data)[source]¶ post to the ulord-platform
Parameters: - url (str) – request’s url
- data (dict) – post data
Returns: return result.you can query the errcode
-
publish
(data)[source]¶ publish data to the ulord platform
Parameters: data (dict) – data needed to be published.Key includes author,title,tags,udfs_hash,price,content_type,des,pay_password Returns: errcode.You can query from the errcode dict.
-
queryBillingDetailByID
(claim_id, page=1, num=10)[source]¶ query all billing details according to the claimID
Parameters: - claim_id (str) – resource on the ulord-chain ID
- page (int) – which page of result do you want to view?Default is 1.
- num (int) – how many pieces of data of result do you want to view?Default is 10.
Returns: errcode.You can query from the errcode dict.
-
queryStatisticsByID
(claim_ids)[source]¶ query resource statistics information by ID
Parameters: claim_ids (list) – need to be query ID list. Returns: errcode.You can query from the errcode dict.
-
query_resourc_by_ID
(ids)[source]¶ query resource list according to the id list
Parameters: ids (list) – need to be query id list Returns: errcode.You can query from the errcode dict.
-
querybalance
(payer, pay_password)[source]¶ query the personal balance from the ulord platform
Parameters: - payer (str) – payer wallet name
- pay_password (str) – payer wallet password
Returns: errcode.You can query from the errcode dict.
-
querybillings
(username, start, end)[source]¶ get billings info
Parameters: - username (str) – current user wallet name
- start (str) – start time.2018-03-29
- end (str) – end time.2018-03-29
Returns: errcode.You can query from the errcode dict.
-
querybillingsdetail
(author, page=1, num=10)[source]¶ query the billings detail.Union the income and outgo
Parameters: - author (str) – current user wallet name
- page (int) – which page of result do you want to view?Default is 1.
- num (int) – how many pieces of data of result do you want to view?Default is 10.
Returns: errcode.You can query from the errcode dict.
-
queryincomebillings
(author, start, end, page=1, num=10, category=2)[source]¶ get income billings info
Parameters: - author (str) – current user wallet name
- start (str) – start time.2018-03-29
- end (str) – end time.2018-03-29
- page (int) – which page of result do you want to view?Default is 1.
- num (int) – how many pieces of data of result do you want to view?Default is 10.
- category (int) – resource type. 0—-common resource,1—-ads,2—–all
Returns: errcode.You can query from the errcode dict.
-
queryoutgobillings
(author, start, end, page=1, num=10, category=2)[source]¶ get outgo billings info
Parameters: - author (str) – current user wallet name
- start (str) – start time.2018-03-29
- end (str) – end time.2018-03-29
- page (int) – which page of result do you want to view?Default is 1.
- num (int) – how many pieces of data of result do you want to view?Default is 10.
- category (int) – resource type. 0—-common resource,1—-ads,2—–all
Returns: errcode.You can query from the errcode dict.
-
querypublishnum
(author, start, end)[source]¶ query the number of resourced which has published
Parameters: - author (str) – current user wallet name
- start (str) – start time.2018-03-29
- end (str) – end time.2018-03-29
Returns: errcode.You can query from the errcode dict.
-
queryresource
(page=1, num=10, **kwargs)[source]¶ query the resource list from the ulord platform.method is get
Parameters: - page (int) – which page do you want to view?Default is 1.
- num (int) – how many pieces of datas in one page?.Default is 10.
- kwargs (key-value) – key-value query
Returns: errcode.You can query from the errcode dict.
-
queryuserpublished
(wallet_username, page=1, num=10)[source]¶ query user published from ulort platform
Parameters: - wallet_username (str) – auther wallet name
- page (int) – which page of result do you want to view?Default is 1.
- num (int) – how many pieces of data of result do you want to view?Default is 10.
Returns: errcode.You can query from the errcode dict.
-
regist
(username, password)[source]¶ regist wallet address from the ulord platform
Parameters: - username (str) – wallet name
- password (str) – wallet password
Returns: errcode.You can query from the errcode dict
-
transaction
(payer, claim_id, pay_password, isads=False)[source]¶ record the transaction to the ulord platform
Parameters: - payer (str) – payer wallet name
- claim_id (str) – resource claim id
- pay_password (str) – payer wallet password
- isads (bool) – check the resource if a Ad.
Returns: errcode.You can query from the errcode dict.
-
user¶
-
class
ulordapi.user.
Developer
(appkey, secret)[source]¶ Bases:
ulordapi.up.UlordHelper
basic develoer class to execute some functions
-
config_edit
(args=None)[source]¶ config operations
Parameters: args (list/dict) – a list or a dict.Update config Returns: args dict
-
config_show
(args=None)[source]¶ show config.Default show all.
Parameters: args (list/dict) – keys Returns: config according to the keys
-
decrypt
(args)[source]¶ check if the arg is encrypted.If encrypted return decrypted arg,else return None.
Parameters: args (str/str list) – arg need to be checked, Returns: decrypted arg or arg(unicode)
-
request
(method, url, data=None)[source]¶ advanced command. request to the ulord-platform
Parameters: - method (str) – request method,like post,get and so on.
- url (str) – request url
- data (dict) – request data
Returns: return result.you can query the errcode
-
udfs_cat
(udfshashs)[source]¶ view the udfs hash comment
Parameters: udfshashs (list) – udfs hashes Returns: dict udfshash - True/False
-
-
class
ulordapi.user.
Junior
(appkey, secret)[source]¶ Bases:
ulordapi.user.Developer
Junior programmer to develop his application.Using default database.
-
create_database
(path=None)[source]¶ create database
Parameters: path (str) – database path.Warining:It’a a dir Returns: True/False
-
pay_ads
(wallet, claim_id, authername)[source]¶ user view ads
Parameters: - wallet (str) – user wallet name
- claim_id (str) – resource claim id
- authername (str) – resource auther name
Returns: errcode.You can query from the errcode.
-
pay_resources
(payer, claim_id, password, encrypted=False)[source]¶ user pay resource
Parameters: - payer (User) – payer
- claim_id (str) – resource claim id
- password (str) – payer password
Returns: errcode.You can query from the errcode.
-
query
(sql)[source]¶ advanced command self query
Parameters: sql (str) – sql sentence Returns: query result
-
resouce_views
(claim_id)[source]¶ add resource view
Parameters: claim_id (str) – resource claim_id Returns: resource current view
-
resource_publish
(title, udfshash, amount, tags, des, usercondition)[source]¶ user publish resource
Parameters: - title (str) – resource title
- udfshash (str) – resource uplorded to the UDFS hash
- amount (float) – resource price
- tags (list) – resource tag
- des (str) – resource description
- usercondition (dict) – a condition which need to query user
Returns: errcode.You can query from the errcode.
-
resource_update
(id, pay_password, encrypted=True, title=None, body=None, price=None, tags=None, des=None)[source]¶ user update data to the ulord-platform
Parameters: - id (str) – data id
- pay_password (str) – auther wallet pay password
- encrypted (bool) – if encrypt password
- title (str) – resource title
- body (str) – resource
- price (float) – resource price
- tags (list) – resource tags
- des (str) – resource description
Returns: errcode.You can query from the errcode.
-
user_activity
(token=None, username=None)[source]¶ activity.App developer send some ulords to the user.
Parameters: - token (str) – user token
- username (str) – user name
Returns: True or False.
-
user_info_query
(username=None, token=None)[source]¶ user information
Parameters: - username (str) – username.Default is none.
- token (str) – user token.Default is none.
Returns: dict.User info
-
user_infor_modify
(password, username=None, token=None, encrypted=False, cellphone=None, email=None, new_password=None)[source]¶ - user information
Parameters: - username (str) – username.Default is none.
- token (str) – user token.Default is none.
- encrypted (bool) – if encrypted password.If ture,all password will be decrypted.
- password (str) – user passowrd to confirm account
- cellphone (str) – user new cellphone
- email (str) – user new email
- new_password (str) – user new password
Returns: dict.User info
-
user_login
(username, password, encrypted=False)[source]¶ user login
Parameters: - username (str) – user name
- password (str) – user password
- encrypted (bool) – check if the password is encrypted
Returns: user token
-
user_logout
(token=None, username=None)[source]¶ user logout.Change user’s timestamp
Parameters: - token (str) – user token
- username (str) – user name
Returns: username or errcode.You can query the errcode dict.
-
user_regist
(username, password, cellphone=None, email=None, wallet=None, pay_password=None, encrypted=False)[source]¶ user regist
Parameters: - username (str) – user name
- password (str) – user password
- cellphone (str) – user cellphone.Default is None.
- email (str) – user email.Default is None.
- wallet (str) – user wallet name.Default is username.
- pay_password (str) – user wallet password.Default is hash password.
- encrypted (bool) – check if the password encrypted
Returns: user token
-
-
class
ulordapi.user.
Senior
(appkey, secret)[source]¶ Bases:
ulordapi.user.Developer
Senior programmer to develop his application.
utils¶
-
class
ulordapi.utils.
FileHelper
[source]¶ file helper to operate the files
-
changeName
(originalname, newname)[source]¶ change file name from a hash to filename
Parameters: - originalname (str) – a file path, old file name.
- newname (str) – a file path, new file name.
Returns: True or False
-
getName
(filename)[source]¶ get file name,including type
Parameters: filename (str) – a file path Returns: file name
-
getPureName
(filename)[source]¶ get file name.Doesn’t contain type.
Parameters: filename (str) – a file path Returns: file name
-
mergeFile
(filepath, chunks)[source]¶ merge chunks into a file.Used for the multi-threading download
Parameters: - filepath (str) – a file path.Final file.
- chunks (list) – chunk path list
Returns: True or False
-
-
ulordapi.utils.
ListToDict
(args)[source]¶ change a list to dict
Parameters: args (list) – a list Returns: dict >>> a = [1,2,3,4] >>> print(ListToDict(a)) {1: {2: {3: 4}}}
-
class
ulordapi.utils.
RSAHelper
(public_path, private_path)[source]¶ Bases:
object
rsa helper.Create private key and public key.
-
decrypt
(prikey, message)[source]¶ using private key to decrypt message
Parameters: - prikey (Crypto.PublicKey.RSA.RsaKey) – private key
- message (str) – need to be decrypted
Returns: decrypted message
-
-
ulordapi.utils.
Update
(orgin_dict, dict_father)[source]¶ update dict dict_father to dict orgin_dict
Parameters: - orgin_dict (dict) – base dict
- dict_father (dict) – need to update
Returns: dict orgin_dict which updates orgin_dict
In [8]: dictb = { ...: "t":2, ...: "ttt":{ ...: "123":1, ...: "a":2 ...: } ...: ...: } In [9]: dicta = { ...: "test": 1, ...: "ttt":{ ...: "a":1 ...: } ...: } In [10]: Update(dictb, dicta) Out[10]: {'t': 2, 'test': 1, 'ttt': {'123': 1, 'a': 1}}
-
ulordapi.utils.
generateMD5
(value)[source]¶ generate value’s md5
Parameters: value (str) – need to encrypt Returns: value’s md5 or “”
-
ulordapi.utils.
isCellphone
(number)[source]¶ check if a cellphone
Parameters: number (str) – cellphone Returns: True of False
-
ulordapi.utils.
isMail
(mail)[source]¶ check if a mail
Parameters: mail (str) – mail Returns: True of False
-
ulordapi.utils.
isUdfsHash
(udfshash)[source]¶ check the string if a udfs hash simple check, TODO advanced check
Parameters: udfshash (str) – a string Returns: True or False
version¶
webServer¶
-
ulordapi.webServer.
add_views
()[source]¶ add views according to the resource’s title
Returns: current views
-
ulordapi.webServer.
blog_delete
()[source]¶ delete blog :return: errcode.You can query from the errcode dict.
-
ulordapi.webServer.
check_bought
()[source]¶ check the resource if has been bought
Returns: if has bought return resource hash,if not existed return null,if hasn’t bought return none.