Spade
Mini Shell
| Directory:~$ /proc/self/root/lib/python2.7/site-packages/certbot/plugins/ |
| [Home] [System Details] [Kill Me] |
�
���_c@s�dZddlZddlZddlmZddlmZddlmZddlm Z ddlm
Z
eje�Z
defd ��YZdS(
sPlugin storage class.i����N(tAny(tDict(terrors(t
filesystem(tost
PluginStoragecBsDeZdZd�Zd�Zd�Zd�Zd�Zd�ZRS(s4Class
implementing storage functionality for
pluginscCs1||_||_t|_d|_d|_dS(s�Initializes PluginStorage
object storing required configuration
options.
:param .configuration.NamespaceConfig config: Configuration object
:param str classkey: class name to use as root key in storage file
N(t_configt _classkeytFalset_initializedtNonet_datat_storagepath(tselftconfigtclasskey((s;/usr/lib/python2.7/site-packages/certbot/plugins/storage.pyt__init__s
cCs5tjj|jjd�|_|j�t|_dS(shInitializes
PluginStorage data and reads current state from the disk
if the storage json
exists.s.pluginstorage.jsonN( RtpathtjoinRt
config_dirRt_loadtTrueR (R
((s;/usr/lib/python2.7/site-packages/certbot/plugins/storage.pyt_initialize_storage
s
cCsi}d}y+t|jd��}|j�}WdQXWnbtk
r�}dj|jt|��}tjj|j�r�t j
|�tj|��q�nXyt
j|�}Wn[tk
r|s�t jd|j�q
dj|j�}t j
|�tj|��nX||_dS(s�Reads PluginStorage content from the
disk to a dict structure
:raises .errors.PluginStorageError: when unable to open or read the
file
ttrNs1Could not read PluginStorage data file: {0} : {1}s2Plugin
storage file %s was empty, no values loadeds$PluginStorage file {0} is
corrupted.(topenRtreadtIOErrortformattstrRRtisfiletloggerterrorRtPluginStorageErrortjsontloadst
ValueErrortdebugR(R
tdatatfiledatatfhteterrmsg((s;/usr/lib/python2.7/site-packages/certbot/plugins/storage.pyR(s,
cCs+|js.d}tj|�tj|��nytj|j�}WnDtk
r�}dj t
|��}tj|�tj|��nXyOtjt
j|jtjtjBtjBd�d��}|j|�WdQXWnJtk
r&}dj |jt
|��}tj|�tj|��nXdS(s�Saves PluginStorage
content to disk
:raises .errors.PluginStorageError: when unable to serialize the
data
or write it to the filesystem
s;Unable to save, no values have been added to
PluginStorage.s+Could not serialize PluginStorage data: {0}i�twNs4Could
not write PluginStorage data to file {0} : {1}(R RR
RR!R"tdumpsRt TypeErrorRRRtfdopenRRRtO_WRONLYtO_CREATtO_TRUNCtwriteR(R
R*t
serializedR)R(((s;/usr/lib/python2.7/site-packages/certbot/plugins/storage.pytsaveFs,
cCsS|js|j�n|j|jkr;i|j|j<n||j|j|<dS(s�Put
configuration value to PluginStorage
:param str key: Key to store the value to
:param value: Data to store
N(R RRR(R
tkeytvalue((s;/usr/lib/python2.7/site-packages/certbot/plugins/storage.pytputds
cCs(|js|j�n|j|j|S(s�Get configuration value from
PluginStorage
:param str key: Key to get value from the storage
:raises KeyError: If the key doesn't exist in the storage
(R RRR(R
R5((s;/usr/lib/python2.7/site-packages/certbot/plugins/storage.pytfetchqs
( t__name__t
__module__t__doc__RRRR4R7R8(((s;/usr/lib/python2.7/site-packages/certbot/plugins/storage.pyRs
(R;R"tloggingtacme.magic_typingRRtcertbotRtcertbot.compatRRt getLoggerR9RtobjectR(((s;/usr/lib/python2.7/site-packages/certbot/plugins/storage.pyt<module>s