コード例 #1
0
    def setupClicksend(config):
        if "Notifications" in config:
            if "clicksendAPI_username" in config['Notifications']:
                configuration = clicksend_client.Configuration()
                configuration.username = config['Notifications'][
                    'clicksendAPI_username']
                configuration.password = config['Notifications'][
                    'clicksendAPI_password']
                self.notificationNumber = config['Notifications'][
                    'phonenumber']
                # create an instance of the API class
                self.smsAccountAPI = clicksend_client.AccountApi(
                    clicksend_client.ApiClient(configuration))
                try:
                    # Get account information
                    api_response = self.smsAccountAPI.account_get()
                    if "http_code': 200" not in api_response:
                        print("Invalid clicksend API response")
                        print(api_response)
                        self.smsAccountAPI = False
                    else:
                        self.smsAPI = clicksend_client.SMSApi(
                            clicksend_client.ApiClient(configuration))

                except ApiException as e:
                    print(
                        "Exception when calling AccountApi->account_get: %s\n"
                        % e)
                except Exception as err:
                    print("Eception when calling clicksend API")
                    print(err)
コード例 #2
0
def textSender():

    configuration = clicksend_client.Configuration()
    configuration.username = ''
    configuration.password = ''


    # create an instance of the API class
    api_instance = clicksend_client.SMSApi(clicksend_client.ApiClient(configuration))

    # If you want to explictly set from, add the key _from to the message.
    sms_message = SmsMessage(source="sdk",
                        body="Delivery Driver needed for Cake's Bakery. Contact at 214-557-4834",
                        to=""
                       )

    sms_messages = clicksend_client.SmsMessageCollection(messages=[sms_message])

    try:
        # Send sms message(s)
        api_response = api_instance.sms_send_post(sms_messages)
        print(api_response)
        return(jsonify(api_response))
    except ApiException as e:
        print("Exception when calling SMSApi->sms_send_post: %s\n" % e)
        return("error")
