Merge lp:~sil/desktopcouch/load-many-ini-files into lp:desktopcouch

Proposed by Stuart Langridge
Status: Merged
Approved by: Chad Miller
Approved revision: 64
Merged at revision: not available
Proposed branch: lp:~sil/desktopcouch/load-many-ini-files
Merge into: lp:desktopcouch
Diff against target: None lines
To merge this branch: bzr merge lp:~sil/desktopcouch/load-many-ini-files
Reviewer Review Type Date Requested Status
Chad Miller (community) Approve
dobey (community) Approve
Review via email: mp+11609@code.launchpad.net

Commit message

Load all ini files found in XDG config folders for desktop-couch
Add new ini file to turn on compulsory auth
Add new ini file to setup.py

To post a comment you must log in.
Revision history for this message
Stuart Langridge (sil) wrote :

Load all ini files found in XDG config folders for desktop-couch
Add new ini file to turn on compulsory auth
Add new ini file to setup.py

Revision history for this message
Stuart Langridge (sil) wrote :

This will now load every ini file it finds in any XDG folder for desktopcouch, so .config/desktop-couch or /etc/xdg/desktop-couch. So we can just add new ini files as required. The test environment adds sourcetree/etc/xdg/desktop-couch to the xdg config list, so adding new files in there will mean that they are picked up by the test environment correctly *and* that they are properly added when DC is installed as a package.

61. By Stuart Langridge

Add comment stating that /etc/xdg/desktop-couch is the system level XDG_CONFIG_DIRS

62. By Stuart Langridge

Load ini files in alphabetical order in a folder
use extend, not +=, for lists
Remove stale chain= lines

63. By Stuart Langridge

Include new ini file in MANIFEST

Revision history for this message
dobey (dobey) wrote :

Ugh. Bunch of extraneous directories in source tree == ugly. Can you just put stuff in a config/ dir, and install to /etc/ from there, instead of etc/xdg/desktopcouch/? If not, why? Having so many directories in the source is ugly, and makes test code extraneously ugly as well with the os.path.join()s.

review: Needs Fixing
64. By Stuart Langridge

Reduce number of nested folders in source tree

Revision history for this message
dobey (dobey) wrote :

Better, but still not happy. :)

review: Approve
Revision history for this message
Chad Miller (cmiller) wrote :

Looks good.

review: Approve
Revision history for this message
Chad Miller (cmiller) wrote :
Download full text (31.0 KiB)

desktopcouch.contacts.tests.test_contactspicker
  TestContactsPicker
    test_can_contruct_contactspicker ... Apache CouchDB has started, time to relax.
Desktop CouchDB is not running; starting it. ...waiting for couchdb to start...
...waiting for couchdb to start...
Browse your desktop CouchDB at file:///tmp/tmpcg7le0/xdg_data/desktop-couch/couchdb.html
                               [ERROR]
desktopcouch.contacts.tests.test_create
  TestCreate
    test_create_many_contacts ... [ERROR]
    test_head_or_tails ... [OK]
    test_random_bools ... [OK]
desktopcouch.contacts.tests.test_record
  TestContactRecord
    test_contact_record ... [OK]
desktopcouch.pair.tests.test_couchdb_io
  TestCouchdbIo
    test_get_database_names_replicatable ... [ERROR]
    test_get_database_names_replicatable_bad_server ... [ERROR]
    test_get_my_host_unique_id ... [ERROR]
    test_put_dynamic_paired_host ... [ERROR]
    test_put_static_paired_service ... [ERROR]
desktopcouch.pair.tests.test_network_io
  TestNetworkIO
    test_successful_lifespan ... [OK]
desktopcouch.records.tests.test_couchgrid
  TestCouchGrid
    test_all_from_database ... [ERROR]
    test_constructor_guarded ... [ERROR]
    test_new_rows_with_headings ... [ERROR]
    test_no_headings_or_stored_records ... [ERROR]
    test_optional_args_no_stored_records ... [ERROR]
    test_optional_record_type_arg ... [ERROR]
    test_programatically_add_row ... [ERROR]
    test_single_col_from_database ... [ERROR]
desktopcouch.records.tests.test_field_registry
  TestFieldMapping
    test_mergeable_list_field_mapping ... [OK]
    test_mergeable_list_field_mapping_empty_field ... [OK]
    test_simple_field_mapping ... [OK]
  TestTransformer
    test_from_app ... [OK]
    test_to_app ... [OK]
