~jderose/dc3/for-dmj726

« back to all changes in this revision

Viewing changes to dc3/__init__.py

  • Committer: Jason Gerard DeRose
  • Date: 2011-09-01 08:29:01 UTC
  • mfrom: (21.1.11 intree)
  • Revision ID: jderose@novacut.com-20110901082901-kdwtz53rh78d1n2f
Added new dc3-display script for James

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
import socket
31
31
from hashlib import sha1
32
32
from base64 import b32encode
 
33
import json
33
34
import logging
34
35
 
35
36
from xdg import BaseDirectory
37
38
 
38
39
__version__ = '11.09.0'
39
40
NAME = 'dc3'
40
 
 
 
41
APPS = '/usr/share/couchdb/apps'
41
42
intree = path.isfile(path.join(path.dirname(__file__), 'setup.py'))
42
43
BUS = ('intree.freedesktop.DC3' if intree else 'org.freedesktop.DC3')
43
 
 
44
 
 
45
 
# _apps handler, for rationale see:
46
 
# https://wiki.ubuntu.com/DesktopCouchWishList#Standard_location_for_static_webUI_files
47
 
APPS = '{couch_httpd_misc_handlers, handle_utils_dir_req, "/usr/share/couchdb/apps"}'
48
44
SOCKET_OPTIONS = '[{recbuf, 262144}, {sndbuf, 262144}, {nodelay, true}]'
49
45
 
50
46
log = logging.getLogger()
98
94
"""
99
95
 
100
96
 
 
97
def handler(d):
 
98
    assert path.abspath(d) == d
 
99
    return      '{{couch_httpd_misc_handlers, handle_utils_dir_req, {}}}'.format(
 
100
        json.dumps(d)
 
101
    )
 
102
    
 
103
assert handler('/home/jderose/bzr/novacut/trunk/ui') == \
 
104
'{couch_httpd_misc_handlers, handle_utils_dir_req, "/home/jderose/bzr/novacut/trunk/ui"}'
 
105
 
 
106
 
101
107
def random_port():
102
108
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
103
109
    s.bind(('127.0.0.1', 0))
148
154
    d = {
149
155
        'share': share,
150
156
        'couchlog': logfile(cache, 'couchdb'),
151
 
        'apps': APPS,
 
157
        'apps': handler(APPS),
152
158
        'socket_options': SOCKET_OPTIONS,
153
159
    }
154
160
    return (d, ini)