Ejemplo n.º 1
0
def main():
    for a in sys.argv:
        if a == '-v':
            print_version_and_exit()
    
    if len(sys.argv) < 2 or sys.argv[1] == '-h':
        print_usage_and_exit(0)
    
    load_settings()

    command = sys.argv[1]
    arg_parser = make_arg_parser(command)

    import relayevent
    import sendmail
    import server
    import webhook

    if command in ('startserver', 'stopserver'):
        server.main(arg_parser, sys.argv[2:], command[:-6])

    elif command == 'sendmail':
        sendmail.main(arg_parser, sys.argv[2:])
    
    elif command == 'relayevent':
        relayevent.main(arg_parser, sys.argv[2:])

    elif command == 'webhook':
        webhook.main(arg_parser, sys.argv[2:])

    else:
        sys.stderr.write('unknown command "%s"\n\n' % command)
        print_usage_and_exit(-1)
Ejemplo n.º 2
0
def main():
    for a in sys.argv:
        if a == '-v':
            print_version_and_exit()

    if len(sys.argv) < 2 or sys.argv[1] == '-h':
        print_usage_and_exit(0)

    load_settings()

    command = sys.argv[1]
    arg_parser = make_arg_parser(command)

    if command in ('startserver', 'stopserver'):
        server.main(arg_parser, sys.argv[2:], command[:-6])

    elif command == 'sendmail':
        sendmail.main(arg_parser, sys.argv[2:])

    elif command == 'relayevent':
        relayevent.main(arg_parser, sys.argv[2:])

    elif command == 'webhook':
        webhook.main(arg_parser, sys.argv[2:])

    else:
        sys.stderr.write('unknown command "%s"\n\n' % command)
        print_usage_and_exit(-1)
Ejemplo n.º 3
0
def share(folder_id, folder_link, full_name, email, batch, service):
    user_permission = {
        'type': 'user',
        'role': 'reader',
        'emailAddress': email,	
    }
    batch.add(service.permissions().create(
            fileId=folder_id,
            body=user_permission,
            fields='id',
            sendNotificationEmail=False
    ))
    service.files().update(fileId=folder_id, body={'folderColorRgb': '#00FF00'}).execute()

    print('Do you want to email the Drive folder link to ' + email + '? <y/n>')
    if m.getch().decode('ASCII') == 'y':
        body = 'Edbase Physics Drive Folder Link: \n\n' + folder_link + '\n\nPlease do not lose access to this link.'
        message = sendmail.create_message('*****@*****.**', email, 'Physics_' + full_name + '_Edbase', body)
        try:
            sendmail.main(message)
        except Exception:
            print('An error occurred while trying to send an email to ' + email + '.')
Ejemplo n.º 4
0
r = requests.get(f"{base_url}/senator/all")
data = r.json()
emails = [i['sen_email'] for i in data['data'] if emailcheck(i['sen_email'])]


def sendMail():
    message = Mail(
        from_email=os.getenv('hostemail'),  # set sender email as envvar
        to_emails=emails,
        subject="END FSARS NOW!!",  # You can edit this
        plain_text_content=open('message.txt', 'r').read())

    try:
        sg = SendGridAPIClient(
            os.environ.get('API_KEY'))  # add your sendgrid api-key
        resp = sg.send(message)
        return True
    except HTTPError as e:
        print(e.to_dict)
        return False
    else:
        print(e.to_dict)
        return False


for i in list_data:
    for keys, value in dict(i).items():
        if keys == "email":
            print(value)
            main(value)
Ejemplo n.º 5
0
        print local_time(),name,ip,port,"down"
        with open(logfile,'a+') as f:
            print >> f, local_time(), name, alias, ip, port, "down"
        #ssh.run(ip,name)

if __name__ == "__main__":
    if platform.system() == "Windows":
        logfile = "logs\\check.log"
    else:
        logfile = "logs/check.log"
    Time = time.strftime("%Y-%m-%d-%H-%M", time.localtime())
    if os.path.exists(logfile):
        os.rename(logfile,'%s_%s' %(logfile,Time))
    config_file = conf.getConfig("service.ini")
    sections = conf.getSections(config_file)
    # print "日期","时间","服务","主机","端口","状态"
    for service_name in sections:
        items = conf.getItems(config_file,service_name)
        name = items[0][1];alias = items[1][1];protocol = items[2][1];ips = (items[3][1]).split(",");port = items[4][1];index = items[5][1]
        for ip in ips:
            service_url = protocol + "://" + ip + ":" + port + "/" + index
            check_service(service_name,service_url,logfile)
    sendmail.main()