Git Product home page Git Product logo

Comments (9)

jkcso avatar jkcso commented on May 18, 2024 1

It worked, cheers for you fast and effective responses mate!

from python-o365.

Narcolapser avatar Narcolapser commented on May 18, 2024

Can you include your stack trace?

from python-o365.

jkcso avatar jkcso commented on May 18, 2024

hi, i just realised that i was not using a schedule to retrieve a calendar, can you help on what I am missing?

schedule = Schedule(authentication)
result = schedule.calendars
print(result)

CALENDAR

ev = Event(authentication)
ev.setSubject('coffee')
ev.setStart(time.gmtime(time.time() + 3600)) # start an hour from now.
ev.setEnd(time.gmtime(time.time() + 7200)) # end two hours from now.
new_e = ev.create()

I am trying to understand how to get a calendar from a scheduler and pass it to event.create

from python-o365.

Narcolapser avatar Narcolapser commented on May 18, 2024

Well, the library does a lazy load, so you need to get the calendars like this:

result = schedule.getCalendars()

Then you create the event with the calendar of your choosing, assuming you only have one, it should look something like this:

result = schedule.getCalendars()
ev = Event(auth=authentication,cal=result[0])

It's a bit of a wonky system I'll admit. It's largely because I'm just exposing the API in Python fairly directly. I'm starting to realize I need to rewrite this to work in a more sensible way.

from python-o365.

jkcso avatar jkcso commented on May 18, 2024

hey again and thank you but this line:
result = schedule.getCalendars() is a boolean

from python-o365.

Narcolapser avatar Narcolapser commented on May 18, 2024

oh, hehe, sorry. It's been a while clearly. This should work:

schedule = Schedule(authentication)
schedule.getCalendars()
result = schedule.calendars

from python-o365.

jkcso avatar jkcso commented on May 18, 2024

Still same issue, ill show you all my code to understand what I am trying to do. So I am trying to see if your library is suitable for posting and getting events for my web application, what I am having now is this:

authentication = (e, p)  // e is my mail and p is my password

bookings = []
json_outs = {}

schedule = Schedule(authentication)
try:
    result = schedule.getCalendars()
    print('\nFetched calendars for', e, 'was successful:', result, '\n')
except:
    print('Login failed for', e, '\n')

for cal in schedule.calendars:
    print('Attempting to fetch events for', e, '\n')
    try:
        result = cal.getEvents()
        print('Got:', len(cal.events), 'events in total from given calendar')
    except:
        print('failed to fetch events')
    print('\nAttempting for event information, events I got: \n')
    for event in cal.events:
        bookings.append(event.fullcalendarioJson())
json_outs[e] = bookings

print(bookings[0])
print(bookings[1])
print(bookings[2])

schedule = Schedule(authentication)
schedule.getCalendars()
result = schedule.calendars
ev = Event(authentication, result[0])
ev.setSubject('coffee')
ev.setStart(time.gmtime(time.time() + 3600))  # start an hour from now.
ev.setEnd(time.gmtime(time.time() + 7200))  # end two hours from now.
new_e = ev.create()

It fetches the events and I indeed have them in a dictionary but when i go to "ev." lines I have the following error with the program output being this:

Traceback (most recent call last):
File "/Users/jk/Documents/ExchangeTesting/narcolapser.py", line 46, in
ev.setSubject('coffee')
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/O365/event.py", line 223, in setSubject
self.json['Subject'] = val
TypeError: 'tuple' object does not support item assignment

Process finished with exit code 1

from python-o365.

Narcolapser avatar Narcolapser commented on May 18, 2024

your problem is in instantiation of Event. Because the constructor for Event uses key word arguments, authentication and your calendar aren't going to the right places. The method declaration looks like this:

def __init__(self,json=None,auth=None,cal=None,verify=True):

If you don't assign the key word arguments, it just does them in order. Which means you are passing in your authentication tuple as the json, and your calendar as authentication. Try updating your event line to this:

ev = Event(auth=authentication, cal=result[0])

from python-o365.

Narcolapser avatar Narcolapser commented on May 18, 2024

No problem. Glad to help!

from python-o365.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.