<commit_before>import os
import urllib
import urllib2
from neonsms import NeonException, NeonRestException


def find_credentials(environ=None):
    """
    Look in the current environment for Neon credentials

    :param environ: the environment to check
    """
    environment = environ or os.environ
    try:
        account = environment["NEON_USERNAME"]
        token = environment["NEON_PASSWORD"]
        return account, token
    except KeyError:
        return None, None


class Messages(object):
    def __init__(self, account, token, base):
        self.account = account
        self.token = token
        self.base = base

    def create(self, to=None, from_=None, body=None):
        #url = '{}/sms.php?user={}&clipwd={}&text={}&to={}&from={}'.format(
        #    self.base, self.account, self.token, urllib.quote(body), to, from_
        #)
        url = '{}/sms.php?user={}&clipwd={}&text={}&to={}'.format(
            self.base, self.account, self.token, urllib.quote(body), to
        )
        try:
            resp = urllib2.urlopen(url)
            if resp.getcode() != 200:
                raise NeonRestException('Unable to GET {}, {} recieved'.format(
                    url, resp.getcode())
                )
        except urllib2.URLError, e:
            raise NeonRestException(e.reason)



class NeonRestClient(object):
    def __init__(self, account=None, token=None,
                 base="https://api.neonsolutions.ie"):
        # Get account credentials
        if not account or not token:
            account, token = find_credentials()
            if not account or not token:
                raise NeonException("""
Neon could not find your account credentials. Pass them into the
NeonRestClient constructor like this:

    client = NeonRestClient(account='AC38135355602040856210245275870',
                              token='<PASSWORD>')

Or, add your credentials to your shell environment. From the terminal, run

    echo "export NEON_USERNAME=AC3813535560204085626521" >> ~/.bashrc
    echo "export NEON_PASSWORD=<PASSWORD>" >> ~/.bashrc

and be sure to replace the values for the Account SID and auth token with the
values from your Neon Account at http://www.neonsms.ie
""")
        self.messages = Messages(account, token, base)


if __name__ == '__main__':
    import sys
    if len(sys.argv) != 3:
        print("{} <to number> <from number>".format(sys.argv[0]))
    else:
        client = NeonRestClient()
        #client.messages.create(to=sys.argv[1], from_=sys.argv[2], body="Hi there")
        client.messages.create(to=sys.argv[1], body="Hi there")<commit_msg>Msg from cli<commit_after>import os
import urllib
import urllib2
from neonsms import NeonException, NeonRestException


def find_credentials(environ=None):
    """
    Look in the current environment for Neon credentials

    :param environ: the environment to check
    """
    environment = environ or os.environ
    try:
        account = environment["NEON_USERNAME"]
        token = environment["NEON_PASSWORD"]
        return account, token
    except KeyError:
        return None, None


class Messages(object):
    def __init__(self, account, token, base):
        self.account = account
        self.token = token
        self.base = base

    def create(self, to=None, from_=None, body=None):
        url = '{}/sms.php?user={}&clipwd={}&text={}&to={}&from={}'.format(
            self.base, self.account, self.token, urllib.quote(body), to, from_
        )
        try:
            resp = urllib2.urlopen(url)
            if resp.getcode() != 200:
                raise NeonRestException('Unable to GET {}, {} recieved'.format(
                    url, resp.getcode())
                )
        except urllib2.URLError, e:
            raise NeonRestException(e.reason)



class NeonRestClient(object):
    def __init__(self, account=None, token=None,
                 base="https://api.neonsolutions.ie"):
        # Get account credentials
        if not account or not token:
            account, token = find_credentials()
            if not account or not token:
                raise NeonException("""
Neon could not find your account credentials. Pass them into the
NeonRestClient constructor like this:

    client = NeonRestClient(account='AC38135355602040856210245275870',
                              token='<PASSWORD>')

Or, add your credentials to your shell environment. From the terminal, run

    echo "export NEON_USERNAME=AC3813535560204085626521" >> ~/.bashrc
    echo "export NEON_PASSWORD=<PASSWORD>" >> ~/.bashrc

and be sure to replace the values for the Account SID and auth token with the
values from your Neon Account at http://www.neonsms.ie
""")
        self.messages = Messages(account, token, base)


if __name__ == '__main__':
    import sys
    if len(sys.argv) != 4:
        print("{} <to number> <from number> <msg>".format(sys.argv[0]))
    else:
        client = NeonRestClient()
        client.messages.create(to=sys.argv[1], from_=sys.argv[2], body=sys.argv[3])
{'fraction_non_alphanumeric': 0.11358663218619455, 'fraction_numerical': 0.024666799283867117, 'mean_word_length': 2.6120689655172415, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 20, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '3462603', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1478, 'n_words': 411}