diff --git a/O365/attachment.py b/O365/attachment.py index 25d1e65add883..9741eca8e1ed1 100644 --- a/O365/attachment.py +++ b/O365/attachment.py @@ -1,16 +1,3 @@ -# Copyright 2015 by Toben "Narcolapser" Archer. All Rights Reserved. -# -# Permission to use, copy, modify, and distribute this software and its documentation for any purpose -# and without fee is hereby granted, provided that the above copyright notice appear in all copies and -# that both that copyright notice and this permission notice appear in supporting documentation, and -# that the name of Toben Archer not be used in advertising or publicity pertaining to distribution of -# the software without specific, written prior permission. TOBEN ARCHER DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT -# SHALL TOBEN ARCHER BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ''' This file contains the functions for working with attachments. Including the ability to work with the binary of the file directly. The file is stored locally as a string using base64 encoding. diff --git a/O365/cal.py b/O365/cal.py index 2a6cd277a4d1b..7bed7e672bccc 100644 --- a/O365/cal.py +++ b/O365/cal.py @@ -1,16 +1,3 @@ -# Copyright 2015 by Toben "Narcolapser" Archer. All Rights Reserved. -# -# Permission to use, copy, modify, and distribute this software and its documentation for any purpose -# and without fee is hereby granted, provided that the above copyright notice appear in all copies and -# that both that copyright notice and this permission notice appear in supporting documentation, and -# that the name of Toben Archer not be used in advertising or publicity pertaining to distribution of -# the software without specific, written prior permission. TOBEN ARCHER DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT -# SHALL TOBEN ARCHER BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - import requests import base64 import json diff --git a/O365/contact.py b/O365/contact.py index 54fe991b91631..88fa4be88cb02 100644 --- a/O365/contact.py +++ b/O365/contact.py @@ -1,16 +1,3 @@ -# Copyright 2015 by Toben "Narcolapser" Archer. All Rights Reserved. -# -# Permission to use, copy, modify, and distribute this software and its documentation for any purpose -# and without fee is hereby granted, provided that the above copyright notice appear in all copies and -# that both that copyright notice and this permission notice appear in supporting documentation, and -# that the name of Toben Archer not be used in advertising or publicity pertaining to distribution of -# the software without specific, written prior permission. TOBEN ARCHER DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT -# SHALL TOBEN ARCHER BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - import requests import base64 import json diff --git a/O365/event.py b/O365/event.py index 541747d08ffae..4cefbaebcee8b 100644 --- a/O365/event.py +++ b/O365/event.py @@ -1,16 +1,3 @@ -# Copyright 2015 by Toben "Narcolapser" Archer. All Rights Reserved. -# -# Permission to use, copy, modify, and distribute this software and its documentation for any purpose -# and without fee is hereby granted, provided that the above copyright notice appear in all copies and -# that both that copyright notice and this permission notice appear in supporting documentation, and -# that the name of Toben Archer not be used in advertising or publicity pertaining to distribution of -# the software without specific, written prior permission. TOBEN ARCHER DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT -# SHALL TOBEN ARCHER BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - import logging import json import requests diff --git a/O365/group.py b/O365/group.py index 368dda5e61c71..4547516991f25 100644 --- a/O365/group.py +++ b/O365/group.py @@ -1,16 +1,3 @@ -# Copyright 2015 by Toben "Narcolapser" Archer. All Rights Reserved. -# -# Permission to use, copy, modify, and distribute this software and its documentation for any purpose -# and without fee is hereby granted, provided that the above copyright notice appear in all copies and -# that both that copyright notice and this permission notice appear in supporting documentation, and -# that the name of Toben Archer not be used in advertising or publicity pertaining to distribution of -# the software without specific, written prior permission. TOBEN ARCHER DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT -# SHALL TOBEN ARCHER BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - from contact import Contact import logging import json @@ -37,15 +24,15 @@ class Group( object ): con_folder_url = 'https://outlook.office365.com/api/v1.0/me/contactfolders/{0}/contacts' folder_url = 'https://outlook.office365.com/api/v1.0/me/contactfolders?$filter=DisplayName eq \'{0}\'' - def __init__(self, email, password, folderName=None): + def __init__(self, auth, folderName=None): ''' Creates a group class for managing all contacts associated with email+password. Optional: folderName -- send the name of a contacts folder and the search will limit it'self to only those which are in that folder. ''' - log.debug('setting up for the schedule of the email %s',email) - self.auth = (email,password) + log.debug('setting up for the schedule of the email %s',auth[0]) + self.auth = auth self.contacts = [] self.folderName = folderName diff --git a/O365/inbox.py b/O365/inbox.py index 708df0b3b2564..26f5d9dae4895 100644 --- a/O365/inbox.py +++ b/O365/inbox.py @@ -1,16 +1,3 @@ -# Copyright 2015 by Toben "Narcolapser" Archer. All Rights Reserved. -# -# Permission to use, copy, modify, and distribute this software and its documentation for any purpose -# and without fee is hereby granted, provided that the above copyright notice appear in all copies and -# that both that copyright notice and this permission notice appear in supporting documentation, and -# that the name of Toben Archer not be used in advertising or publicity pertaining to distribution of -# the software without specific, written prior permission. TOBEN ARCHER DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT -# SHALL TOBEN ARCHER BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - from O365.message import Message import logging import json @@ -33,15 +20,15 @@ class Inbox( object ): #url for fetching emails. Takes a flag for whether they are read or not. inbox_url = 'https://outlook.office365.com/api/v1.0/me/messages' - def __init__(self, email, password,getNow=True): + def __init__(self, auth, getNow=True): ''' Creates a new inbox wrapper. Send email and password for authentication. set getNow to false if you don't want to immedeatly download new messages. ''' - log.debug('creating inbox for the email %s',email) - self.auth = (email,password) + log.debug('creating inbox for the email %s',auth[0]) + self.auth = auth self.messages = [] self.filters = '' diff --git a/O365/message.py b/O365/message.py index 1b479e8782ad0..b6cd97682171f 100644 --- a/O365/message.py +++ b/O365/message.py @@ -1,16 +1,3 @@ -# Copyright 2015 by Toben "Narcolapser" Archer. All Rights Reserved. -# -# Permission to use, copy, modify, and distribute this software and its documentation for any purpose -# and without fee is hereby granted, provided that the above copyright notice appear in all copies and -# that both that copyright notice and this permission notice appear in supporting documentation, and -# that the name of Toben Archer not be used in advertising or publicity pertaining to distribution of -# the software without specific, written prior permission. TOBEN ARCHER DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT -# SHALL TOBEN ARCHER BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - from O365 import Attachment from O365 import Contact import logging @@ -181,10 +168,11 @@ def setRecipients(self,val): ''' if isinstance(val,list): self.json['ToRecipients'] = [] - if isinstance(val,Contact): - self.addRecipient(val) - else: - self.json['ToRecipients'].append(val) + for con in val: + if isinstance(con,Contact): + self.addRecipient(con) + else: + self.json['ToRecipients'].append(con) elif isinstance(val,dict): self.json['ToRecipients'] = [val] elif isinstance(val,str): diff --git a/O365/schedule.py b/O365/schedule.py index e64f17cbbc969..2b3dddb4aa8bd 100644 --- a/O365/schedule.py +++ b/O365/schedule.py @@ -1,16 +1,3 @@ -# Copyright 2015 by Toben "Narcolapser" Archer. All Rights Reserved. -# -# Permission to use, copy, modify, and distribute this software and its documentation for any purpose -# and without fee is hereby granted, provided that the above copyright notice appear in all copies and -# that both that copyright notice and this permission notice appear in supporting documentation, and -# that the name of Toben Archer not be used in advertising or publicity pertaining to distribution of -# the software without specific, written prior permission. TOBEN ARCHER DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT -# SHALL TOBEN ARCHER BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT -# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - from O365 import Calendar import logging import json @@ -33,10 +20,10 @@ class Schedule( object ): ''' cal_url = 'https://outlook.office365.com/EWS/OData/Me/Calendars' - def __init__(self, email, password): + def __init__(self, auth): '''Creates a Schedule class for managing all calendars associated with email+password.''' - log.debug('setting up for the schedule of the email %s',email) - self.auth = (email,password) + log.debug('setting up for the schedule of the email %s',auth[0]) + self.auth = auth self.calendars = [] diff --git a/tests/test_group.py b/tests/test_group.py index 2438bdc72d0fe..a8532beb63223 100644 --- a/tests/test_group.py +++ b/tests/test_group.py @@ -52,8 +52,8 @@ def get(url,auth,params=None): class TestGroup (unittest.TestCase): def setUp(self): - self.cons = group.Group('Wernher.VonKerman@ksp.org','rakete') - self.folds = group.Group('Wernher.VonKerman@ksp.org','rakete','Engineers') + self.cons = group.Group(('Wernher.VonKerman@ksp.org','rakete')) + self.folds = group.Group(('Wernher.VonKerman@ksp.org','rakete'),'Engineers') def test_getContacts(self): #Sanity check diff --git a/tests/test_inbox.py b/tests/test_inbox.py index 54881f14f0934..82033c1ded217 100644 --- a/tests/test_inbox.py +++ b/tests/test_inbox.py @@ -44,8 +44,8 @@ def get(url,auth,params): class TestInbox (unittest.TestCase): def setUp(self): - self.preFetch = inbox.Inbox('test@unit.com','pass') - self.JITFetch = inbox.Inbox('test@unit.com','pass',getNow=False) + self.preFetch = inbox.Inbox(('test@unit.com','pass')) + self.JITFetch = inbox.Inbox(('test@unit.com','pass'),getNow=False) def test_getMessages(self): #test to see if they got the messages already, should only work for prefetch diff --git a/tests/test_schedule.py b/tests/test_schedule.py index a930f4314adbf..47f7ad7d1ce75 100644 --- a/tests/test_schedule.py +++ b/tests/test_schedule.py @@ -36,7 +36,7 @@ def get(url,**params): class TestSchedule (unittest.TestCase): def setUp(self): - self.val = schedule.Schedule('test@unit.com','pass') + self.val = schedule.Schedule(('test@unit.com','pass')) def test_getCalendar(self): self.val.getCalendars()