Commit f13130168fa3c5923742f28eb2327195a0e5fcae
1 parent
082f3cd4
Exists in
master
and in
1 other branch
Default config options updated. Fixed bug with logging, config is Singleton.
Showing
2 changed files
with
42 additions
and
35 deletions
Show diff stats
src/bin/app_recommender.cfg
| ... | ... | @@ -3,34 +3,34 @@ |
| 3 | 3 | [general] |
| 4 | 4 | # logging level |
| 5 | 5 | debug = 0 |
| 6 | -verbose = 0 | |
| 6 | +verbose = 1 | |
| 7 | 7 | # output file |
| 8 | 8 | #output = /dev/null |
| 9 | -output = log-apprec | |
| 9 | +output = log-popindex-desktop-full | |
| 10 | 10 | |
| 11 | 11 | [data_sources] |
| 12 | 12 | # path to recommender filters |
| 13 | 13 | filters = ~/.app-recommender/filters |
| 14 | 14 | # path to apt-xapian-index |
| 15 | 15 | #axi = /var/lib/apt-xapian-index/index |
| 16 | -axi = /root/.app-recommender/DesktopAxi | |
| 16 | +axi = /root/.app-recommender/axi_desktop | |
| 17 | 17 | # DDE url |
| 18 | -dde_url = http://dde.debian.net/dde/q/udd/packages/all/%s?t=json | |
| 18 | +#dde_url = http://dde.debian.net/dde/q/udd/packages/all/%s?t=json | |
| 19 | +dde_url = http://46.4.235.200:8000/q/udd/packages/all/%s?t=json | |
| 19 | 20 | # old, reindex, cluster, recluster |
| 20 | 21 | index_mode = old |
| 21 | 22 | # path to popcon index |
| 22 | -popcon_index = ~/.app-recommender/popcon-index_desktop_1000 | |
| 23 | +popcon_index = ~/.app-recommender/popcon-index_desktop | |
| 23 | 24 | # path to popcon submissions dir |
| 24 | -#popcon_dir = ~/.app-recommender/popcon_dir | |
| 25 | -popcon_dir = ~/org/popcon.debian.org/popcon-mail/popcon-entries/ | |
| 25 | +popcon_dir = ~/.app-recommender/popcon-entries | |
| 26 | 26 | # path to valid_pkgs file |
| 27 | -pkgs_filter = program | |
| 27 | +pkgs_filter = desktop | |
| 28 | 28 | # path to popcon clusters dir |
| 29 | 29 | clusters_dir = ~/.app-recommender/clusters_dir_full |
| 30 | 30 | # number of medoids for clustering |
| 31 | 31 | k_medoids = 100 |
| 32 | 32 | # number of popcon submission for indexing |
| 33 | -max_popcon = 1000 | |
| 33 | +max_popcon = 100000000 | |
| 34 | 34 | |
| 35 | 35 | [recommender] |
| 36 | 36 | # recommendation strategy | ... | ... |
src/config.py
| ... | ... | @@ -26,8 +26,9 @@ import logging |
| 26 | 26 | import logging.handlers |
| 27 | 27 | |
| 28 | 28 | from ConfigParser import * |
| 29 | +from singleton import Singleton | |
| 29 | 30 | |
| 30 | -class Config(): | |
| 31 | +class Config(Singleton): | |
| 31 | 32 | """ |
| 32 | 33 | Class to handle configuration options. |
| 33 | 34 | """ |
| ... | ... | @@ -35,29 +36,33 @@ class Config(): |
| 35 | 36 | """ |
| 36 | 37 | Set default configuration options. |
| 37 | 38 | """ |
| 38 | - self.debug = 0 | |
| 39 | - self.verbose = 1 | |
| 40 | - self.output = "/dev/null" | |
| 41 | - self.filters = os.path.expanduser("~/.app-recommender/filters") | |
| 42 | - #self.axi = "/var/lib/apt-xapian-index/index" | |
| 43 | - self.axi = os.path.expanduser("~/.app-recommender/ProgramAxi") | |
| 44 | - #self.dde_url = "http://dde.debian.net/dde/q/udd/packs/all/%s?t=json" | |
| 45 | - self.dde_url = "http://46.4.235.200:8000/q/udd/packages/all/%s?t=json" | |
| 46 | - self.popcon_index = os.path.expanduser("~/.app-recommender/popcon-index") | |
| 47 | - self.popcon_dir = os.path.expanduser("~/.app-recommender/popcon-entries") | |
| 48 | - self.pkgs_filter = "program" | |
| 49 | - self.clusters_dir = os.path.expanduser("~/.app-recommender/clusters-dir") | |
| 50 | - self.k_medoids = 100 | |
| 51 | - self.max_popcon = 1000 | |
| 52 | - self.index_mode = "old" | |
| 53 | - self.strategy = "cb" | |
| 54 | - self.weight = "bm25" | |
| 55 | - self.profile_size = 50 | |
| 56 | - # options: maximal, voted, desktop | |
| 57 | - self.profiling = ["maximal"] | |
| 58 | - self.k_neighbors = 100 | |
| 59 | - self.load_options() | |
| 60 | - self.set_logger() | |
| 39 | + if not hasattr(self, 'initialized'): | |
| 40 | + self.debug = 0 | |
| 41 | + self.verbose = 1 | |
| 42 | + #self.output = "/dev/null" | |
| 43 | + self.output = "log" | |
| 44 | + self.filters = os.path.expanduser("~/.app-recommender/filters") | |
| 45 | + #self.axi = "/var/lib/apt-xapian-index/index" | |
| 46 | + self.axi = os.path.expanduser("~/.app-recommender/ProgramAxi") | |
| 47 | + #self.dde_url = "http://dde.debian.net/dde/q/udd/packs/all/%s?t=json" | |
| 48 | + self.dde_url = "http://46.4.235.200:8000/q/udd/packages/all/%s?t=json" | |
| 49 | + self.popcon_index = os.path.expanduser("~/.app-recommender/popcon-index") | |
| 50 | + self.popcon_dir = os.path.expanduser("~/.app-recommender/popcon-entries") | |
| 51 | + self.pkgs_filter = "program" | |
| 52 | + self.clusters_dir = os.path.expanduser("~/.app-recommender/clusters-dir") | |
| 53 | + self.k_medoids = 100 | |
| 54 | + self.max_popcon = 1000 | |
| 55 | + self.index_mode = "old" | |
| 56 | + self.strategy = "cb" | |
| 57 | + self.weight = "bm25" | |
| 58 | + self.profile_size = 50 | |
| 59 | + # options: maximal, voted, desktop | |
| 60 | + self.profiling = ["maximal"] | |
| 61 | + self.k_neighbors = 100 | |
| 62 | + self.load_options() | |
| 63 | + self.set_logger() | |
| 64 | + self.initialized = 1 | |
| 65 | + logging.info("Basic config") | |
| 61 | 66 | |
| 62 | 67 | def usage(self): |
| 63 | 68 | """ |
| ... | ... | @@ -226,7 +231,9 @@ class Config(): |
| 226 | 231 | file_handler = logging.handlers.RotatingFileHandler(self.output, |
| 227 | 232 | maxBytes=50000000, |
| 228 | 233 | backupCount=5) |
| 229 | - log_format = '%(asctime)s AppRecommender %(levelname)-8s %(message)s' | |
| 230 | - file_handler.setFormatter(logging.Formatter(log_format)) | |
| 234 | + log_format = '%(asctime)s %(levelname)-8s %(message)s' | |
| 235 | + file_handler.setFormatter(logging.Formatter(log_format, | |
| 236 | + datefmt='%Y-%m-%d %H:%M:%S')) | |
| 231 | 237 | file_handler.setLevel(log_level) |
| 232 | 238 | self.logger.addHandler(file_handler) |
| 239 | + logging.info("Set up logger") | ... | ... |