Exemplo n.º 1
0
def sendMessage(number, from_number=from_number):
    message = client.messages.create(to="+" + str(number),
                                     from_=from_number,
                                     body="john")
    if message.status == "failed" or message.status == "undelivered":
        raise ValueError("Message failed/undelivered")
    send()
    return message
def executeStmt(body, cur):
    firstName = body['firstName']['value']
    lastName = body['lastName']['value']
    email = body['email']['value']
    primaryNumber = body['primaryNumber']['value']
    secondaryNumber = body['secondaryNumber']['value']
    morning = 1 if body['bestContactMorning'] else 0
    afternoon = 1 if body['bestContactAfternoon'] else 0
    evening = 1 if body['bestContactEvening'] else 0
    firstDate = body['firstDate']['value']
    firstTime = body['firstTime']['value']
    secondTime = body['secondTime']['value']
    secondDate = body['secondDate']['value']
    thirdTime = body['thirdTime']['value']
    thirdDate = body['thirdDate']['value']
    termsAgree = 1 if body['termsAgree'] else 0
    lastId = int(body['lastId'])

    userInfo = {
        "firstName": firstName,
        "lastName": lastName,
        "email": email,
        "primaryNumber": primaryNumber,
        "secondaryNumber": secondaryNumber,
        'morning': '' if morning == 0 else 'morning',
        'afternoon': '' if afternoon == 0 else 'afternoon',
        'evening': '' if evening == 0 else 'evening',
        'firstDate': firstDate,
        'firstTime': firstTime,
        'secondDate': secondDate,
        'secondTime': secondTime,
        'thirdDate': thirdDate,
        'thirdTime': thirdTime
    }

    stmt = '''
        INSERT INTO userInfo(email, user_id, first_name, last_name, primary_number, 
             secondary_number, contact_morning, contact_afternoon, contact_evening, 
             first_date, first_time, second_date, second_time, third_date, third_time, 
             terms_agreement)
        VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
    '''

    # cur.execute(stmt, (email, lastId, firstName, lastName, primaryNumber, secondaryNumber, morning, afternoon, evening, firstDate, firstTime, secondDate, secondTime, thirdDate, thirdTime, termsAgree))
    cur.execute("select * from userResponse where user_id = (%s)", (lastId))
    data = cur.fetchone()
    cur.execute("select * from question")
    qData = cur.fetchall()
    print(qData)
    sendEmail.send(userInfo, data[1:], [n[1] for n in qData])

    print(data)
Exemplo n.º 3
0
def main():
    """
    Main 
    """
    reference = sys.argv[1]  # reference genome to use
    submitter = sys.argv[2]  # users name
    rnaDir = sys.argv[3]  # rna processing directory name
    workflowID = sys.argv[4]  # workflow ID, used to update GLOW
    token = sys.argv[5]  # GLOW access token
    currDir = os.getcwd()
    runRPKM(currDir, reference)
    for file in os.listdir():
        if file.endswith('final.sort.gz.bam'):
            bam2wig(file)

    updateGLOW(submitter, rnaDir, workflowID, token)
    cleanUp(currDir, submitter, rnaDir, workflowID, token)
    mail.send("RNA-Seq processing complete")
Exemplo n.º 4
0
Arquivo: app.py Projeto: andtun/juki
def postinfo():
    raw_body = request.body.read()
    print("raw body:")
    print(raw_body)
    new_events = request.files.get('sentJson')
    new_events = new_events.file.readlines()[0]
    new_events = new_events.decode("utf-8").encode("unicode_escape")
    print("new events: "+ new_events)


    dct = json.loads(new_events)

    print("DCT IS:", dct)

    print("-----  filling table from db started  -----")

    maildata = []
    
    for event in dct.keys():
        wrkdct = dct[event]
        print(wrkdct)
        name = wrkdct['personInfo']['last_name'].encode('utf-8') + ' ' + wrkdct['personInfo']['first_name'].encode('utf-8')
        form = wrkdct['personInfo']['class']
        print(name)
        a = {}
        a['inOrOut'] = wrkdct['inOrOut']
        a['name'] = name
        a['class'] = form
        maildata.append(a)
        
        #try:
        #    name = rdname(name)
        #except ValueError:
        #    print("Value Error in app.py")
        #    pass
        m = dct[event]['datetime']['date']
        month = m[m.find('.')+1:m.rfind('.')]
        day = m[:m.find('.')]
        # topr = name + " " + convert(month) + " " + str(day)
        # print(topr)
        addPoint(name, convert(month), int(day), form)

    print("-----  table filling finished successfully  -----")
    sendEmail.send(maildata)
Exemplo n.º 5
0
def main():

    logging.basicConfig(
        format='%(asctime)s %(module)s.%(funcName)s:%(levelname)s:%(message)s',
        datefmt='%m/%d/%Y %I_%M_%S %p',
        filename='home-security.log',
        level=logging.DEBUG)

    pir = MotionSensor(4)

    camera = PiCamera()
    camera.rotation = 180

    while True:

        fileName = 'file-' + str(randint(1, 9999)) + '.jpg'
        print('Filename: ', fileName)

        pir.wait_for_motion()
        print('Motion detected!')

        camera.start_preview()
        sleep(5)
        camera.capture('/home/pi/camera-files/%s' % fileName)
        camera.stop_preview()
        print('Image captured!')

        logging.info("Start to uplaod File:  -- \'{}\'".format(fileName))

        uploadPhoto.fileUpload(fileName)
        print('Image Uploaded!')

        sendEmail.send(fileName)
        print('Image Send to Email!')

        logging.info("Completed sending Email!")
        pir.wait_for_no_motion()
        print('No Motion!')
