Commit 3197a72c authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add the logic for the free_run_harvester and polish the interface.

parent a8e686fc
......@@ -9,11 +9,46 @@ from plugin_dbui import Selector
def free_run():
"""Run a free harvester where all its parameter are defined
in the selector.
"""Run a free harvester.
All harvester parameters are defined via the selector.
"""
return 'hello'
fields = ('collections',
'controller',
'host',
'id_projects',
'id_teams',
'id_categories',
'ratio')
try:
selector = Selector(virtdb.free_harvester_selector,
exclude_fields=('mode', 'year_start', 'year_end'))
for el in fields:
if not selector[el]:
return T('All fields of the form have to be defined !!!')
tool_class = get_harvester_tool(selector.controller)
tool = tool_class(selector, debug=False)
tool.harvester = Storage()
for el in fields:
tool.harvester[el] = selector[el]
tool.process(db)
except ToolException, e:
return T(str(e))
except BaseException, e:
msg = '<br><br><hr/>'
msg += CODE(traceback.format_exc()).xml()
msg += '<hr/>'
return msg
response.view = 'harvest/layout.html'
return tool.report()
def insert_marcxml():
......@@ -23,11 +58,11 @@ def insert_marcxml():
try:
selector = Selector(virtdb.marc12_selector)
Tool = get_harvester_tool(selector.controller)
if not Tool:
tool_class = get_harvester_tool(selector.controller)
if not tool_class:
return T('Select a controller.')
tool = Tool(selector, debug=False)
tool = tool_class(selector, debug=False)
tool.process(db)
except ToolException, e:
......@@ -60,11 +95,11 @@ def run():
selector = Selector(virtdb.harvester_selector,
exclude_fields=('year_start', 'year_end'))
Tool = get_harvester_tool(selector.controller)
if not Tool:
tool_class = get_harvester_tool(selector.controller)
if not tool_class:
return T('Select an harvester.')
tool = Tool(selector, debug=False)
tool = tool_class(selector, debug=False)
tool.process(db)
except ToolException, e:
......@@ -102,9 +137,9 @@ def run_all():
collections.extend(row.collections.split(','))
Tool = get_harvester_tool(selector.controller)
tool = Tool(selector, debug=False)
tool_class = get_harvester_tool(selector.controller)
tool = tool_class(selector, debug=False)
tool.process(db)
logs.extend(tool.logs)
......
......@@ -12,6 +12,7 @@
'Address of the invenio store where the search is performed.': 'Addresse du site invenio où les recherches sont effectuées.',
'Affiliation': 'Affiliation',
'Agencies': 'Agencies',
'All fields of the form have to be defined !!!': 'Tous les champs doivent ếtre définis !!!',
'Already in the database': 'Already in the database',
'AP': 'AP',
'Are you sure you want to delete this object?': 'Voulez-vous vraiment détruire cet object ?',
......@@ -117,6 +118,7 @@
'enter a number between %(min)g and %(max)g': 'enter a number between %(min)g and %(max)g',
'enter an integer between %(min)g and %(max)g': 'entrez un entier entre %(min)g et %(max)g',
'enter an integer greater than or equal to %(min)g': 'entrez un entier plus grand ou égual à %(min)g',
'essai à blanc': 'essai à blanc',
'export as csv file': 'exporter un fichier CSV',
'extract authors': 'extraire les auteurs',
'Fill': 'Remplir',
......@@ -177,8 +179,8 @@
'List of sections separated by a comma: Articles, Proceedings.': 'List of sections separated by a comma: Articles, Proceedings.',
'lists': 'listes',
'Load': 'Load',
'Load in the database': 'Remplir la base de données',
'load in the database': 'remplir la base de données',
'load in the database': 'charger la base de données',
'Load in the database': 'Charger la base de données',
'Logged in': 'Logged in',
'Logged out': 'Logged out',
'Login': 'Login',
......
......@@ -50,20 +50,22 @@ IS_IN_DB(db, 'teams.id', 'teams.team')
#
# free harvesters selector
#
stores = ['cdsweb.cern.ch', 'inspirehep.net']
virtdb.define_table('free_harvester_selector',
Field('year_start', 'integer', default=year),
Field('year_end', 'integer'),
Field("id_teams", db.teams, label='Team'),
Field("id_projects", db.projects, label='Project'),
Field("host", "string", notnull=True, default='cdsweb.cern.ch', label='Store'),
Field("collections", "string"),
Field("host", "string", notnull=True, default=stores[1], label='Store'),
Field("collections", "string", default="find ..."),
Field("ratio", "double", notnull=True, default=1.0),
Field("controller", "string", notnull=True),
Field("id_categories", db.categories, label='Category'),
Field("mode", "string", default=MODE_DRY_RUN))
virtdb.free_harvester_selector.host.requires = \
IS_IN_SET(['cdsweb.cern.ch', 'inspirehep.net'])
IS_IN_SET(stores)
virtdb.free_harvester_selector.mode.requires = \
IS_IN_SET([MODE_DRY_RUN, MODE_LOAD_IN_DB])
......
......@@ -28,6 +28,8 @@ formModifier.link_comboboxes(masterName='controller',
displayFieldSlaves='CategoriesCode',
valueFieldSlaves='ControllersId_categories')
formModifier.hide_fields('ratio')
#
# harvester selector (linked comboboxes)
#
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment