Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lann/harvest
Python API for getharvest.com
https://github.com/lann/harvest
Last synced: 20 days ago
JSON representation
Python API for getharvest.com
- Host: GitHub
- URL: https://github.com/lann/harvest
- Owner: lann
- License: agpl-3.0
- Created: 2011-02-08T06:55:17.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2015-02-22T16:35:26.000Z (over 9 years ago)
- Last Synced: 2024-10-14T13:49:05.448Z (about 1 month ago)
- Language: Python
- Homepage:
- Size: 520 KB
- Stars: 49
- Watchers: 12
- Forks: 32
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
**This project is no longer actively maintained.**
This one is (as of this writing): `lionheart/python-harvest`_
.. _lionheart/python-harvest: https://github.com/lionheart/python-harvest
===================
Harvest API
===================Example:
.. code:: python
from datetime import datetime, timedelta
from harvest import Harvesth = Harvest( 'https://foo.harvestapp.com', '[email protected]', 'mypassword' )
user = h.find_user( 'John', 'Doe' )
if user:
print 'The user ID = %d' % user.idstart = datetime.today()
end = start + timedelta(7)total = 0
for entry in user.entries( start, end ):
total += entry.hoursprint 'Total hours worked = %f' % total
Example:
.. code:: python
import sys
from harvest import Harvest, HarvestError
from datetime import datetime, timedelta
import timeURI = 'https://foo.harvestapp.com'
EMAIL = '[email protected]'
PASS = 'xxxxxx'h = Harvest(URI,EMAIL,PASS)
while True:
total = 0
dose = 0start = datetime.today().replace( hour=0, minute=0, second=0 )
end = start + timedelta(1)
try:
for user in h.users():
for entry in user.entries( start, end ):
total += entry.hourstext = '%0.02f' % total
print textexcept HarvestError:
print 'Retrying in 5 minutes...'time.sleep(300)
Example:
.. code:: python
for project in h.projects:
print project
print project.client
for assignment in project.task_assignments:
print '\t',assignment
for entry in project.entries:
print '\t',entry
print '\t\ttask:',entry.taskExample:
.. code:: python
for client in h.clients:
print client
for contact in client.contacts:
print '\t',contact