Kano Profile API documentation - KanoComputing/kano-profile GitHub Wiki
Kano-Profile API documentation
kano-profile-cli
To communicate with kano-profile you can use a command line tool: kano-profile-cli
or direct Python import if you are in Python. The Python import is recommended as it's faster.
load_profile
python: kano.profile.profile
load_profile()
Returns the main profile dict. Data in this dict include:
- kanoworld_id
- kanoworld_username
- save_date
- token
- username_linux
load_app_state_variable
cli: load_app_state_variable app_name variable value
python: kano.profile.apps
load_app_state_variable(app_name, variable)
returns a variable of app
if variable not found:
- cli returns
VARIABLE_NOT_FOUND
- Python returns none
save_app_state_variable
cli with dialog: save_app_state_variable app_name variable value
python with dialog: kano.profile.badges
save_app_state_variable_with_dialog(app_name, variable, value)
python without dialog: kano.profile.apps
save_app_state_variable(app_name, variable, value)
saves value to app's variable
increment_app_state_variable
cli with dialog: increment_app_state_variable app_name variable value
python with dialog: kano.profile.badges
increment_app_state_variable_with_dialog(app_name, variable, value)
python without dialog: kano.profile.apps
increment_app_state_variable(app_name, variable, value)
Increments an apps variable with the given value. If the variable has not been initialised it starts from 0.
set_unlocked
cli: unlock
, lock
python: kano.profile.profile
set_unlocked(True/False)
Unlocks/locks the profile.
is_registered
cli: is_registered
python: kano.world.functions
is_registered()
Returns whether the user has registered on kano-world.
has_token
cli: has_token
python: kano.world.functions
has_token()
Returns whether the user is logged in to kano-world.
get_mixed_username
cli: get_username
python: kano.world.functions
get_mixed_username()
Returns the kano-world username if the user is registered, linux username otherwise.
calculate_kano_level
cli: get_level
python: kano.profile.badges
calculate_kano_level()
Returns the user's kano-level (cli), or (kano-level, progress) tuple (Python).
calculate_xp
cli: get_xp
python: kano.profile.badges
calculate_xp()
Returns the user's xp.
get_avatar
cli: get_avatar
// to be implemented
Returns the user's avatar in 'avatar_category avatar' format (cli)
get_stats
cli: get_stats
Prints is_registered, get_avatar, get_xp, get_level, get_username, has_token in one function.
get_app_data_dir
cli: get_app_data_dir app_name
python: kano.profile.apps
get_app_data_dir(app_name)
get the full-path of data folder of app. Not used at the moment, data is stored in ...-content folders
get_email
cli: get_email
python: kano.profile.profile
load_profile()['email']
Returns the user's kano-world registered email address.
Cli:
- if email found: prints it and exits 0
- if email not found: prints error message and exits 1
Python:
You should check if 'email' in profile
or put it in a try-except block.
kano-sync
kano-sync
is a command line tool for syncing the kano-profile.
-s --silent
kano-sync
always logs in and if it cannot it launches the login-dialog. By adding -s
you make it silently fail.
--sync
--sync
does the profile data sync. This is small amount of data stored in JSON files and can be synced frequently.
--backup
--backup
backs up the users content folders. The folders folders are specified in the rules/app_profiles.json file
--restore
--restore
restores the users content folders. The folders folders are specified in the rules/app_profiles.json file.
Note: restore does not overwrite existing files.
kano-world-cli
// will be merged with kano-profile-cli in the future
--reset
Removes all profile information.
Login or Register (no argument)
Login or register
--list-shares
Deletes all shares of the user.
--delete-shares
Deletes all shares of the user.