diff options
Diffstat (limited to 'PrestametuVoz.activity/instance.py')
-rwxr-xr-x | PrestametuVoz.activity/instance.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/PrestametuVoz.activity/instance.py b/PrestametuVoz.activity/instance.py new file mode 100755 index 0000000..a4b1303 --- /dev/null +++ b/PrestametuVoz.activity/instance.py @@ -0,0 +1,48 @@ +import os + +from sugar import profile +from sugar import util +from sugar.activity import activity +import shutil + +from color import Color + +class Instance: + key = profile.get_pubkey() + if hasattr(util, '_sha_data'): + # sugar-0.82 and previous + keyHash = util._sha_data(key) + else: + keyHash = util.sha_data(key) + + keyHashPrintable = util.printable_hash(keyHash) + nickName = profile.get_nick_name() + + colorFill = Color() + colorFill.init_hex( profile.get_color().get_fill_color() ) + colorStroke = Color() + colorStroke.init_hex( profile.get_color().get_stroke_color() ) + + instanceId = None + instancePath = None + dataPath = None + + def __init__(self, ca): + self.__class__.instanceId = ca._activity_id + + self.__class__.instancePath = os.path.join(ca.get_activity_root(), "instance") + recreateTmp() + + self.__class__.dataPath = os.path.join(ca.get_activity_root(), "data") + recreateData() + + +def recreateTmp(): + if (not os.path.exists(Instance.instancePath)): + os.makedirs(Instance.instancePath) + + +def recreateData(): + if (not os.path.exists(Instance.dataPath)): + os.makedirs(Instance.dataPath) + |