From e5f8f2c986ee50b1c94c1063ceea40be31061531 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sat, 20 Sep 2003 18:31:17 +0000 Subject: [PATCH] Add -c option to read additional config file. Send config-parsing output to stderr, and show the name of the config file upon error. --- NEWS | 6 +++++- README | 9 +++++++++ rawdoglib/rawdog.py | 15 +++++++++++++-- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 4fbd30c..0a1ba6f 100644 --- a/NEWS +++ b/NEWS @@ -11,11 +11,15 @@ now encoded in UTF-8 rather than ISO-8859-1 as before). Use standard option syntax (i.e. "--update --write" instead of "update write"). The old syntax will be supported until 2.0. -Warning output from --update now goes to stderr instead of stdout. +Error output from reading the config file and from --update now goes to +stderr instead of stdout. Made the socket timeout configurable (which also means the included copy of feedparser isn't modified any more). +Added --config option to read an additional config file; this lets you +have multiple output files with different options. + - rawdog 1.2 Updated feedparser to 2.5.2, which fixes a bug that was making rawdog diff --git a/README b/README index b86f6aa..8134c5c 100644 --- a/README +++ b/README @@ -45,6 +45,15 @@ known feed: Update that feed immediately, even if its period hasn't elapsed since it was last updated. This is useful if you're trying to debug your own feed. +"--config FILE" (or "-c FILE"), where FILE is an absolute path or a path +relative to your .rawdog directory: Read FILE as an additional config +file; any options provided in FILE will override those set in the +default config (with the exception of "feed", which is cumulative). +This is useful if you want rawdog to write two different output files +with different sets of options ("rawdog -u -w -c config2 -w" will first +update and write with the default config, then read config2, then write +again). + You will want to run "rawdog -uw" periodically to fetch data and write the output file. The easiest way to do this is to add a crontab entry that looks something like this: diff --git a/rawdoglib/rawdog.py b/rawdoglib/rawdog.py index 9982fbb..1a263b8 100644 --- a/rawdoglib/rawdog.py +++ b/rawdoglib/rawdog.py @@ -488,15 +488,18 @@ Usage: rawdog [OPTION]... -l, --list List feeds known at time of last update -w, --write Write out HTML output -f|--update-feed URL Force an update on the single feed URL +-c|--config FILE Read additional config file FILE --help Display this help and exit +Actions are taken in the order they are given on the command line. + Report bugs to .""" def main(argv): """The command-line interface to the aggregator.""" try: - (optlist, args) = getopt.getopt(argv, "ulwf:", ["update", "list", "write", "update-feed=", "help"]) + (optlist, args) = getopt.getopt(argv, "ulwf:c:", ["update", "list", "write", "update-feed=", "help", "config="]) except getopt.GetoptError, s: print s usage() @@ -525,7 +528,8 @@ def main(argv): try: config.load("config") except ConfigError, err: - print err + print >>sys.stderr, "In config:" + print >>sys.stderr, err return 1 persister = Persister("state", Rawdog) @@ -540,6 +544,13 @@ def main(argv): rawdog.write(config) elif o in ("-f", "--update-feed"): rawdog.update(config, a) + elif o in ("-c", "--config"): + try: + config.load(a) + except ConfigError, err: + print >>sys.stderr, "In " + a + ":" + print >>sys.stderr, err + return 1 persister.save() -- 2.35.1