示例#1
0
def gcal_insert_bc_event(titleid, descfull, lockv, sdatekv, edatekv):
    from GoogleCalendar import GoogleCalendarMng, newEvent
    import GoogleCalendar
    try:
        #from GoogleCalendar import *
        gCalMNG = GoogleCalendarMng()
        myname = "john bragato"
        myemail = "*****@*****.**"
        gCalMNG.connect (myemail, "yankee17")
        calendar = gCalMNG.getCalendar ("Default1")
        gcalevents = calendar.getEvents()
        print len(gcalevents)
        gcaleventslist = []
        for event in gcalevents:
            gcalevent = event.getTitle()
            if gcalevent == titleid:
                continue
            else:
                print event.getContent()
                #print time.strftime("%Y-%m-%dT%H:%M:%S" , time.localtime(event.getStartTime()))
                #print time.strftime("%Y-%m-%dT%H:%M:%S" , time.localtime(event.getEndTime()))
        ev = newEvent(myname, myemail, titleid, descfull, lockv, time.mktime(sdatekv), time.mktime(edatekv))
        print ev
        calendar.addEvent (ev)
    except xml.parsers.expat.ExpatError:
    #except:
        print "FAILED"
                    from GoogleCalendar import *
                    myname = "john bragato"
                    myemail = "*****@*****.**"
                    gCalMNG = gcal_login_jb()
                    calendar = gCalMNG.getCalendar("ProductionNumbers")
                    try:
                        gcalevents = gCalMNG.getCalendar("ProductionNumbers").getEvents()
                        print len(gcalevents)
                        gcaleventslist = []
                        for event in gcalevents:
                            gcalevent = event.getTitle()
                            if gcalevent == titleid:
                                continue
                            else:
                                print event.getContent()
                                #print time.strftime("%Y-%m-%dT%H:%M:%S" , time.localtime(event.getStartTime()))
                                #print time.strftime("%Y-%m-%dT%H:%M:%S" , time.localtime(event.getEndTime()))
                    except AttributeError:
                        pass
                    ev = newEvent(myname, myemail, titleid, descfull, lockv, time.mktime(sdatekv), time.mktime(edatekv))
                    print ev
                    calendar.addEvent(ev)
                except AttributeError:
                    print "AttributeError"
                except xml.parsers.expat.ExpatError:
                #except:
                    print "FAILED" #+ k,v
            except ValueError:
                print "ValueError Key: {} Value: {}".format(k,v)
        #    continue