コード例 #3
0
ファイル: Main2.py プロジェクト: Bensky13/garagedoor
    def __init__(self):
        print("Initializing Garage Door Monitor")
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(self.BEAM_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        #GPIO.add_event_detect(self.BEAM_PIN, GPIO.BOTH, callback=self.break_beam_callback)
        
        atexit.register(self.exitHandler)

        config = configparser.ConfigParser()
        config.read('settings.conf')


        # While there is no internet... run a continously loop.
        # THIS IS BLOCKING THE ENTIRE STATUS CHECK SCRIPT!
        noInternetCount = 0
        while not self.internet():
            print("No internet %s!!!" % noInternetCount)

            noInternetCount += 1
            time.sleep(5)

        # Configure HTTP basic authorization: BasicAuth
        username = config['Notifications']['clicksendAPI_username']
        password = config['Notifications']['clicksendAPI_password']
        notificationNumber = config['Notifications']['phonenumber']
        notificationNumber2 = config['Notifications']['benjaminWork']
        notificationNumber3 = config['Notifications']['annaCell']
        configuration = clicksend_client.Configuration()
        configuration.username = username
        configuration.password = password

        # create an instance of the API class
        self.api_instance = clicksend_client.SMSApi(clicksend_client.ApiClient(configuration))

        # If you want to explictly set from, add the key _from to the message.
        sms_message = SmsMessage(source="python",
                        body="Hey, the garage door has been open for five minutes.",
                        to=notificationNumber)
        sms_message2 = SmsMessage(source="python",
                        body="Hey, the garage door has been open for several minutes.",
                        to=notificationNumber2)

        sms_message3 = SmsMessage(source="python",
                        body="Hey, the garage door has been open for several minutes.",
                        to=notificationNumber3)

        self.sms_messages = clicksend_client.SmsMessageCollection(messages=[sms_message,sms_message2,sms_message3])


        garageDoorStatusThread = threading.Thread(target=self.doorStatusLoop)
        sendSMSThread = threading.Thread(target=self.sendSMS)


        garageDoorStatusThread.start()
        sendSMSThread.start()
コード例 #4
0
    def send_sms(self, phone, code):
        api_instance = clicksend_client.SMSApi(clicksend_client.ApiClient(configuration))

        sms_message = SmsMessage(source="php",
                                 body="Your security code for MEDD is {}".format(code),
                                 to=phone,
                                 schedule=1436874701)

        sms_messages = clicksend_client.SmsMessageCollection(messages=[sms_message])

        try:
            # Send sms message(s)
            api_response = api_instance.sms_send_post(sms_messages)
            print(api_response)
        except ApiException as e:
            print("Exception when calling SMSApi->sms_send_post: %s\n" % e)
コード例 #5
0
    def send_invite_sms(self, company, phone, link):
        api_instance = clicksend_client.SMSApi(clicksend_client.ApiClient(configuration))

        sms_message = SmsMessage(source="php",
                                 body="Hello! Your company {} "
                                      "invited you as a representative manager to the MEDD platform."
                                      " Please, follow this link and confirm your participation {}".format(company, link),
                                 to=phone,
                                 schedule=1436874701)

        sms_messages = clicksend_client.SmsMessageCollection(messages=[sms_message])

        try:
            # Send sms message(s)
            api_response = api_instance.sms_send_post(sms_messages)
            print(api_response)
        except ApiException as e:
            print("Exception when calling SMSApi->sms_send_post: %s\n" % e)
コード例 #6
0
ファイル: clicks_outg_sms.py プロジェクト: alxfed/permits
def main():
    # create an instance of the API class
    api_instance = clicksend_client.SMSApi(
        clicksend_client.ApiClient(configuration))
    sms_message = SmsMessage(source="sdk",
                             body="This is the body of the message.",
                             country='US',
                             to="+13129709819")
    sms_messages = clicksend_client.SmsMessageCollection(
        messages=[sms_message])
    try:
        # Send sms message(s)
        api_response = api_instance.sms_send_post(sms_messages)
        sent_list = api_response['data']['messages']
        print(sent_list)
        # then - https://developers.clicksend.com/docs/rest/v3/?python#view-sms-receipts
        # https://developers.clicksend.com/docs/rest/v3/#create-test-sms-receipt
        # inbound https://developers.clicksend.com/docs/rest/v3/#view-inbound-sms
    except ApiException as e:
        print("Exception when calling SMSApi->sms_send_post: %s\n" % e)
    return
コード例 #7
0
        if x > -1:
            num = num[:x].strip().replace(",", "")

        if num.isdigit():
            if int(num) != url['LastNum']:
                if url['LastNum'] > 0:
                    msg += f"{url['Company']}: Old:{url['LastNum']}, Current:{num}\n"
                s = f"update JodyEmployees set LastNum = {num} where intID = {url['intID']}"
                SQLExec(s, cursor, conn)

    if msg != "":
        configuration = clicksend_client.Configuration()
        configuration.username = smsUser
        configuration.password = smsPass

        api_instance = clicksend_client.SMSApi(
            clicksend_client.ApiClient(configuration))
        toSend = []
        for phone in phones:

            toSend.append(
                SmsMessage(source="python", _from=srcPhone, body=msg,
                           to=phone))
        sms_messages = clicksend_client.SmsMessageCollection(messages=toSend)

        try:
            api_response = api_instance.sms_send_post(sms_messages)
            print(api_response)
        except ApiException as e:
            print("Exception when calling SMSApi->sms_send_post: %s\n" % e)

    s = "update JodyConfig set LastChecked = getdate()"
コード例 #8
0
ファイル: wemo.py プロジェクト: nebriv/wemoLivePowerMonitor
    def __init__(self, config, bgRun=True):
        self.config = config
        if "Elasticsearch" in config:
            esHost = config['Elasticsearch']['host']
            esUser = config['Elasticsearch']['username']
            esPass = config['Elasticsearch']['password']
            esPort = config['Elasticsearch']['port']
            self.es = Elasticsearch([esHost],
                                    http_auth=(esUser, esPass),
                                    ssl_show_warn=False,
                                    verify_certs=False,
                                    port=esPort)

        if "Notifications" in config:
            if "clicksendAPI_username" in config['Notifications']:
                configuration = clicksend_client.Configuration()
                configuration.username = config['Notifications'][
                    'clicksendAPI_username']
                configuration.password = config['Notifications'][
                    'clicksendAPI_password']
                self.notificationNumber = config['Notifications'][
                    'phonenumber']
                # create an instance of the API class
                self.smsAccountAPI = clicksend_client.AccountApi(
                    clicksend_client.ApiClient(configuration))
                try:
                    # Get account information
                    api_response = self.smsAccountAPI.account_get()
                    if "http_code': 200" not in api_response:
                        print("Invalid clicksend API response")
                        print(api_response)
                        self.smsAccountAPI = False
                    else:
                        self.smsAPI = clicksend_client.SMSApi(
                            clicksend_client.ApiClient(configuration))

                except ApiException as e:
                    print(
                        "Exception when calling AccountApi->account_get: %s\n"
                        % e)
                except Exception as err:
                    print("Eception when calling clicksend API")
                    print(err)

        if "Wemo" in config:
            if "AlwaysOn" in config['Wemo']:
                print("Loading always on devices")
                self.alwaysOnDevices = config['Wemo']['AlwaysOn'].split(",")

        if self.es:
            print("Connecting to ES")
            try:
                if not self.es.ping():
                    print(self.es.ping())
                    raise ConnectionError(
                        "Error connecting to Elasticsearch host: %s" % esHost)
            except Exception as err:
                print("Error connecting to ES")
        self.discovery()
        self.bgRun = bgRun

        if self.bgRun:
            self.bgUpdateThread = threading.Thread(target=self.update)
            self.bgUpdateThread.start()
コード例 #9
0
 def __init__(self) -> None:
     configuration = clicksend_client.Configuration()
     configuration.username = self.USERNAME
     configuration.password = self.PASSWORD
     self.api_instance = clicksend_client.SMSApi(
         clicksend_client.ApiClient(configuration))