SO ive created a script to add events in google calendar, with the final goal of using program AB to make the robot add them for me, the script runs pretty well and does what it is suposed, however when i try run with MRL it gives errors evrywhere, it never happened before in other scripts, does anyone have a clue?

this is the script

from __future__ import print_function
import httplib2
import os

from apiclient import discovery
import oauth2client
from oauth2client import client
from oauth2client import tools
from oauth2client import file
from apiclient.discovery import build
from httplib2 import Http

import datetime

try:
import argparse
flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args()
except ImportError:
flags = None

# If modifying these scopes, delete your previously saved credentials
# at ~/.credentials/calendar-python-quickstart.json
SCOPES = 'https://www.googleapis.com/auth/calendar'
store = file.Storage('storage.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
creds = tools.run_flow(flow, store, flags) \
if flags else tools.run(flow, store)
CAL = build('calendar', 'v3', http=creds.authorize(Http()))

SUBJECT = 'teste azul'

GMT_OFF = '-04:00'
EVENT = {
'summary' : SUBJECT,
'start' : {'dateTime': '2016-08-12T19:00:00%s' % GMT_OFF},
'end' : {'dateTime': '2016-08-12T22:00:00%s' % GMT_OFF},
'attendees': [

],
}

e = CAL.events().insert(calendarId='primary',
sendNotifications=True, body=EVENT).execute()

print('''*** %r event added:
Start: %s
End: %s''' % (e['summary'].encode('utf-8'),
e['start']['dateTime'], e['end']['dateTime']))

he is not recognizing the libraries! i will try learn to use git so i can put the code

 

GroG

7 years 8 months ago

In reply to by pedrosenarego

Only 'pure' python libraries would work - ones which do not require native binaries ...

And they must go in the correct directory ...

The directory is {mrlInstallDir}\pythonModules

Where {mrlInstallDir} is wherever you installed mrl...

Hi Pedro,

  I see that you're using some non-standard python libraries in your script.  in particular :

import oauth2client

Where did you get this library?  Did you have to install it manually into python?  MyRobotLab uses "jython" which is a python interpreter for java, so there are some subtle differences between the two.

I suspect you'll have difficulty finding some of these libraries to import into the python service, as GroG points out, if you can find a pure python impl of the libraries. you should be able to load them into the pythonModules directory.

Unfortunately, the formatting of your script above lost all of it's white space, so it's basically un-readable ..  I highly recommend you check it into github in the pyrobotlab project.