<commit_before>#!/usr/bin/python
import json
import sys
import requests
from requests import ConnectionError
import os

from model import MinCommand
from model import StatusView
from bashhub_globals import *

def search(user_id=BH_USER_ID, limit=100, path='', query='', system_id='',
        session_name=''):

    payload = {'userId' : user_id, 'limit' : limit }

    if path:
        payload["path"] = os.getcwd()

    if query:
        payload["query"] = query

    if system_id:
        payload["systemId"] = BH_SYSTEM_ID

    url = BH_URL + "/command/v1/search"

    try:
        r = requests.get(url, params=payload)
        return MinCommand.from_JSON_list(r.json())

    except ConnectionError as error:
        print "Sorry, looks like there's a connection error. Please try again later"
        return []

def save_command(command):
    url = BH_URL + "/command"
    headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
    try:
        r = requests.post(url, data=command.to_JSON(), headers=headers)
    except ConnectionError as error:
        print "Sorry, looks like there's a connection error"
        pass

def get_status_view(user_context):
    url = BH_URL + "/client-view/v1/status"

    payload = { 'userId' : user_context.user_id, 'processId' :
            user_context.process_id, 'startTime' : user_context.start_time  }
    try:
        r = requests.get(url, params=payload)
        statusViewJson = json.dumps(r.json())
        return StatusView.from_JSON(statusViewJson)
    except ConnectionError as error:<commit_msg>Changed client to hit new endpoint.<commit_after>#!/usr/bin/python
import json
import sys
import requests
from requests import ConnectionError
import os

from model import MinCommand
from model import StatusView
from bashhub_globals import *

def search(user_id=BH_USER_ID, limit=100, path='', query='', system_id='',
        session_name=''):

    payload = {'userId' : user_id, 'limit' : limit }

    if path:
        payload["path"] = os.getcwd()

    if query:
        payload["query"] = query

    if system_id:
        payload["systemId"] = BH_SYSTEM_ID

    url = BH_URL + "/command/v1/search"

    try:
        r = requests.get(url, params=payload)
        return MinCommand.from_JSON_list(r.json())

    except ConnectionError as error:
        print "Sorry, looks like there's a connection error. Please try again later"
        return []

def save_command(command):
    url = BH_URL + "/command"
    headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
    try:
        r = requests.post(url, data=command.to_JSON(), headers=headers)
    except ConnectionError as error:
        print "Sorry, looks like there's a connection error"
        pass

def get_status_view(user_context):
    url = BH_URL + "/client-view/v2/status"

    payload = { 'userId' : user_context.user_id,
                'systemId' : user_context.system_id,
                'processId' : user_context.process_id,
                'startTime' : user_context.start_time  }
    try:
        r = requests.get(url, params=payload)
        statusViewJson = json.dumps(r.json())
        return StatusView.from_JSON(statusViewJson)
    except ConnectionError as error:
{'fraction_non_alphanumeric': 0.11238745731139398, 'fraction_numerical': 0.003104625892579944, 'mean_word_length': 3.032540675844806, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '2060610', 'n_tokens_mistral': 998, 'n_tokens_neox': 961, 'n_words': 258}