<commit_before>#!/usr/bin/python2.6
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This code is not supported by Google
#
"""Classes for administering the Google Search Appliance.

Currently, the classes available can be used to import/export/rewrite
the config file. This module is designed to be expandable so that
other functionality can be easily included.

gsaConfig: Class for handling XML from GSA export/import.
gsaWebInterface: Class for interacting with GSA Web Interface.

Example usage:

1. Export the config file:

gsa_admin.py -n <host> --port 8000 -u admin -p <pw> -e --sign-password
<PASSWORD> -o ~/tmp/o.xml -v

2. Make a change to the config file and sign:

./gsa_admin.py -n <host> -u admin -p <pw> -s --sign-password hellohello
-f ~/tmp/o.xml -v -o ~/tmp/o2.xml

3. Import the new config file:

./gsa_admin.py -n <host> --port 8000 -u admin -p <pw> -i --sign-password
hellohello -f ~/tmp/o2.xml -v

Note that import of configurations fails on 6.8.0.G.30, even if there
have been no changes to the config.

4. Export all the URLs to a file:

./gsa_admin.py --hostname=<host> --username=admin
--password=<pw> --all_urls --output=/tmp/all_urls

5. Retrieve GSA^n (mirroring) status from the admin console
./gsa_admin.py -z -n <host> -u admin -p <pw>

Note that you must use the same password to sign a file that you used
when exporting. You will get an error when importing if you do not do
this.

TODO(jlowry): add in functionality from adminconsole.py: sync DB,
pause/resume crawl, get crawl status, shutdown.
"""

__author__ = "<EMAIL> (<NAME>)"


import cgi
import os.path
import logging
import sys
import xml.dom.minidom
import hashlib
import hmac
import codecs
import urllib2
import urllib
import cookielib<commit_msg>Import/export config works with 6.8 and newer<commit_after>#!/usr/bin/python2.6
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This code is not supported by Google
#
"""Classes for administering the Google Search Appliance.

Currently, the classes available can be used to import/export/rewrite
the config file. This module is designed to be expandable so that
other functionality can be easily included.

gsaConfig: Class for handling XML from GSA export/import.
gsaWebInterface: Class for interacting with GSA Web Interface.

Example usage:

1. Export the config file:

gsa_admin.py -n <host> --port 8000 -u admin -p <pw> -e --sign-password
hellohello -o ~/tmp/o.xml -v

2. Make a change to the config file and sign:

./gsa_admin.py -n <host> -u admin -p <pw> -s --sign-password <PASSWORD>
-f ~/tmp/o.xml -v -o ~/tmp/o2.xml

3. Import the new config file:

./gsa_admin.py -n <host> --port 8000 -u admin -p <pw> -i --sign-password
<PASSWORD> -f ~/tmp/o2.xml -v


4. Export all the URLs to a file:

./gsa_admin.py --hostname=<host> --username=admin
--password=<pw> --all_urls --output=/tmp/all_urls

5. Retrieve GSA^n (mirroring) status from the admin console
./gsa_admin.py -z -n <host> -u admin -p <pw>

Note that you must use the same password to sign a file that you used
when exporting. You will get an error when importing if you do not do
this.

TODO(jlowry): add in functionality from adminconsole.py: sync DB,
pause/resume crawl, get crawl status, shutdown.
"""

__author__ = "<EMAIL> (<NAME>)"


import cgi
import os.path
import logging
import sys
import xml.dom.minidom
import hashlib
import hmac
import codecs
import urllib2
import urllib
import cookielib
{'fraction_non_alphanumeric': 0.09510869565217392, 'fraction_numerical': 0.01154891304347826, 'mean_word_length': 3.708955223880597, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5121572', 'n_tokens_mistral': 1417, 'n_tokens_neox': 1369, 'n_words': 631}