Created
January 17, 2012 19:48
-
-
Save fish2000/1628440 to your computer and use it in GitHub Desktop.
Untested Python snippet to automatically update a Solr instances' schema.xml with the puke from the django-haystack build_solr_schema command.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys, os, uuid, tempfile | |
| from django.core.management import call_command | |
| def main(): | |
| # create /tmp/log with default bitmask of 0777 | |
| os.makedirs('/tmp/log') | |
| # | |
| def reschematize(solr_schema=None): | |
| default_schema = "/Users/fish/Dropbox/local-instance-packages/apache-solr-3.3.0/example/solr/conf/schema.xml" | |
| if solr_schema is None: | |
| solr_schema = os.environ.get('SOLR_SCHEMA', default_schema) | |
| tmpid = uuid.uuid4().hex | |
| tmpold = "/tmp/solr-schema-old-%s.xml" % tmpid | |
| tmpnew = "/tmp/solr-schema-new-%s.xml" % tmpid | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment