-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSPConstants.py
152 lines (125 loc) · 5 KB
/
SPConstants.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# -*- coding: utf-8 -*-
# Copyright (c) 2006-2011 Stas Zykiewicz <[email protected]>
#
# SPConstants.py
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 3 of the GNU General Public License
# as published by the Free Software Foundation. A copy of this license should
# be included in the file GPL-3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Set the NoGtk constants to True if you don't want to use gtk stuff.
NoGtk = True
# Set this to which dbase we use.
# Currently these are supported: 'sqlite' and 'mysql'
WHICHDBASE = 'sqlite'
# Set the default milestone for the mail tickets script
MILESTONE = 'BT2.3'
# DON'T CHANGE ANYTHING BELOW THIS LINE !!!!
# If you want to change the paths, change SPBasePaths.py
import sys
import SPBasePaths
import logging
import os
import time
import shutil
import pygame
import glob
SPCmodule_logger = logging.getLogger("childsplay.SPConstants")
# module_logger.debug("Contents of os.environ: %s" % os.environ)
# module_logger.debug("Contents of sys.argv %s " % sys.argv)
from SPColors import *
# Import keymaps as they are now in a seperate module.
from SPKeyMaps import KeyMaps
# Which themes do we have?
SUPPORTEDTHEMES = ['default', 'childsplay', 'cognitionplay', 'seniorplay', 'braintrainer']
# Which keymaps do we have?
SUPPORTEDKEYMAPS = KeyMaps.supportedmaps
# The base of the schoolsplay installation, only used on win98?
BASEDIR = SPBasePaths.BASEDIR
# here are the activities data directories installed
ACTIVITYDATADIR = SPBasePaths.SHARELIBDATADIR
# gettext mo files location
LOCALEDIR = SPBasePaths.LOCALEDIR
# Localized soundfiles
ALPHABETDIR = SPBasePaths.ALPHABETDIR
WWWDIR = SPBasePaths.WWWDIR
GUITHEMESPATH = os.path.join(ACTIVITYDATADIR, 'SPData', 'gui', 'themes')
DEFAULTGUITHEMESPATH = os.path.join(GUITHEMESPATH, 'default')
THEMESPATH = os.path.join(ACTIVITYDATADIR, 'SPData', 'themes')
DEFAULTTHEMESPATH = os.path.join(THEMESPATH, 'default')
CORESOUNDSDIR = os.path.join(ACTIVITYDATADIR, 'SPData', 'base', 'sounds')
ACTDATADIR = os.path.join(ACTIVITYDATADIR, 'CPData')
# Users sp dir
HOME_DIR_NAME = '.schoolsplay.rc'
# Name of the SQLite users dbase
DBASE = 'sp_users.db'
# name of the SQLite content dbase
CONTENTDBASE = 'sp_content.db'
# language
LANG = 'en'
LOCALE_RTL = None
# Check if there's a schoolsplay dir in the home directory
if sys.platform == 'win32':
PLATFORM = 'win32'
try:
HOMEDIR = os.path.join(os.environ['HOMEDRIVE'], os.environ['HOMEPATH'], HOME_DIR_NAME)
except:
# for win 98 ??
HOMEDIR = os.path.join(BASEDIR, HOME_DIR_NAME)
if not os.path.exists(HOMEDIR):
os.makedirs(HOMEDIR)
else:
PLATFORM = 'All your platform are belong to us'
if os.path.exists('/data/userdata'): # BTP production machine
HOMEDIR = os.path.join('/data/userdata', HOME_DIR_NAME)
else:
try:
HOMEDIR = os.path.join(os.environ['HOME'], HOME_DIR_NAME)
except KeyError as info:
print(info)
HOMEDIR = os.path.abspath(sys.path[0])
# Create a schoolsplay directory and subdirectories.
START_POSTPULL = 1
if not os.path.exists(HOMEDIR):
os.makedirs(HOMEDIR)
ppl = ["%s\n" % f for f in glob.glob(os.path.join(BASEDIR, 'post_pull', '*.sh'))]
ppl.sort()
START_POSTPULL = len(ppl)
f = open(os.path.join(HOMEDIR, 'post_pull'), 'w')
f.writelines(ppl)
f.close()
PSYCOPATH = os.path.join(HOMEDIR, 'schoolsplay_psyco.log')
DBASEPATH = os.path.join(HOMEDIR, DBASE)
TEMPDIR = os.path.join(HOMEDIR, 'tmp')
if os.path.exists(TEMPDIR):
shutil.rmtree(TEMPDIR)
os.makedirs(TEMPDIR)
os.chmod(TEMPDIR, 0o777)
os.makedirs(os.path.join(TEMPDIR, 'birthday'))
os.chmod(os.path.join(TEMPDIR, 'birthday'), 0o777)
BASEPATH = os.getcwd()
# lockfile path used to set a lock to prevent multiple instances of childsplay
LOCKFILE = os.path.join(HOMEDIR, '.splock')
HOMEIMAGES = os.path.join(HOMEDIR, 'my_images')
# set font path and fontsize
TTFSIZE = 19 # used for default ttf
TTF = os.path.join(ACTIVITYDATADIR, 'SPData', 'base', 'DejaVuSansCondensed-Bold.ttf')
TTFBOLD = os.path.join(ACTIVITYDATADIR, 'SPData', 'base', 'DejaVuSansCondensed-Bold.ttf')
if os.path.exists(TTF):
# default size for DejaVuSansCondensed
TTFSIZE = 12
# [6, 94, 182, 270, 358, 446, 534, 622, 710]
CORE_BUTTONS_XCOORDS = list(range(6, 800, 91))
SPLC_TIMESTAMP = time.strftime("%y-%m-%d_%H-%M-%S", time.localtime())
IMAGE_EXT_PATTERN = ['*.jpg', '*.JPG', '*.jpeg', '*.png', '.*tiff', '*.gif', '*.bmp']
IMAGE_EXT = ['.jpg', '.JPG', '.jpeg', '.png', '.tiff', '.gif', '.bmp']
XML_FILES_WE_MUST_HAVE = ["SP_menu.xml"]
BUTTON_FEEDBACK_TIME = 200