prefs¶
Module to hold module-global variables as preferences.
Warning
DO NOT hardcode prefs here.
A prefs.json file should be generated with an appropriate autopilot.setup
routine
Before importing any other autopilot module,
Examples
from autopilot import prefs prefs_file = ‘~/autopilot/prefs.json’ # or some .json prefs file prefs.init(prefs_file)
And to add a pref
Examples
prefs.add(‘PARAM’, ‘VALUE”)
Data:
stores a dictionary of preferences that mirrors the global variables. |
Functions:
|
Initialize prefs on autopilot start. |
|
Add a pref after init |
|
Get the git hash of the current commit. |
|
|
-
prefdict
= {'AGENT': 'docs', 'AUDIOSERVER': 'docs', 'AUTOPILOT_ROOT': '/home/docs/checkouts/readthedocs.org/user_builds/auto-pi-lot/checkouts/v0.3.3/autopilot'}¶ stores a dictionary of preferences that mirrors the global variables.
-
init
(fn=None)[source]¶ Initialize prefs on autopilot start.
- Parameters
fn (str, dict) – a path to prefs.json or a dictionary of preferences
-
add
(param, value)[source]¶ Add a pref after init
- Parameters
param (str) – Allcaps parameter name
value – Value of the pref
-
git_version
(repo_dir)[source]¶ Get the git hash of the current commit.
Stolen from numpy’s setup
and linked by ryanjdillon on SO
- Parameters
repo_dir (str) – directory of the git repository.
- Returns
git commit hash.
- Return type
unicode