Permalink
Browse files

merge

  • Loading branch information...
2 parents e595e57 + 658d04a commit 996f39d1606412e96faa8c92ddbc3aea46134872 @sahib sahib committed Jun 23, 2012
View
@@ -1,2 +1,3 @@
#!/bin/sh
-env python -m archive --version
+# Just forward commands to python -m archive
+env python -m archive $*
@@ -10,7 +10,7 @@
archive.py [--loglevel=<severity>] javadapter [--start]
archive.py [--loglevel=<severity>] db (--rebuild|--remove)
archive.py [--loglevel=<severity>] repair
- archive.py config (--get=<confurl>|--set=<confurl><arg>)
+ archive.py config (--get=<confurl>|--set=<confurl> <value>|--default=<confurl>)
archive.py -h | --help
archive.py --version
@@ -29,6 +29,7 @@
Config Options:
--set=<confurl><value> Set a Value in the config permanently.
--get=<confurl> Acquire a Value in the config by it's url.
+ --default=<confurl> Acquire the Default-Value of this url.
"""
@@ -186,8 +187,9 @@ def handle_config(self):
if self.__arguments['--get']:
print(config.get(self.__arguments['--get']))
elif self.__arguments['--set']:
- pass
- # TODO: Wait for config implementation.
+ config.set(self.__arguments['--set'], self.__arguments['--value'])
+ elif self.__arguments['--default']:
+ print(config.get_default(self.__arguments['--default']))
def handle_repair(self):
"""
@@ -3,25 +3,6 @@
__author__ = 'Florian Bauer'
-actual_options = {
- 'general.root': '/tmp/archive/',
- 'general.filterpath': 'filter/',
- 'crawler.depth': 1,
- 'crawler.interval': 0.5,
- 'crawler.maxInst': 20,
- 'crawler.userAgent': 'Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.7.3) Gecko/20040924 Epiphany/1.4.4 (Ubuntu)',
- #'webarchive/0.1 +https://github.com/studentkittens/webarchive',
- 'crawler.tempRoot': 'tmp/',
- 'crawler.ignoreRobots': 'true',
- 'crawler.urllistpath': 'url.txt',
- 'crawler.customWgetParms': '',
- 'db.path': 'metadata.db',
- 'db.sqlSource': 'sql/',
- 'xml.schemaPath': 'xml/',
- 'server.port': 42420,
- 'server.notify.interval': 15,
- 'javadapter.port': 42421
- }
default_options = {
'general.root': '/tmp/archive/',
@@ -42,6 +23,3 @@
'server.notify.interval': 15,
'javadapter.port': 42421
}
-
-
-
@@ -3,26 +3,32 @@
__author__ = 'Florian Bauer'
-
+import logging
+import archive.config.xmlhandler as xmlhandler
import archive.config.options as options
def get_default(value):
try:
return options.default_options[value]
except KeyError:
+ logging.info('No default found')
return ''
def get(value):
try:
- return options.actual_options[value]
+ ret = xmlhandler.get_element(value)
+ if ret == '':
+ return get_default(value)
+ else:
+ return ret
except KeyError:
return ''
def get_with_default(value):
try:
- return 'Actual: ' + str(options.actual_options[value]) + ' Default: ' + str(options.default_options[value])
+ return 'Actual: ' + str(get(value)) + ' Default: ' + str(get_default(value))
except KeyError:
return 'Wrong Item Name'
@@ -3,38 +3,21 @@
__author__ = 'Florian Bauer'
-import archive.config.options as options
import archive.config.reader as reader
+import archive.config.xmlhandler as xmlhandler
-def set(value, st):
- if (value == ('crawler.depth' or 'crawler.maxInst' or 'server.port' or
- 'server.notify.interval' or 'javadapter.port')):
- try:
- var1 = int(st)
- options.actual_options[value] = var1
- return value + ' is set to ' + str(var1)
- except ValueError:
- return 'NAN'
-
- if (value == 'crawler.interval'):
- try:
- var2 = float(st)
- options.actual_options[value] = var2
- return value + ' is set to ' + str(var2)
- except ValueError:
- return 'NAN'
- else:
- try:
- options.actual_options[value] = st
- return value + ' is set to ' + st
- except KeyError:
- return value + ' is not a Item'
+def set_value(tagname, str):
+ xmlhandler.set_element(tagname, str)
+
+
+def set_configPath(value):
+ xmlhandler.configPath = value
def set_default(value):
- try:
- options.actual_options[value] = reader.get_default(value)
- return value + ' set to ' + options.actual_options[value]
- except KeyError:
- return value + ' is not a Item'
+ default = reader.get_default(value)
+ if default == '':
+ return ''
+ else:
+ set_value(value, default)

0 comments on commit 996f39d

Please sign in to comment.