11 return os.path.dirname(os.path.abspath(
12 inspect.stack()[0][1]))
16 os.makedirs(*args, **kwargs)
22 return filename.endswith(
'.json')
and not filename.startswith(
'sample')
25 schema_dict[
'id'] =
'{url_base_with_version}/{filename}#'.format(**vars())
27 def main(template_directory, output_directory_base, url_base):
28 url_base_with_version =
'{0}/v{1}'.format(url_base, SCHEMA_VERSION)
29 output_directory_with_version = os.path.join(output_directory_base,
'v' + SCHEMA_VERSION)
31 for dirpath, _, filenames
in os.walk(template_directory):
32 for filename
in filenames:
34 with open(os.path.join(dirpath, filename))
as f:
35 schema_dict = json.load(f)
37 with open(os.path.join(output_directory_with_version, filename),
'w')
as f:
38 json.dump(schema_dict, f, indent=4, sort_keys=
True)
40 if __name__ ==
'__main__':
42 Usage: python %prog --output_directory_base <path to desired deployment directory> [options]
44 Deploys packaged schemas to <output_directory_base>.
46 Sets "id" field of deployed schemas appropriately based on <url_base>.
50 python %prog --output_directory_base /tmp/irods_schemas
52 This will create, if necessary, /tmp/irods_schemas and /tmp/irods_schemas/v{SCHEMA_VERSION}, then populate the latter with copies of the schema files currently found in {SCHEMAS_DIR}. The schema copies will have their "id" fields updated to reflect their new locations (e.g. "server_config.json" will have "id" field "file:///tmp/irods_schemas/v{SCHEMA_VERSION}/server_config.json#".
54 To have an iRODS installation validate its configuration files against this local deployment, set the iRODS "schema_validation_base_uri" (found in "/etc/irods/server_config.json" or fed into the prompt during setup) to "file:///tmp/irods_schemas".
56 Make sure that the Linux account running iRODS has read access to the deployed schemas.
57 '''.format(SCHEMA_VERSION=SCHEMA_VERSION, SCHEMAS_DIR=os.path.join(
get_script_directory(),
'schemas'))
59 parser = optparse.OptionParser(usage=usage)
60 parser.add_option(
'--output_directory_base', help=optparse.SUPPRESS_HELP)
61 parser.add_option(
'--template_directory', metavar=
'<path to alternate schema templates>')
62 parser.add_option(
'--url_base', metavar=
'<alternate url base for "id" field>', help=
'Useful for creating web deployments')
63 options, _ = parser.parse_args()
65 if not options.output_directory_base:
68 options.output_directory_base = os.path.abspath(options.output_directory_base)
70 if not options.template_directory:
73 if not options.url_base:
74 options.url_base =
'file://' + options.output_directory_base
76 options.url_base = options.url_base.rstrip(
'/')
78 main(options.template_directory, options.output_directory_base, options.url_base)