Web · Wiki · Activities · Blog · Lists · Chat · Meeting · Bugs · Git · Translate · Archive · People · Donate

Commit 8cbaa8059b39256f7b6be01beb64580176b0db95

Make possible to run from command line again. Ninja IDE project file.
  
1# Copyright (C) 2012, Sebastian Silva
1# Copyright (C) 2012, Sebastian Silva
22#
33# This program is free software: you can redistribute it and/or modify
44# it under the terms of the GNU General Public License as published by
app/app.py
(1 / 1)
  
2929import simplejson
3030
3131from sugar_network import sugar
32from .client import Client
32from client import Client
3333
3434_BUFFER_SIZE = 1024 * 10
3535
  
161161 a dictionary of properties to filter resulting list
162162
163163 """
164 from .cursor import Cursor
164 from cursor import Cursor
165165 return Cursor(self.mountpoint, self.document, query, order_by, reply,
166166 page_size, **filters)
167167
  
1717import collections
1818
1919from active_toolkit import coroutine, util, enforce
20from .objects import Object
21from .client import Client
20from objects import Object
21from client import Client
2222
2323
2424_QUERY_PAGES_NUMBER = 2
  
11# -*- coding: utf-8 -*-
2# Copyright (C) 2012, Sebastian Silva
2# Copyright (C) 2012, Sebastian Silva
33#
44# This program is free software: you can redistribute it and/or modify
55# it under the terms of the GNU General Public License as published by
1414# You should have received a copy of the GNU General Public License
1515# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
17from .client import Client
17from client import Client
1818
1919class Mount:
2020 def __init__(self, mountpoint, keep_impl=None):
  
1919
2020from sugar_network.toolkit import sugar
2121from active_toolkit import enforce
22from .client import Client
22from client import Client
2323
2424
2525_logger = logging.getLogger('sugar_network.objects')
  
1from os.path import join, abspath, exists
2from sugar_network import toolkit, local, node
3from sugar_network.toolkit import sugar, sneakernet
4from sugar_network.local.mounts import HomeMount, RemoteMount
5from sugar_network.local.mountset import Mountset
6from sugar_network.resources.volume import Volume
7from active_toolkit import util, printf, application, coroutine, enforce
8import gevent
9
10def _mountset():
11 toolkit.ensure_dsa_pubkey(sugar.profile_path('owner.key'))
12
13 _db_path = join(local.local_root.value, 'local')
14 volume = Volume(_db_path, lazy_open=local.lazy_open.value)
15 mountset = Mountset(volume)
16 mountset['~'] = HomeMount(volume)
17 mountset['/'] = RemoteMount(volume)
18
19 return mountset
20
21mountset = _mountset()
22
23import sugar_network_webui as webui
24
25from gevent.wsgi import WSGIServer
26
27host = '0.0.0.0' # '0.0.0.0' for all
28http_server = WSGIServer((host, 5000), webui.get_app(mountset))
29
30import webbrowser
31webbrowser.open_new_tab('localhost:5000')
32http_server.serve_forever()
  
1#!/usr/bin/env python
2
3# Copyright (C) 2012, Aleksey Lim
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18import sys
19from os.path import dirname, join, realpath
20from gettext import gettext as _
21
22from gevent.wsgi import WSGIServer
23from sugar_network import application, optparse, sugar
24
25
26SRC_ROOT = dirname(realpath(__file__))
27
28
29host = optparse.Option(
30 _('address to listen for Web clients'),
31 default='127.0.0.1')
32
33port = optparse.Option(
34 _('address to listen for Web clients'),
35 default=5000)
36
37
38class Application(application.Daemon):
39
40 httpd = None
41
42 def start(self):
43 application.logdir.value = sugar.profile_path('logs')
44 application.rundir.value = sugar.profile_path('run')
45 application.Daemon.start(self)
46
47 def run(self):
48 app = self._get_app()
49 self.httpd = WSGIServer((host.value, port.value), app)
50 self.httpd.serve_forever()
51
52 def shutdown(self):
53 if self.httpd is not None:
54 self.httpd.stop()
55
56 @application.command(_('Run application in debug mode'))
57 def debug(self):
58 app = self._get_app()
59 app.debug = True
60 app.run(host=host.value, port=port.value)
61
62 def _get_app(self):
63 try:
64 from mejorar_sistema.app import app
65 except ImportError:
66 # Reuse from sources diretory
67 sys.path.insert(0, join(SRC_ROOT, 'app'))
68 from app import app
69 return app
70
71
72optparse.Option.seek('mejorar-sistema')
73optparse.Option.seek('mejorar-sistema',
74 [application.debug, application.foreground])
75
76app = Application(
77 name='mejorar-sistema',
78 description=_('Flask server to serve Sugar Network users'),
79 epilog=_('See http://wiki.sugarlabs.org/go/Platform_Team/' \
80 'Sugar_Network/Browser.'),
81 config_files=[
82 '/etc/sweets.conf',
83 '~/.config/sweets/config',
84 sugar.profile_path('sweets.conf'),
85 ])
86app.start()
  
1{
2 "mainFile": "interactive.py",
3 "venv": "",
4 "relatedProjects": [],
5 "name": "Red Az\u00facar",
6 "license": "GNU General Public License v3",
7 "url": "http://localhost:5000/",
8 "pythonPath": "python",
9 "preExecScript": "/usr/bin/sugar-network-service debug",
10 "programParams": "",
11 "PYTHONPATH": "",
12 "supported-extensions": [
13 ".py",
14 ".html",
15 ".jpg",
16 ".png",
17 ".ui",
18 ".css",
19 ".json",
20 ".js",
21 ".ini"
22 ],
23 "project-type": "Import from sources",
24 "postExecScript": "",
25 "description": ""
26}
  
1#!/usr/bin/env python
2
3# Copyright (C) 2012, Aleksey Lim
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18import sys
19import optparse
20from os.path import dirname, join, realpath
21from gettext import gettext as _
22
23from gevent.wsgi import WSGIServer
24from sugar_network import sugar
25
26
27SRC_ROOT = dirname(realpath(__file__))
28
29
30host = optparse.Option(
31 _('address to listen for Web clients'),
32 default='127.0.0.1')
33
34port = optparse.Option(
35 _('address to listen for Web clients'),
36 default=5000)
37
38
39class Application(application.Daemon):
40
41 httpd = None
42
43 def start(self):
44 application.logdir.value = sugar.profile_path('logs')
45 application.rundir.value = sugar.profile_path('run')
46 application.Daemon.start(self)
47
48 def run(self):
49 app = self._get_app()
50 self.httpd = WSGIServer((host.value, port.value), app)
51 self.httpd.serve_forever()
52
53 def shutdown(self):
54 if self.httpd is not None:
55 self.httpd.stop()
56
57 @application.command(_('Run application in debug mode'))
58 def debug(self):
59 app = self._get_app()
60 app.debug = True
61 app.run(host=host.value, port=port.value)
62
63 def _get_app(self):
64 try:
65 from mejorar_sistema.app import app
66 except ImportError:
67 # Reuse from sources diretory
68 sys.path.insert(0, join(SRC_ROOT, 'app'))
69 from app import app
70 return app
71
72
73optparse.Option.seek('mejorar-sistema')
74optparse.Option.seek('mejorar-sistema',
75 [application.debug, application.foreground])
76
77app = Application(
78 name='mejorar-sistema',
79 description=_('Flask server to serve Sugar Network users'),
80 epilog=_('See http://wiki.sugarlabs.org/go/Platform_Team/' \
81 'Sugar_Network/Browser.'),
82 config_files=[
83 '/etc/sweets.conf',
84 '~/.config/sweets/config',
85 sugar.profile_path('sweets.conf'),
86 ])
87app.start()