def update_contact_info(self): """ Updates contact information in the database. """ contact_info, task_info = self.get_contact_task_information( self.spreadsheetId) self.contacts = Contacts(contact_info) for month in self.months: month.update_contacts(self.contacts)
def initiateGame(self, addrList, contactList): print addrList threads = [] game = Game(len(addrList)) contacts = Contacts() for con in contactList: contacts.add(con) contacts.notifyAll(Code.START) contacts.notifyAll(Code.INFO, ["You wait until the fateful night of the " + "party, dressing up in your finest attire. " + "At the house you're greeted by a elderly " + 'butler. "Which guest are you again?" ' + "he asks."]) contacts.notifyAll(Code.CHAR_PROMPT, game.availableSuspects()) for i in range(len(contacts)): threads.append(threading.Thread(target= ClientHandler.start, args=(i, game, contacts))) threads[-1].start() for thread in threads: thread.join() self.s.shutdown(socket.SHUT_RDWR) self.s.close()
def __init__(self, slug, api_key): super(NationBuilder, self).__init__() self.people = People(slug, api_key) self.tags = NBTags(slug, api_key) self.lists = Lists(slug, api_key) self.contacts = Contacts(slug, api_key)
def __init__(self, options=None): defaults = { 'contacts_file': os.path.join(DATA_DIR, 'contacts.json'), } if not options: options = defaults # Auth self.credentials = self.authenticate() self.http = self.credentials.authorize(httplib2.Http()) self._messages = None self._drafts = None self._people = None # Try to instantiate services (requires internet connection) try: self.service = discovery.build('gmail', 'v1', http=self.http) self.users = self.service.users() except Exception as e: print('Google API je nedostupan:', e) self.ok = False # Prepare contacts self.contacts = Contacts(options.get('contacts_file'), self.people)
def main(): myContacts = Contacts() print "My " + str(myContacts) myContacts.addContact("Mickey") myContacts.addContact("Fred") myContacts.addContact("Edward") myContacts.addContact("Harry") print "My " + str(myContacts) yourContacts = Contacts() yourContacts.addContact("Pat") print "Your " + str(yourContacts) print "My " + str(myContacts)
def text_find_contact_by_number(self): """test to check if we can find a contact by phone number and display information""" self.new_contact.save_contact() test_contact = Contacts('Test', 'User', '071234786', '*****@*****.**') test_contact.save_contact() found_contact = Contacts.find_by_number('0711223344') self.assertEqual(found_contact.email, test_contact.email)
def test_delete_contact(self): """test_delete_contact to test if we can remove a contact from our contact list""" self.new_contact.save_contact() test_contact = Contacts('Test', 'User', '071234786', '*****@*****.**') test_contact.save_contact() self.new_contact.delete_contact() self.assertEqual(len(Contacts.contact_list), 1)
def test_contact_exists(self): """test to check if we can return Boolean "if we cannot find the contact""" self.new_contact.save_contact() test_contact = Contacts('Test', 'User', '071234786', '*****@*****.**') test_contact.save_contact() contact_exists = Contacts.contact_exists('0711223344') self.assertTrue(contact_exists)
def testEmptyList(self): '''Check that an empty list is handled properly''' contacts = Contacts() self.assertFalse(contacts.isOnline("abcdef")) self.assertIsNone(contacts.lastSeen("abcdef"), "last seen time should be None") self.assertIsNone(contacts.lastSeen(None), "last seen time should be None") self.assertIsNone(contacts.lastSeen(""), "last seen time should be None")
def __init__(self, scope, resources, calibration): #initialise pygame self.compass = Compass(calibration) #get a compass object self.scope = scope #Use a pyscope object so we can run the program from the console self.resources = resources #get the resources class instance self.contactsArray = Contacts() #get a contacts class instance self.text = None self.smallnumber_text = None self.dots = None self.display_scale = None self.closest_text = "" self.smallnumber = ""
def __init__(self, app=None, token=None, refresh_token=None, tokens=None): if tokens: token = tokens["access_token"] refresh_token = tokens["refresh_token"] self.app = app self.token = token self.refresh_token = refresh_token self.session = self.app.oauth.get_session(token=self.token) self.session.headers.update({'Content-Type': 'application/json'}) self.timeline = Timeline(self) self.contacts = Contacts(self)
def load(self, command=False): if command: return "Load" with open("data.json", "r") as file: data = json.load(file) contact_data = data["owner"]["contacts"] contacts = Contacts(contact_data["adress"], contact_data["mobile"], contact_data["nif"], contact_data["email"]) self.owner = Owner(data["owner"]["name"], contacts) self.product_manager.from_dict(data["products"]) self.warehouse_manager.from_dict(data["warehouses"]) self.order_manager.from_dict(data["orders"]) self.client_manager.from_dict(data["clients"]) self.product_group_manager.from_dict(data["product_groups"])
def testComingOnline(self): '''Check that a contact coming online is handled properly''' contacts = Contacts() contacts.comeOnline("abcdef") self.assertTrue(contacts.isOnline("abcdef")) self.assertIsNotNone(contacts.lastSeen("abcdef"), "last seen time should be filled now") # Other contacts should still be offline self.assertFalse(contacts.isOnline("abcdef2")) self.assertFalse(contacts.isOnline("ABCDEF")) self.assertFalse(contacts.isOnline("ghijklmn")) self.assertIsNone(contacts.lastSeen("ghijklmn"), "last seen time should be None") self.assertIsNone(contacts.lastSeen(None), "last seen time should be None") self.assertIsNone(contacts.lastSeen(""), "last seen time should be None")
def __init__(self): self.product_manager = ProductManager() self.warehouse_manager = WarehouseManager() self.order_manager = OrderManager() self.client_manager = ClientManager() self.product_group_manager = ProductGroupManager() self.owner = Owner( "Yo Corp.", Contacts("Tomar", 123456789, 987654321, "*****@*****.**")) prods_list = self.product_manager.get_all().keys() self.product_group_manager.from_dict([{ "id": 0, "name": "ALL PRODUCTS", "products": prods_list }, { "id": 1, "name": "OLD PRODUCTS", "products": [] }]) self.load()
def testGoingOffline(self): '''Check that a contact going offline is handled properly''' contacts = Contacts() contacts.comeOnline("abcdef") self.assertTrue(contacts.isOnline("abcdef")) self.assertIsNotNone(contacts.lastSeen("abcdef"), "last seen time should be filled now") goOnlineTime = contacts.lastSeen("abcdef") # Now go offline again contacts.goneOffline("abcdef") self.assertFalse(contacts.isOnline("abcdef")) self.assertIsNotNone(contacts.lastSeen("abcdef"), "last seen time should be filled now") goOfflineTime = contacts.lastSeen("abcdef") self.assertNotEqual(goOnlineTime, goOfflineTime) # Reappear contacts.comeOnline("abcdef") self.assertTrue(contacts.isOnline("abcdef")) self.assertIsNotNone(contacts.lastSeen("abcdef"), "last seen time should be filled now") reappearTime = contacts.lastSeen("abcdef") self.assertNotEqual(goOnlineTime, reappearTime) self.assertNotEqual(goOfflineTime, reappearTime)
def __init__(self, editors, names, tasks, spreadsheetId, month_file=None, new_page=False): super(GSheetsRequest, self).__init__() self.editors = editors self.service = None self.spreadsheetId = spreadsheetId self.write_body = {} self.request_body = {} self.service = self.start() if new_page: self.new_page() self.full_send(request_only=True) contact_info, task_info = self.get_contact_task_information( self.spreadsheetId) self.contacts = Contacts(contact_info) self.tasks = TaskManager(task_info) self.current_sheet_name, self.current_sheet_id, self.totals_sheet_id = self.get_sheet_name_and_id( self.spreadsheetId) self.months = [ Month(self.contacts, self.tasks, self.current_sheet_id, self.spreadsheetId, self.current_sheet_name, self.editors) if month_file is None else Month.load(month_file) ] self.recent_month = self.months[0] self.sheet_name_date_start = None self.sheet_name_date_end = None self.save()
def contacts(self): phone_contacts = Contacts( ) # phone_contacts is the object of the class
def setUp(self): """set up method to run before each test cases""" self.new_contact = Contacts('Valentine', 'Robai', '0712345678', '*****@*****.**')
def create_contact(fname, lname, phone, email): """Function to create a new contact """ new_contact = Contacts(fname, lname, phone, email) return new_contact
else: mlog_file = sys.stderr mlog_observer = FilteringLogObserver(textFileLogObserver(mlog_file), predicates=[info_predicate]) globalLogPublisher.addObserver(mlog_observer) # logger.info('resetting log output file') return reset_log_file() logger = Logger() globalLogBeginner.beginLoggingTo([]) contacts = Contacts(config_top) # noinspection PyUnusedLocal def receive_signal(signal_number, frame): logger.info('Received signal: {signal_number}', signal_number=signal_number) if ('True' == config.get('Testing')) and (signal.SIGUSR1 == signal_number): # testing is set logger.info('Testing is set') # noinspection PyBroadException,PyPep8 try: contacts.reset() except: logger.failure('error resetting, exiting') reactor.stop()
def setUp(self): self.home_book = Contacts() self.work_book = Contacts()
# unknown locale, use en is better than fail LANG = None if LANG is None: LANG = 'en' else: LANG = LANG[:2] # en, fr, el etc.. gmail_domains = ['gmail.com', 'googlemail.com'] transport_type = {} # list the type of transport last_message_time = {} # list of time of the latest incomming message # {acct1: {jid1: time1, jid2: time2}, } encrypted_chats = {} # list of encrypted chats {acct1: [jid1, jid2], ..} contacts = Contacts() gc_connected = { } # tell if we are connected to the room or not {acct: {room_jid: True}} gc_passwords = { } # list of the pass required to enter a room {room_jid: password} automatic_rooms = { } # list of rooms that must be automaticaly configured and for which we have a list of invities {account: {room_jid: {'invities': []}}} groups = {} # list of groups newly_added = {} # list of contacts that has just signed in to_be_removed = {} # list of contacts that has just signed out events = Events() nicks = {} # list of our nick names in each account # should we block 'contact signed in' notifications for this account?
import pytz config = yaml.safe_load(open("config.yml")) my_timezone = timezone(config["global"]["timezone"]) utc = pytz.utc dt_format = config["global"]["dt_format"] twilio_account_sid = config["twilio"]["account_sid"] twilio_auth_token = config["twilio"]["auth_token"] from twilio.rest import TwilioRestClient twilio_client = TwilioRestClient(twilio_account_sid, twilio_auth_token) from contacts import Contacts, Contact c = Contacts() # syntax: print_texts_with.py <contact> import sys script_name = sys.argv.pop(0) name = sys.argv.pop(0) contact = c.find_contact_by_name(name) def name_or_number(number): contact = c.find_contact_by_number(number) if contact: return contact.name else: return number
def main(): c = Connections() users = c.get_all_data() contacts = Contacts(users).contacts for contact in contacts: print(contact)
def __init__ (self, name, contacts=Contacts()): self.name = name self.contacts = contacts
def from_dict (self, client_list): for client in client_list: contacts = Contacts(client["contacts"]["adress"], client["contacts"]["mobile"], client["contacts"]["nif"], client["contacts"]["email"]) self.clients[client["id"]] = Client(client["name"], contacts)
def test_save_multiple_contacts(self): """test_save_multiple_contact to check if we can save multiple contacts to the list""" self.new_contact.save_contact() test_contact = Contacts('Test', 'User', '071234786', '*****@*****.**') test_contact.save_contact() self.assertEqual(len(Contacts.contact_list), 2)