Enhancements to the tool shed api to enable the curretnly most important updates for repository_metadata records.

This commit is contained in:
Greg Von Kuster
2013-02-22 14:35:34 -05:00
parent fc2088af7e
commit 4e91bb120e
7 changed files with 157 additions and 20 deletions
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env python
"""
PUT/update script to update appropriate values in a repository_metadata table record in the Tool Shed.
usage: tool_shed_repository_revision_update.py key url key1=value1 key2=value2 ...
"""
import os, sys
sys.path.insert( 0, os.path.dirname( __file__ ) )
from common import update
import pkg_resources
pkg_resources.require( "simplejson" )
import simplejson
to_json_string = simplejson.dumps
from_json_string = simplejson.loads
data = {}
for key, value in [ kwarg.split( '=', 1 ) for kwarg in sys.argv[ 3: ] ]:
"""
This example script will properly handle updating the value of one or more of the following RepositoryMetadata attributes:
tools_functionally_correct, do_not_test, tool_test_errors
"""
if key in [ 'tools_functionally_correct', 'do_not_test' ]:
if str( value ).lower() in [ 'true', 'yes', 'on' ]:
new_value = True
else:
new_value = False
elif key in [ 'tool_test_errors' ]:
new_value = from_json_string( value )
else:
new_value = str( value )
data[ key ] = new_value
update( sys.argv[ 1 ], sys.argv[ 2 ], data )