# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import os import errno import logging from os.path import join, exists, abspath, dirname, expanduser from active_toolkit.options import Option from sugar_network.toolkit import sugar api_url = Option( 'url to connect to Sugar Network server API', default='http://api-devel.network.sugarlabs.org', short_option='-a', name='api-url') certfile = Option( 'path to SSL certificate file to connect to server via HTTPS') no_check_certificate = Option( 'do not check the server certificate against the available ' 'certificate authorities', default=False, type_cast=Option.bool_cast, action='store_true') local_root = Option( 'path to the directory to keep all local data', default=sugar.profile_path('network'), name='local_root') activity_dirs = Option(
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import os import logging from os.path import join, exists, isdir from pylru import lrucache from active_toolkit.options import Option from sugar_network.toolkit.rrd import Rrd from sugar_network.toolkit.collection import Sequence, PersistentSequence stats_root = Option('path to the root directory for placing stats', default='/var/lib/sugar-network/stats') stats_node_step = Option('step interval in seconds for node RRD databases', default=60 * 5, type_cast=int) stats_node_rras = Option( 'space separated list of RRAs for node RRD databases', default=[ 'RRA:AVERAGE:0.5:1:288', # one day with 5min step 'RRA:AVERAGE:0.5:3:672', # one week with 15min step 'RRA:AVERAGE:0.5:12:744', # one month with 1h step 'RRA:AVERAGE:0.5:144:732', # one year with 12h step 'RRA:AVERAGE:0.5:288:36600', # hundred years with 24h step ], type_cast=Option.list_cast,
import hashlib from os.path import join, exists, dirname from active_toolkit.options import Option from active_toolkit import enforce _XO_SERIAL_PATH = '/ofw/mfg-data/SN' _XO_UUID_PATH = '/ofw/mfg-data/U#' _NICKNAME_GCONF = '/desktop/sugar/user/nick' _COLOR_GCONF = '/desktop/sugar/user/color' _uid = None keyfile = Option( 'path to SSH private key file to authenticate user; public key file ' 'should have ".pub" suffif; if ommited, use key file generated by ' 'Sugar Shell', name='keyfile') def logger_level(): """Current Sugar logger level as --debug value.""" _LEVELS = { 'error': 0, 'warning': 0, 'info': 1, 'debug': 2, 'all': 2, } level = os.environ.get('SUGAR_LOGGER_LEVEL') return _LEVELS.get(level, 0)
ACCESS_SYSTEM = 64 ACCESS_LOCAL = 128 ACCESS_REMOTE = 256 ACCESS_LEVELS = ACCESS_SYSTEM | ACCESS_LOCAL | ACCESS_REMOTE ACCESS_NAMES = { ACCESS_CREATE: 'Create', ACCESS_WRITE: 'Write', ACCESS_READ: 'Read', ACCESS_DELETE: 'Delete', } index_flush_timeout = Option( 'flush index index after specified seconds since the last change', default=5, type_cast=int) index_flush_threshold = Option( 'flush index every specified changes', default=32, type_cast=int) index_write_queue = Option( 'if active-document is being used for the scheme with one writer ' 'process and multiple reader processes, this option specifies ' 'the writer\'s queue size', default=256, type_cast=int) def uuid(): """Generate GUID value.
# This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from gettext import gettext as _ from active_toolkit.options import Option webui = Option(_('start web application to serve Sugar Network content'), default=False, type_cast=Option.bool_cast, action='store_true') webui_host = Option(_('hostname to bind'), default='127.0.0.1', name='webui-host') webui_port = Option(_('address to listen for Web clients'), default=5000, type_cast=int, name='webui-port')
# You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import os import json import logging from xml.etree import cElementTree as ElementTree from os.path import join, exists from sugar_network.toolkit import http from active_toolkit.options import Option from active_toolkit import util, enforce obs_url = Option( 'OBS API url; the entire OBS related functionality makes sense only ' 'for master server', default='https://obs.sugarlabs.org') obs_project = Option( 'OBS project to use unattended building', default='base') obs_presolve_project = Option( 'OBS project to use with packagekit-backend-presolve', default='resolve') obs_presolve_path = Option( 'filesystem path to store presolved packages', default='/var/lib/presolve')
def __init__(self, *args, **kwargs): Activity.__init__(self, *args, **kwargs) self._webkit = None pythonpath = [] try: import webkit except ImportError: self.set_canvas(self._alert('PyWebKitGtk is not installed.')) return try: import M2Crypto except ImportError: self.set_canvas(self._alert('M2Crypto is not installed.')) return try: import gevent if gevent.version_info[0] < 1: raise ImportError() except ImportError: sys.path.insert(0, bin_packages) try: import gevent except ImportError: error = 'gevent-1.0 is not installed.' self.set_canvas(self._alert(error)) return pythonpath.append(bin_packages) pythonpath.append(site_packages) if 'PYTHONPATH' in os.environ: pythonpath.append(os.environ.get('PYTHONPATH')) os.environ['PYTHONPATH'] = ':'.join(pythonpath) returncode = subprocess.call([ 'sugar-network-client', 'graceful_start', '-DDD', '--hub-root', join(src_root), '--webui', '--lazy-open', ], env=os.environ) if returncode: error = 'Fail to start sugar-network-client. ' \ 'See log file for details.' self.set_canvas(self._alert(error)) return self._sn_plugin_started = False try: from jarabe.plugins import plugins, sn Option.seek('shell', [plugins]) Option.load([ '/etc/sweets.conf', '~/.config/sweets/config', sugar.profile_path('sweets.conf'), ]) self._sn_plugin_started = 'sn' in plugins.value except ImportError: pass self._client = IPCClient() self._subscription = self._client.subscribe() gobject.io_add_watch(self._subscription.fileno(), gobject.IO_IN | gobject.IO_HUP, self.__subscription_cb) self._webkit = webkit.WebView() self._webkit.show() scrolled = gtk.ScrolledWindow() scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled.set_shadow_type(gtk.SHADOW_NONE) scrolled.add(self._webkit) scrolled.show() self.set_canvas(scrolled) self._webkit.open(launcher_url)
# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from active_toolkit.options import Option host = Option( 'hostname to listen for incomming connections and ' 'using for publicly visible urls', default='localhost', name='host') port = Option( 'port number to listen incomming connections', default=8000, type_cast=int, name='port') keyfile = Option( 'path to SSL certificate keyfile to serve requests via HTTPS', name='keyfile') certfile = Option( 'path to SSL certificate file to serve requests via HTTPS', name='certfile') trust_users = Option(
# # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import os import logging import hashlib import tempfile from os.path import isfile, lexists, exists, dirname from active_toolkit.options import Option from active_toolkit import util tmpdir = Option( 'if specified, use this directory for temporary files; such files ' 'might take considerable number of bytes while downloading of ' 'synchronizing Sugar Network content', name='tmpdir') _logger = logging.getLogger('toolkit') def spawn(cmd_filename, *args): _logger.trace('Spawn %s%r', cmd_filename, args) if os.fork(): return os.execvp(cmd_filename, (cmd_filename, ) + args)