jpetrucciani / hubspot3

python3.6+ hubspot client based on hapipy, but modified to use the newer endpoints and non-legacy python
MIT License
147 stars 73 forks source link

This package is having an issue loading for me. Hubspot3UsageLimits #75

Closed tycooperaow closed 4 years ago

tycooperaow commented 4 years ago

File "send_docs.py", line 22, in

from hubspot3 import Hubspot3

File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\hubspot3__init__.py", line 9, in

class Hubspot3UsageLimits:

File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\hubspot3__init__.py", line 21, in Hubspot3UsageLimits

collected_at: datetime = datetime.fromtimestamp(0),

OSError: [Errno 22] Invalid argument

jpetrucciani commented 4 years ago

Hmm, that's interesting - is that the full stack trace?

Also, could you send OS version info and python version/environment info?

tycooperaow commented 4 years ago

I am running Windows 10. Python 3.7.0

tycooperaow commented 4 years ago

Here's my code

from hubspot3 import Hubspot3
API_KEY = "my-api-key"

client = Hubspot3(api_key=API_KEY)

# all of the clients are accessible as attributes of the main Hubspot3 Client
contact = client.contacts.get_contact_by_email('testingapis@hubspot.com')
contact_id = contact['vid']

all_companies = client.companies.get_all()

print(all_companies)
# new usage limit functionality - keep track of your API calls
client.usage_limits
# <Hubspot3UsageLimits: 28937/1000000 (0.028937%) [reset in 22157s, cached for 299s]>

client.usage_limits.calls_remaining
# 971063
print(client.usage_limits.calls_remaining)
jpetrucciani commented 4 years ago

Could you open up a python REPL and try running the following:

from datetime import datetime
datetime.fromtimestamp(0)

and see if that throws a similar error?

I found this bug specific to Windows on python's bug tracker

jpetrucciani commented 4 years ago

If this is the issue, I can definitely release a quick fix for it

tycooperaow commented 4 years ago

Yep that causes the error in the REPL. How do I fix it in the file?

jpetrucciani commented 4 years ago

I'll have to release a fixed version, I could do that in just a few minutes

tycooperaow commented 4 years ago

Great! Please let me know once that is completed! I have a project I have to complete today lol

jpetrucciani commented 4 years ago

Okay, that fix should be live on pip as version 3.2.38. Could you try installing the newer version and running your script again?

pip install hubspot3==3.2.38
tycooperaow commented 4 years ago
ERROR: Exception:
Traceback (most recent call last):
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\pip\_vendor\urllib3\response.py", line 425, in _error_catcher
    yield
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\pip\_vendor\urllib3\response.py", line 507, in read
    data = self._fp.read(amt) if not fp_closed else b""
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 62, in read
    data = self.__fp.read(amt)
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 447, in read
    n = self.readinto(b)
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 491, in readinto
    n = self.fp.readinto(b)
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\socket.py", line 589, in readinto
    return self._sock.recv_into(b)
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 1049, in recv_into
    return self.read(nbytes, buffer)
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 908, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\pip\_internal\cli\base_command.py", line 153, in _main
    status = self.run(options, args)
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\pip\_internal\commands\install.py", line 382, in run
    resolver.resolve(requirement_set)
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\pip\_internal\legacy_resolve.py", line 201, in resolve
    self._resolve_one(requirement_set, req)
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\pip\_internal\legacy_resolve.py", line 365, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\pip\_internal\legacy_resolve.py", line 313, in _get_abstract_dist_for
    req, self.session, self.finder, self.require_hashes
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\pip\_internal\operations\prepare.py", line 194, in prepare_linked_requirement
    progress_bar=self.progress_bar
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\pip\_internal\download.py", line 465, in unpack_url
    progress_bar=progress_bar
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\pip\_internal\download.py", line 316, in unpack_http_url
    progress_bar)
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\pip\_internal\download.py", line 551, in _download_http_url
    _download_url(resp, link, content_file, hashes, progress_bar)
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\pip\_internal\download.py", line 253, in _download_url
    hashes.check_against_chunks(downloaded_chunks)
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\pip\_internal\utils\hashes.py", line 80, in check_against_chunks
    for chunk in chunks:
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\pip\_internal\download.py", line 223, in written_chunks
    for chunk in chunks:
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\pip\_internal\download.py", line 212, in resp_read
    decode_content=False):
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\pip\_vendor\urllib3\response.py", line 564, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\pip\_vendor\urllib3\response.py", line 529, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\contextlib.py", line 130, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\pip\_vendor\urllib3\response.py", line 430, in _error_catcher
    raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
jpetrucciani commented 4 years ago

What were you doing when you got this error? That looks like a pip connection failure

tycooperaow commented 4 years ago

Yeh it downloaded lol. I was having wifi issues.

tycooperaow commented 4 years ago

IT WORKED!!!

jpetrucciani commented 4 years ago

Awesome! Glad that fixed it

tycooperaow commented 4 years ago

Do you have a list of all the python commands for hubspot? I was looking in their documentation and it's very scattered

jpetrucciani commented 4 years ago

For the code itself or for the CLI?

If you want the CLI, you'll also need to run pip install hubspot3[cli] to get the extra requirements, then you can run hubspot3 from the command line to see what clients are available, and if you run hubspot3 deals for example, it'll show you accessible methods for the deals client.

For the code itself, we don't have a ton of that documented out yet - but it should be relatively straightforward to read if you open up the associated client's python file. Not all clients that are in the HubSpot API documentation are completely implemented yet

tycooperaow commented 4 years ago

Which ones are implemented and which ones aren't?

jpetrucciani commented 4 years ago

I don't know the list off the top of my head, but you could get that information by installing the CLI functionality and playing around with it

tycooperaow commented 4 years ago

Ahh yeah I see now. Thanks and for future people seeing this here's the Hubspot API Documentation

https://developers.hubspot.com/docs/methods/contacts/get_contacts