Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions scripts/btgrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import sys
import urllib
import urllib2
import base64

# You need to fill in the domain of where you install
# Botanist for this to work, obviously :)
BOTANIST_DOMAIN = 'http://example.com'
BOTANIST_DOMAIN = 'https://codesearcher.int.sproutsocial.com/'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be worth force pushing to remove that internal domain from this public pull request - not that it's accessible outside your network, but if someone gets on the network, they'd know where to go

# NOTE: Fill out with real username/password to test.
# (Or come up with a real solution like sticking an auth-less version behind SDM)
LDAP_USERNAME = ''
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe put these variables in the .env.template and that way you can save your LDAP_USERNAME and LDAP_PASSWORD to the .env.local so that there's no chance of an accidental commit...but what could be really fun is integrating it with your SSO provider 😄

LDAP_PASSWORD = ''


def get_vcs_prefix(vcs_loc):
Expand All @@ -27,8 +30,12 @@ def get_vcs_prefix(vcs_loc):
args = parser.parse_args()

params = urllib.urlencode({'q': args.PATTERN, 'case': 'insensitive' if args.ignore_case else 'sensitive'})
r = urllib2.urlopen(BOTANIST_DOMAIN + '/search/results.json?' + params).read()
data = json.loads(r).get('data', {}).get('results', {})
req = urllib2.Request(BOTANIST_DOMAIN + '/search/results.json?' + params)
req.add_header('Authorization', 'Basic {0}'.format(
base64.encodestring('{0}:{1}'.format(
LDAP_USERNAME, LDAP_PASSWORD))[:-1]))
resp = urllib2.urlopen(req).read()
data = json.loads(resp).get('data', {}).get('results', {})

if data is None:
print 'no results found.'
Expand Down