Exemplo n.º 6
0
start_time = datetime.datetime.today()
print("\n\n\n\n【程序开始时间为:】", start_time)
week_dict = {0: '一', 1: '二', 2: '三', 3: '四', 4: '五', 5: '六', 6: '日'}
week_tuple = ['一', '二', '三', '四', '五', '六', '日']
# 判断是不是周四,第周四发送前面7天的数据
if datetime.datetime.now().weekday() != 3:
    exit("今天是周%s,周四才能获取数据\n"
         "请检查服务器时间或者等周四再取数据\n"
         "程序退出.......................\n" %
         week_tuple[datetime.datetime.now().weekday()])
else:
    print("今天是周四,正在获取数据......")
end = (datetime.datetime.now() -
       datetime.timedelta(days=1)).date().strftime('%Y%m%d')
start = (datetime.datetime.now() -
         datetime.timedelta(days=7)).date().strftime('%Y%m%d')
file_name = start + '-' + end + "告警数据"

# 循环发送三级告警
for i in range(1, 4):
    query.read_mysql_to_csv(i, start,
                            datetime.datetime.now().date().strftime('%Y%m%d'))
query.yasuo(file_name)
end_time = datetime.datetime.today()
cost_time = str(end_time - start_time)
message = "fanghuanhua你好:\n" \
          "\t请注意查收%s 到 %s 车平台的告警数据。\n" \
          "PS:请核对数据日期是否准确" % (start, end)
message += "\n数据查询时常长:%s " % cost_time
sendEmail.send(message, file_name + '.tar.gz')
Exemplo n.º 7
0
with open('config.json', 'r', encoding='UTF-8') as fr:
    o = json.load(fr)
    print(o)

baseUrls = o['baseUrls']
interfaces = o['interfaces']
print(baseUrls)
print(interfaces)
for baseUrl in baseUrls:
    baseUrlName = baseUrl['name']
    baseUrlHost = baseUrl['host']
    print(baseUrlName + '-----------' + baseUrlHost)
    for interface in interfaces:
        interfaceName = interface['name']
        interfaceUrl = baseUrlHost + interface['url']
        print(interfaceName + '----------' + interfaceUrl)
        try:
            s = requests.get(interfaceUrl, allow_redirects=False)
        except Exception as e:
            print(e)
        if (200 == s.status_code):
            print(s.status_code)
            print('1111111')
        else:
            print(
                str(s.status_code) + '---' + baseUrlName + '-' +
                interfaceName + '-' + interface['url'])
            sendEmail.send(str(s.status_code), baseUrlName, interfaceName,
                           interface['url'])
Exemplo n.º 8
0
            return True
        else:
            logging.info("IP Address has not changed.")
            return False


pushed = False
logging.info('===== Pushing to DNSPod =====')
for apiParams in secret_config.apiParamsLst:
    pushed |= DNSPod.dnsUpdateRecord(*apiParams)
logging.info('===== Pushing to NameSilo =====')
for apiParams in secret_config.apiParamsLst:
    pushed |= NameSilo.dnsUpdateRecord(*apiParams)

if args.forceSend or pushed:
    logging.info('===== Sending Email =====')
    try:
        log = log_acc.getvalue()
        log_acc.close()

        # TODO find a better way of doing this
        import sys
        sys.path.insert(0, str(script_root.parent / 'SendEmail'))
        from sendEmail import send

        today = datetime.today()
        send("DDNS " + today.strftime('%Y/%m/%d %H:%M:%S'), log)
    except Exception as e:
        logging.error('Unable to send email')
        logging.error(e)
Exemplo n.º 9
0
with open('config.json', 'r',encoding='UTF-8') as fr:
    o = json.load(fr)
    print(o)

baseUrls = o['baseUrls']
interfaces = o['interfaces']
print(baseUrls)
print(interfaces)
results  = []
for baseUrl in baseUrls:
    baseUrlName = baseUrl['name']
    baseUrlHost = baseUrl['host']
    print(baseUrlName + '-----------' + baseUrlHost)
    for interface in interfaces:
        interfaceName = interface['name']
        interfaceUrl = baseUrlHost + interface['url']
        print(interfaceName + '----------' + interfaceUrl)
        try:
            s = requests.get(interfaceUrl, allow_redirects=False)
        except Exception as e:
            print(e)
        if (200 == s.status_code):
            print(s.status_code)
            print('1111111')
        else:
            str1 = str(s.status_code) + '---' + baseUrlName + '-' + interfaceName + '-' + interface['url']
            results.append(str1)
            sendEmail.send(results)


Exemplo n.º 10
0
            else:
                board_dict[workitem['column_name']] = {
                    'point': workitem['story_point'],
                    'items': 1
                }

        htmlTabels = ""
        number = 1
        for key, value in board_dict.items():
            newValue = str(value['point'])
            htmlTabels = htmlTabels + """\
            <tr>
                <th class="smarttable-header">""" + str(number) + """</th>
                <td class="smarttable-header">""" + key + """</td>
                <td class="smarttable-header">""" + str(
                value['items']) + """</td>
                <td class="smarttable-header">""" + str(
                    value['point']) + """</td>
            </tr>
            """
            number += 1

        contents = contents.replace("BURNDOWN_COLUMN_SPLITUP", htmlTabels)

        html = """\
        """ + contents + """
        """
        subject = "VSTS-MINI: Sprint BurnDown " + team['name']
        sendEmail.send(team['email'], subject, html)
        #sys.exit(0)