desktopcouch.records.tests.test_record
  TestRecordFactory
    test_build ... [OK]
  TestRecords
    test_application_annotations ... [OK]
    test_dictionary_access_to_mergeable_list ... [OK]
    test_get ... [OK]
    test_get_item ... [OK]
    test_keys ... [OK]
    test_list ... ...

Revision history for this message
Chad Miller (cmiller) wrote :
Download full text (31.0 KiB)

desktopcouch.contacts.tests.test_contactspicker
  TestContactsPicker
    test_can_contruct_contactspicker ... Apache CouchDB has started, time to relax.
Desktop CouchDB is not running; starting it. ...waiting for couchdb to start...
...waiting for couchdb to start...
Browse your desktop CouchDB at file:///tmp/tmpGKgRNX/xdg_data/desktop-couch/couchdb.html
                               [ERROR]
desktopcouch.contacts.tests.test_create
  TestCreate
    test_create_many_contacts ... [ERROR]
    test_head_or_tails ... [OK]
    test_random_bools ... [OK]
desktopcouch.contacts.tests.test_record
  TestContactRecord
    test_contact_record ... [OK]
desktopcouch.pair.tests.test_couchdb_io
  TestCouchdbIo
    test_get_database_names_replicatable ... [ERROR]
    test_get_database_names_replicatable_bad_server ... [ERROR]
    test_get_my_host_unique_id ... [ERROR]
    test_put_dynamic_paired_host ... [ERROR]
    test_put_static_paired_service ... [ERROR]
desktopcouch.pair.tests.test_network_io
  TestNetworkIO
    test_successful_lifespan ... [OK]
desktopcouch.records.tests.test_couchgrid
  TestCouchGrid
    test_all_from_database ... [ERROR]
    test_constructor_guarded ... [ERROR]
    test_new_rows_with_headings ... [ERROR]
    test_no_headings_or_stored_records ... [ERROR]
    test_optional_args_no_stored_records ... [ERROR]
    test_optional_record_type_arg ... [ERROR]
    test_programatically_add_row ... [ERROR]
    test_single_col_from_database ... [ERROR]
desktopcouch.records.tests.test_field_registry
  TestFieldMapping
    test_mergeable_list_field_mapping ... [OK]
    test_mergeable_list_field_mapping_empty_field ... [OK]
    test_simple_field_mapping ... [OK]
  TestTransformer
    test_from_app ... [OK]
    test_to_app ... [OK]
desktopcouch.records.tests.test_record
  TestRecordFactory
    test_build ... [OK]
  TestRecords
    test_application_annotations ... [OK]
    test_dictionary_access_to_mergeable_list ... [OK]
    test_get ... [OK]
    test_get_item ... [OK]
    test_keys ... [OK]
    test_list ... ...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'desktopcouch/local_files.py'
