Tuesday, July 2, 2013

OpenERP - Importing logs from API site

Overview:

OpenERP is an open source enterprise resource planning (ERP) software alternative to SAP, Microsoft Dynamics, Netsuite, Adempiere, Compiere, OFBiz, OpenBravo and other resource planning software.

Assembla and Redmine are online project management tools that help projects done faster. It helps you manage schedule, organize plans, collaboration and many more.

TASK: Import logs from Assembla and Redmine using REST API and PyActiveResource.

Installation:
PyActiveResource:
$ pip install pyactiveresource

Assembla:

$ pip install assembla

Basic example: Assembla
from assembla import API
     assembla = API(
                    key='FHKbGNeDo8lpO2qwM1Bs',
                    secret='X8xPwmyfHYVJqD7ZBvUdazT6G1I3LnQSRjlurOoK'
                    )
# You can view your API Key and Secret from https://www.assembla.com/user/edit/manage_clients

spaces = assembla.spaces()
for space in spaces:
     # Integrate ActiveResource
     class TimeEntry(ActiveResource):
          _plural = 'time_entries'                    
          _site = 'https://www.assembla.com/spaces/%s/' % space['name']
          _user = 'my_username'
          _password = 'my_password'
                                                                                              
     time_entries = TimeEntry.find()               
     for log in time_entries:
          daily_log.append(log.to_dict())

return daily_log

No comments:

Post a Comment