- Timestamp:
- 03/12/08 16:16:48 (5 weeks ago)
- Location:
- trunk/base
- Files:
-
- 25 modified
-
TODO (modified) (1 diff)
-
src/config.py (modified) (9 diffs)
-
src/db.py (modified) (23 diffs)
-
src/distribution/build_py.py (modified) (1 diff)
-
src/distribution/core.py (modified) (11 diffs)
-
src/distribution/svn2log.py (modified) (5 diffs)
-
src/distribution/version.py (modified) (1 diff)
-
src/distribution/xmlconfig.py (modified) (8 diffs)
-
src/extensions/inotify/__init__.py (modified) (4 diffs)
-
src/extensions/objectrow.c (modified) (1 diff)
-
src/extensions/shmmodule.c (modified) (19 diffs)
-
src/input/__init__.py (modified) (1 diff)
-
src/net/mdns.py (modified) (5 diffs)
-
src/net/tls.py (modified) (1 diff)
-
src/notifier/__init__.py (modified) (2 diffs)
-
src/notifier/async.py (modified) (7 diffs)
-
src/notifier/io.py (modified) (1 diff)
-
src/notifier/main.py (modified) (3 diffs)
-
src/notifier/nf_thread.py (modified) (1 diff)
-
src/notifier/reactor.py (modified) (1 diff)
-
src/notifier/signals.py (modified) (4 diffs)
-
src/notifier/sockets.py (modified) (3 diffs)
-
src/notifier/thread.py (modified) (3 diffs)
-
src/notifier/timer.py (modified) (1 diff)
-
src/rpc.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/base/TODO
r3684 r3686 12 12 - Rewrite of Process class 13 13 - Complete documentation 14 14 - Adjust kaa.distribution to not import anything from kaa itself. Right now 15 svn2log.py imports kaa.xmlutils 15 16 16 17 TODO either before or after 1.0: -
trunk/base/src/config.py
r2950 r3686 243 243 else: 244 244 allowed = ', '.join([ str(x) for x in self._type ]) 245 allowed = textwrap.wrap(allowed, 78, 245 allowed = textwrap.wrap(allowed, 78, 246 246 initial_indent = '# | Allowed values: ', 247 247 subsequent_indent = '# |' + 17 * ' ') … … 450 450 return self._vars.__iter__() 451 451 452 452 453 453 class Dict(Base): 454 454 """ … … 470 470 var = self._cfg_get(key) 471 471 var._default = var._value = value 472 472 473 473 474 474 … … 540 540 ret.append(cfgstr) 541 541 if space_vars: 542 # Separate multi-line subgroups with newline. 542 # Separate multi-line subgroups with newline. 543 543 ret.append('') 544 544 … … 741 741 """ 742 742 local_encoding = get_encoding() 743 if filename: 743 if filename: 744 744 filename = os.path.expanduser(filename) 745 745 if not filename: … … 885 885 except SystemError: 886 886 pass 887 887 888 888 assert(self._filename) 889 889 if self._watch_mtime == 0: … … 956 956 if isinstance(var, VarProxy): 957 957 return var._item._default 958 958 959 959 960 960 def get_description(var): … … 975 975 return var._item._type 976 976 return type(var) 977 977 978 978 979 979 def get_config(filename, module = None): … … 982 982 'filenane'. If module is None, the specified config file must have the 983 983 module specified (in the "-*- module: ... -*-" metadata), otherwise the 984 supplied module (string) is used. The module must be importable. 985 984 supplied module (string) is used. The module must be importable. 985 986 986 If the config module cannot be determined and one is not specified, 987 987 will raise ValueError. If import fails, will raise ImportError. -
trunk/base/src/db.py
r3355 r3686 135 135 fname_noext, ext = os.path.splitext(filename) 136 136 levels = dirname.strip('/').split(os.path.sep)[2:][-2:] 137 return PATH_SPLIT.split(' '.join(levels + [fname_noext])) 137 return PATH_SPLIT.split(' '.join(levels + [fname_noext])) 138 138 139 139 … … 217 217 self.last_item = None 218 218 self.last_expr = None 219 219 220 220 def __call__(self, expr, item): 221 221 if item is None: … … 358 358 Note: currently indexes and attributes can only be added, not removed. 359 359 That is, once an attribute or indexes is added, it lives forever. 360 360 361 361 type_name is the name of the type the attributes and indexes apply to 362 (e.g. 'dir' or 'image'). 362 (e.g. 'dir' or 'image'). 363 363 364 364 indexes is a list of tuples, where each tuple contains 2 or more strings, … … 444 444 raise ValueError, "Unsupported attempt to convert attribute '%s' " \ 445 445 "between ATTR_SIMPLE and ATTR_SEARCHABLE" % attr_name 446 446 447 447 if attr_name not in cur_type_attrs or cur_type_attrs[attr_name] != attr_defn: 448 # There is a new attribute specified for this type, or an 448 # There is a new attribute specified for this type, or an 449 449 # existing one has changed. 450 450 new_attrs[attr_name] = attr_defn … … 543 543 544 544 if new_attrs: 545 # Migrate rows from old table to new temporary one. Here we copy only 545 # Migrate rows from old table to new temporary one. Here we copy only 546 546 # ATTR_SEARCHABLE columns that exist in both old and new definitions. 547 547 columns = filter(lambda x: cur_type_attrs[x][1] & ATTR_SEARCHABLE and \ … … 557 557 self._db_query('ALTER TABLE %s_tmp RENAME TO %s' % (table_name, table_name)) 558 558 559 # Create a trigger that reduces the objectcount for each applicable 559 # Create a trigger that reduces the objectcount for each applicable 560 560 # inverted index when a row is deleted. 561 561 inverted_indexes = self._get_type_inverted_indexes(type_name) … … 594 594 terms of length smaller than min or larger than max will not be 595 595 indexed. If neither is specified, terms of all sizes will be indexed. 596 596 597 597 split is either a callable or a regular expression (or a string in 598 598 which case it is compiled as a regexp) and is used to parse … … 616 616 617 617 if split is None: 618 # Default split regexp is to split words on 618 # Default split regexp is to split words on 619 619 # alphanumeric/digits/underscore boundaries. 620 620 split = re.compile("[\W_\d]+", re.U) … … 640 640 } 641 641 642 self._db_query("INSERT OR REPLACE INTO inverted_indexes VALUES(?, 'definition', ?)", 642 self._db_query("INSERT OR REPLACE INTO inverted_indexes VALUES(?, 'definition', ?)", 643 643 (name, buffer(cPickle.dumps(defn, 2)))) 644 644 645 645 defn['objectcount'] = 0 646 646 self._inverted_indexes[name] = defn 647 647 648 648 649 649 def _load_inverted_indexes(self): … … 841 841 _list_to_printable(inverted_indexes)) 842 842 843 843 844 844 # Process inverted index maps for this row 845 845 ivtidx_terms = [] … … 922 922 # Simple attribute needs pickle 923 923 get_pickle = True 924 924 925 925 # TODO: if ObjectRow is supplied, don't need to fetch columns 926 926 # that are available in the ObjectRow. (Of course this assumes … … 1131 1131 raise ValueError, "One or more requested attributes %s are not available for type '%s'" % \ 1132 1132 (str(missing), type_name) 1133 # If any of the requested attributes are ATTR_SIMPLE or 1133 # If any of the requested attributes are ATTR_SIMPLE or 1134 1134 # ATTR_INDEXED_IGNORE_CASE then we need the pickle. 1135 pickled = [ x for x in columns if type_attrs[x][1] & (ATTR_SIMPLE | ATTR_INDEXED_IGNORE_CASE) in 1135 pickled = [ x for x in columns if type_attrs[x][1] & (ATTR_SIMPLE | ATTR_INDEXED_IGNORE_CASE) in 1136 1136 (ATTR_SIMPLE, ATTR_INDEXED_IGNORE_CASE)] 1137 1137 if pickled: … … 1140 1140 if 'pickle' not in columns: 1141 1141 columns.append('pickle') 1142 # Remove the list of pickled attributes so we don't 1142 # Remove the list of pickled attributes so we don't 1143 1143 # request them as sql columns. 1144 1144 columns = list(set(columns).difference(pickled)) … … 1147 1147 1148 1148 # Now construct a query based on the supplied attributes for this 1149 # object type. 1150 1149 # object type. 1150 1151 1151 # If any of the attribute names aren't valid for this type, then we 1152 1152 # don't bother matching, since this an AND query and there won't be … … 1238 1238 1239 1239 # If ivtidx search was done, sort results based on score (highest 1240 # score first). 1240 # score first). 1241 1241 if ivtidx_results: 1242 1242 results.sort(lambda a, b: cmp(ivtidx_results[(b[1], b[2])], ivtidx_results[(a[1], a[2])])) … … 1254 1254 split terms (only used if a string is given for terms), and ivtidx is 1255 1255 the name of inverted index we're scoring for. 1256 1256 1257 1257 Terms are either unicode objects or strings, or sequences of unicode or 1258 1258 string objects. In the case of strings, they are passed through … … 1554 1554 # end loop over terms 1555 1555 1556 1556 1557 1557 for r in reduce(lambda a, b: set(a).intersection(b), results.values()): 1558 1558 all_results[r] = 0 … … 1611 1611 1612 1612 # end loop while not finished 1613 log.info('%d results, did %d subqueries, %.04f seconds (%.04f overhead)', 1613 log.info('%d results, did %d subqueries, %.04f seconds (%.04f overhead)', 1614 1614 len(all_results), nqueries, time.time()-t0, t1-t0) 1615 1615 return all_results … … 1620 1620 Obtains terms for the given inverted index name. If associated is 1621 1621 None, all terms for the inverted index are returned. The return 1622 value is a list of 2-tuples, where each tuple is (term, count). 1622 value is a list of 2-tuples, where each tuple is (term, count). 1623 1623 Count is the total number of objects that term is mapped to. 1624 1624 … … 1628 1628 count reflects the number of objects which have that term plus all 1629 1629 of the given associated terms. 1630 1630 1631 1631 For example, given an otherwise empty database, if you have an object 1632 1632 with terms ['vacation', 'hawaii'] and two other object with terms … … 1652 1652 1653 1653 if not associated: 1654 return self._db_query('''SELECT term, count 1654 return self._db_query('''SELECT term, count 1655 1655 FROM ivtidx_%s_terms AS terms 1656 1656 %s … … 1664 1664 return [] 1665 1665 1666 query = '''SELECT term, COUNT(*) AS total 1666 query = '''SELECT term, COUNT(*) AS total 1667 1667 FROM ivtidx_%s_terms_map AS t0''' % ivtidx 1668 1668 for n, term_id in enumerate(term_ids): … … 1680 1680 (ivtidx, _list_to_printable(term_ids), where_clause) 1681 1681 return self._db_query(query, where_values) 1682 1682 1683 1683 1684 1684 def get_db_info(self): -
trunk/base/src/distribution/build_py.py
r2855 r3686 1 # -*- coding: iso-8859-1 -*- 2 # ----------------------------------------------------------------------------- 3 # build_py.py - kaa.config cxml install support 4 # ----------------------------------------------------------------------------- 5 # $Id$ 6 # 7 # ----------------------------------------------------------------------------- 8 # Copyright (C) 2006-2008 Dirk Meyer, Jason Tackaberry 9 # 10 # First Edition: Dirk Meyer <dmeyer@tzi.de> 11 # Maintainer: Dirk Meyer <dmeyer@tzi.de> 12 # 13 # Please see the file AUTHORS for a complete list of authors. 14 # 15 # This library is free software; you can redistribute it and/or modify 16 # it under the terms of the GNU Lesser General Public License version 17 # 2.1 as published by the Free Software Foundation. 18 # 19 # This library is distributed in the hope that it will be useful, but 20 # WITHOUT ANY WARRANTY; without even the implied warranty of 21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 # Lesser General Public License for more details. 23 # 24 # You should have received a copy of the GNU Lesser General Public 25 # License along with this library; if not, write to the Free Software 26 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 27 # 02110-1301 USA 28 # 29 # ----------------------------------------------------------------------------- 30 31 # python imports 1 32 import os 2 33 import glob -
trunk/base/src/distribution/core.py
r3685 r3686 6 6 # 7 7 # ----------------------------------------------------------------------------- 8 # Copyright (C) 200 6Dirk Meyer, Jason Tackaberry8 # Copyright (C) 2005-2008 Dirk Meyer, Jason Tackaberry 9 9 # 10 10 # First Edition: Dirk Meyer <dmeyer@tzi.de> … … 133 133 b = [ x.zfill(maxlen) for x in b.split('.') ] 134 134 # TODO: special handling of rc and beta (others?) suffixes, so 135 # that 1.0.0 > 1.0.0rc1 135 # that 1.0.0 > 1.0.0rc1 136 136 return cmp(a, b) 137 137 … … 345 345 return os.path.exists(os.path.join(distutils.sysconfig.get_python_inc(), 'Python.h')) 346 346 347 347 348 348 def convert(self): 349 349 """ … … 365 365 366 366 # Keep a reference to self in the distutils Extension object, so that 367 # after distutils.setup() is run, we can clean() the kaa Extension 367 # after distutils.setup() is run, we can clean() the kaa Extension 368 368 # object. 369 369 ext._kaa_ext = self … … 415 415 user_options = [] 416 416 docfiles = [] 417 417 418 418 def initialize_options (self): 419 419 pass 420 420 421 421 def finalize_options (self): 422 422 pass 423 423 424 424 def run(self): 425 425 self.run_command('build') … … 443 443 else: 444 444 python_dirname = prefix + dirname[3:].replace('/', '.') 445 # Anything under module/src/extensions/foo gets translated to 445 # Anything under module/src/extensions/foo gets translated to 446 446 # kaa.module.foo. 447 447 python_dirname = python_dirname.replace(".extensions.", ".") … … 472 472 if 'plugins' in kwargs: 473 473 del kwargs['plugins'] 474 474 475 475 # convert Extensions 476 476 if kwargs.get('ext_modules'): … … 505 505 break 506 506 f.close() 507 507 508 508 if len(sys.argv) > 1 and sys.argv[1] in ('bdist_rpm', 'sdist') and \ 509 509 os.path.isfile('ChangeLog.in'): … … 518 518 print 'generate doc' 519 519 os.system('(cd doc; make clean; make html)') 520 520 521 521 # delete 'module' information, not used by distutils.setup 522 522 kwargs.pop('module', None) … … 558 558 kwargs['cmdclass']['doc'] = Doc 559 559 Doc.docfiles = kwargs.pop('epydoc', []) 560 560 561 561 if len(sys.argv) > 1 and sys.argv[1] == 'bdist_rpm': 562 562 dist = None … … 586 586 587 587 if 'rpminfo' in kwargs: 588 # Grab rpm metadata from setup kwargs and expose as cmdline 588 # Grab rpm metadata from setup kwargs and expose as cmdline 589 589 # parameters to distutils. 590 590 rpminfo = kwargs['rpminfo'] -
trunk/base/src/distribution/svn2log.py
r3645 r3686 40 40 except ImportError: 41 41 from kaa.xmlutils import SaxTreeHandler 42 42 43 43 class Entry(object): 44 44 def __init__(self, author, date): … … 80 80 writer.write('\n') 81 81 writer.write('\n') 82 82 83 83 class LogParser(SaxTreeHandler): 84 84 … … 90 90 self._user = user 91 91 self._writer = writer 92 92 93 93 def handle(self, node): 94 94 revision = node.getattr('revision') … … 127 127 print path.content 128 128 print 129 129 130 130 if self._entry and (self._entry.author != author or self._entry.date != date): 131 131 self._entry.write(self._writer) … … 153 153 prefix.sort() 154 154 prefix.reverse() 155 155 156 156 # Create a parser 157 157 parser = xml.sax.make_parser() -
trunk/base/src/distribution/version.py
r2116 r3686 6 6 # 7 7 # ----------------------------------------------------------------------------- 8 # Copyright (C) 2005 Dirk Meyer, Jason Tackaberry8 # Copyright (C) 2005-2006 Dirk Meyer, Jason Tackaberry 9 9 # 10 10 # First Edition: Dirk Meyer <dmeyer@tzi.de> -
trunk/base/src/distribution/xmlconfig.py
r3645 r3686 6 6 # 7 7 # ----------------------------------------------------------------------------- 8 # Copyright (C) 2006 Dirk Meyer, Jason Tackaberry8 # Copyright (C) 2006-2008 Dirk Meyer, Jason Tackaberry 9 9 # 10 10 # First Edition: Dirk Meyer <dmeyer@tzi.de> … … 85 85 return schema 86 86 87 87 88 88 def parse(self, node, fd, deep=''): 89 89 fd.write('%s(' % node.nodeName.capitalize()) … … 103 103 fd.write('desc=\'%s\'' % desc) 104 104 getattr(self, '_parse_%s' % node.nodeName.lower())(node, fd, deep, first) 105 105 106 106 107 107 def _parse_var(self, node, fd, deep, first): … … 127 127 fd.write(')') 128 128 129 129 130 130 def _parse_config(self, node, fd, deep, first): 131 131 self._parse_group(node, fd, deep, first) 132 132 133 133 134 134 def _parse_group(self, node, fd, deep, first): … … 145 145 fd.write(", module='%s.config'" % self._package) 146 146 fd.write(')') 147 148 147 148 149 149 def _parse_list(self, node, fd, deep, first): 150 150 if not first: … … 171 171 if defaults: 172 172 fd.write(', defaults=%s' % pprint.pformat(defaults).strip()) 173 173 174 174 fd.write(')') 175 175 … … 177 177 def _parse_dict(self, node, fd, deep, first): 178 178 self._parse_list(node, fd, deep, first) 179 179 180 180 181 181 … … 184 184 if tree.nodeName != 'config': 185 185 raise RuntimeError('%s is no valid cxml file' % xml) 186 186 187 187 # out = sys.__stdout__ 188 188 out = open(python, 'w') 189 189 190 190 out.write('# auto generated file\n\n') 191 191 out.write('from kaa.config import Var, Group, Dict, List, Config\n\n') -
trunk/base/src/extensions/inotify/__init__.py
r3069 r3686 35 35 import fcntl 36 36 import select 37 import errno 38 import socket 37 39 38 40 # kaa imports … …
