Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/instance.py
blob: 729bb5e37be6b8f51ffcdfd7ae2179dcabd07ef9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import os

from sugar import profile
from sugar import util
from sugar.activity import activity
import shutil

from color import Color
import record

class Instance:
	key = profile.get_pubkey()
	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
	tmpPath = None
	dataPath = None

	def __init__(self, ca):
		self.__class__.instanceId = ca._activity_id

		self.__class__.tmpPath = os.path.join(ca.get_activity_root(), "tmp")
		recreateTmp()

		self.__class__.dataPath = os.path.join(ca.get_activity_root(), "data")
		recreateInstance()


def recreateTmp():
	if (not os.path.exists(Instance.tmpPath)):
		os.makedirs(Instance.tmpPath)


def recreateData():
	if (not os.path.exists(Instance.dataPath)):
		os.makedirs(Instance.dataPath)