2--- desktopcouch/local_files.py 2009-09-09 23:24:53 +0000
3+++ desktopcouch/local_files.py 2009-09-11 15:34:39 +0000
4@@ -58,19 +58,29 @@
5 if not COUCH_EXE:
6 raise ImportError("Could not find couchdb")
7
8-def couch_chain_flag():
9+def couch_chain_ini_files():
10 process = subprocess.Popen([COUCH_EXE, '-V'], shell=False,
11 stdout=subprocess.PIPE)
12 line = process.stdout.read().split('\n')[0]
13 couchversion = line.split()[-1]
14
15- import distutils.version
16- if distutils.version.LooseVersion(couchversion) >= \
17- distutils.version.LooseVersion('0.10'):
18- # XXX: hardcoded path, won't work when couch is somewhere else.
19- chain = '-n -a /etc/couchdb/default.ini -a'
20- else:
21- chain = '-C'
22+ chain = '-n -a /etc/couchdb/default.ini -a'
23+ chain = "-n "
24+ # Explicitly add default ini file
25+ ini_files = ["/etc/couchdb/default.ini"]
26+
27+ # find all ini files in the desktopcouch XDG_CONFIG_DIRS and add them to
28+ # the chain
29+ xdg_config_dirs = xdg.BaseDirectory.load_config_paths("desktop-couch")
30+ # Reverse the list because it's in most-important-first order
31+ for folder in reversed(list(xdg_config_dirs)):
32+ ini_files += [os.path.join(folder,x) for x in os.listdir(folder)
33+ if x.endswith(".ini")]
34+
35+ if FILE_INI not in ini_files:
36+ ini_files.append(FILE_INI)
37+
38+ chain = "-n -a %s " % " -a ".join(ini_files)
39
40 return chain
41
42@@ -136,5 +146,5 @@
43
44
45 # You will need to add -b or -k on the end of this
46-COUCH_EXEC_COMMAND = [COUCH_EXE, couch_chain_flag(), FILE_INI, '-p', FILE_PID,
47+COUCH_EXEC_COMMAND = [COUCH_EXE, couch_chain_ini_files(), '-p', FILE_PID,
48 '-o', FILE_STDOUT, '-e', FILE_STDERR]
49
50=== modified file 'desktopcouch/start_local_couchdb.py'
51--- desktopcouch/start_local_couchdb.py 2009-09-02 15:28:28 +0000
52+++ desktopcouch/start_local_couchdb.py 2009-09-11 15:34:39 +0000
53@@ -99,9 +99,9 @@
54 'file': local_files.FILE_LOG,
55 'level': 'info',
56 },
57- ## 'admins': {
58- ## admin_account_username: admin_account_basic_auth_password
59- ## },
60+ 'admins': {
61+ admin_account_username: admin_account_basic_auth_password
62+ },
63 'oauth_consumer_secrets': {
64 consumer_key: consumer_secret
65 },
66@@ -110,10 +110,7 @@
67 },
68 'oauth_token_users': {
69 token: admin_account_username
70- },
71- ## 'couch_httpd_auth': {
72- ## 'require_valid_user': 'true'
73- ## },
74+ }
75 }
76
77 dump_ini(local, local_files.FILE_INI)
78
79=== modified file 'desktopcouch/tests/__init__.py'
80--- desktopcouch/tests/__init__.py 2009-09-10 20:12:38 +0000
81+++ desktopcouch/tests/__init__.py 2009-09-11 15:34:39 +0000
82@@ -26,6 +26,13 @@
83 if not os.path.exists(xdg_config):
84 os.mkdir(xdg_config)
85
86+# Add etc folder to config
87+SOURCE_TREE_ETC_FOLDER = os.path.realpath(
88+ os.path.join(os.path.split(__file__)[0], "..", "..", "etc", "xdg")
89+)
90+if os.path.isdir(SOURCE_TREE_ETC_FOLDER):
91+ os.environ["XDG_CONFIG_DIRS"] = SOURCE_TREE_ETC_FOLDER
92+
93 os.environ['XDG_CACHE_HOME'] = xdg_cache
94 os.environ['XDG_DATA_HOME'] = xdg_data
95 os.environ['XDG_CONFIG_HOME'] = xdg_config
96
97=== added directory 'etc'
98=== added directory 'etc/xdg'
99=== added directory 'etc/xdg/desktop-couch'
100=== added file 'etc/xdg/desktop-couch/compulsory-auth.ini'
101--- etc/xdg/desktop-couch/compulsory-auth.ini 1970-01-01 00:00:00 +0000
102+++ etc/xdg/desktop-couch/compulsory-auth.ini 2009-09-11 15:34:39 +0000
103@@ -0,0 +1,3 @@
104+[couch_httpd_auth]
105+require_valid_user = true
106+
107
108=== modified file 'setup.py'
109--- setup.py 2009-09-01 19:34:17 +0000
110+++ setup.py 2009-09-11 15:34:39 +0000
111@@ -34,6 +34,8 @@
112 'bin/desktopcouch-stop']),
113 ('/usr/share/doc/python-desktopcouch-records/api/',
114 ['desktopcouch/records/doc/records.txt']),
115+ ('/etc/xdg/desktop-couch/',
116+ ['etc/xdg/desktop-couch/compulsory-auth.ini']),
117 ('/usr/share/desktopcouch/', ['data/couchdb.tmpl']),
118 ('/usr/share/dbus-1/services/', ['org.desktopcouch.CouchDB.service']),
119 ('share/man/man1/', ['docs/man/desktopcouch-pair.1'])],

Subscribers

People subscribed via source and target branches