<commit_before>import eo_net
import logging
import requests
import time


# How often should we sign-in?
SIGNIN_INTERVAL_IN_HOURS = 4  # hours


class EO_API(object):
    """The API class provides functions for the Electric Objects API calls.

    It maintains the state of credentials and the currently signed-in session.
    Usage: instantiate the object with credentials, then make one or more API calls
    with the object.

    Upon initialization, set the credentials. But don't attempt to sign-in until
    an API call is made.
    """

    # Class variables
    base_url = "https://www.electricobjects.com/"
    api_version_path = "api/v2/"
    endpoints = {
        "user": "user/",
        "devices": "user/devices/",
        "displayed": "user/artworks/displayed/",
        "favorited": "user/artworks/favorited/"
        }

    def __init__(self, username, password):
        self.logger = logging.getLogger(".".join(["eo", self.__class__.__name__]))
        signin_url = self.base_url + "sign_in"
        self.username = username
        self.password = password
        self.signin_url = signin_url
        self.last_signin_time = 0

        self.net = eo_net.EO_Net()

    def signin(self):
        """Sign in. If successful, set self.session to the session for reuse in
        subsequent requests. If not, set self.session to None.

        Note that while the session in self.session can be reused for subsequent
        requests, the sign-in may expire after some time. So requests that fail should
        try signing in again.
        """
        self.net.set_session(requests.Session())
        payload = {
            "user[email]": self.username,
            "user[password]": self.password
        }
        success = self.net.post_with_authenticity(self.signin_url, payload)
        if not success:
            self.net.set_session(None)
            return
        self.last_signin_time = time.clock()

    def signed_in(self):
        """Return true if we have a valid signed-in session. """
        return self.net.get_session() is not None

    def check_signin_status(self):<commit_msg>re-added user-agent to this branch<commit_after>import eo_net
import logging
import requests
import time


# How often should we sign-in?
SIGNIN_INTERVAL_IN_HOURS = 4  # hours

USER_AGENT = "eo-python-client"


class EO_API(object):
    """The API class provides functions for the Electric Objects API calls.

    It maintains the state of credentials and the currently signed-in session.
    Usage: instantiate the object with credentials, then make one or more API calls
    with the object.

    Upon initialization, set the credentials. But don't attempt to sign-in until
    an API call is made.
    """

    # Class variables
    base_url = "https://www.electricobjects.com/"
    api_version_path = "api/v2/"
    endpoints = {
        "user": "user/",
        "devices": "user/devices/",
        "displayed": "user/artworks/displayed/",
        "favorited": "user/artworks/favorited/"
        }

    def __init__(self, username, password):
        self.logger = logging.getLogger(".".join(["eo", self.__class__.__name__]))
        signin_url = self.base_url + "sign_in"
        self.username = username
        self.password = password
        self.signin_url = signin_url
        self.last_signin_time = 0

        self.net = eo_net.EO_Net()

    def signin(self):
        """Sign in. If successful, set self.session to the session for reuse in
        subsequent requests. If not, set self.session to None.

        Note that while the session in self.session can be reused for subsequent
        requests, the sign-in may expire after some time. So requests that fail should
        try signing in again.
        """
        new_session = requests.Session()
        new_session.headers["User-Agent"] = USER_AGENT
        self.net.set_session(new_session)
        payload = {
            "user[email]": self.username,
            "user[password]": self.password
        }
        success = self.net.post_with_authenticity(self.signin_url, payload)
        if not success:
            self.net.set_session(None)
            return
        self.last_signin_time = time.clock()

    def signed_in(self):
        """Return true if we have a valid signed-in session. """
        return self.net.get_session() is not None

    def check_signin_status(self):
{'fraction_non_alphanumeric': 0.09394285714285715, 'fraction_numerical': 0.0013714285714285714, 'mean_word_length': 2.492418196328811, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 3, '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': '5657066', 'n_tokens_mistral': 1288, 'n_tokens_neox': 1247, 'n_words': 393}