Ejemplo n.º 1
0
def createArtifactFor(s3_client, mongoconn, name):
    # s3_client
    # mongoconn
    users = mongoconn.findUsersByLink(name)
    all_urls = awsconfig.get_s3_bucket_contents(s3_client)

    filter(lambda x: x.startswith(name), all_urls)

    pprint(all_urls)

    userx = []
    user_names = []
    greeting_texts = []
    user_urls = []
    for user in users:
        # pprint(user)
        print(user['name'], user['email'], user['text'], user['url_user'])
        urlendswith = user['url_user'].split('-').pop()
        urlx = ''
        for url in all_urls:
            if urlendswith in url:
                urlx = 'https://birthday-engine.s3-us-west-1.amazonaws.com/' + url
        userx.append((user['name'], user['email'], user['text'], urlx))

        user_names.append(user['name'])
        greeting_texts.append(user['text'])
        user_urls.append(urlx)

        # to get picture = match first part of email in image name.
    # bday_person_name
    # user_names
    # greeting_texts
    # user_urls

    print(name)
    print()
    print(userx)
    if len(userx) > 0:
        main(name, user_names, greeting_texts, user_urls)
    else:
        # Create case of default output using some default inputs
        main(name, ['user_names'], ['Happy Birthday!'], ['user_urls'])
        print("Create case of default output")

    # awsconfig.get
    bl = awsconfig.upload_s3_file(s3_client, awsconfig.BUCKET_NAME,
                                  "output/" + name + ".gif")
    if bl:
        return ("https://birthday-engine.s3-us-west-1.amazonaws.com/" +
                "output/" + name + ".gif")
    else:
        return False
Ejemplo n.º 2
0
def send():
    if(request.method=="POST"):      
        txt=request.form['text']
        if(len(txt)==0):
            flash('*Please paste the file and press index')
            return render_template("front.html")

        for k in list(session):
            print(k)
            session.pop(k,None)   
        session["txt"]=txt
        text.main(1,txt)
        return render_template("front.html",txt=session['txt'])
Ejemplo n.º 3
0
def search():
    if(request.method=="POST"):
        src=request.form["src"]
        if(len(src)==0):
            flash('*The search Bar is empty')
            return render_template("front.html",txt=session['txt'])

        src=src.lower() 

        session['src']=src
        l=[]
        text.main(1,session['txt'])
        l=text.search1(src)
        return render_template("front.html",txt=session['txt'],wrd=session['src'],l=l)
Ejemplo n.º 4
0
    def POST(self):
        str_xml = web.data()  # 获得post来的数据
        print(str_xml)
        xml = etree.fromstring(str_xml)  # 进行XML解析
        print(xml)
        msgType = xml.find("MsgType").text
        print(msgType)
        fromUser = xml.find("FromUserName").text
        print(fromUser)
        toUser = xml.find("ToUserName").text
        print(toUser)
        if msgType == 'text':
            content = text.main(xml)
            return self.render.reply_text(fromUser, toUser, int(time.time()), content)
        elif msgType == 'image':
            # 取得图片的url
            img_url = xml.find("PicUrl").text
            # 服务器存放文件的路径
            imgForder = os.path.join(self.app_root, 'koutu')
            # 下载用户上传的图片
            path = koutu.download_img(img_url, imgForder)

            print(path)
            # 获取素材的mediaID
            mediaId = koutu.get_media_ID(path)

            return self.render.reply_image(fromUser, toUser, int(time.time()), mediaId)
            pass
        else:
            pass
Ejemplo n.º 5
0
def OnFriendMsgs(data):
    print(data)
    if 'CurrentPacket' in data:
        if data['CurrentPacket']['Data']['FromUin']==setting['masterqq']:
            a=text.main(data['CurrentPacket']['Data']['Content'])
            if a!=None:
                send(a,setting['masterqq'])
Ejemplo n.º 6
0
def fileidentification(loc):
    command = subprocess.run(['file', loc], capture_output=True, text=True)
    ans = re.findall(r'\w+', command.stdout)

    if ('PNG' in ans):
        import png
        png.main(loc)

    elif ('JPEG' in ans):
        import jpg
        jpg.main(loc)

    elif ('bitmap' in ans):
        import bmp
        bmp.main(loc)

    elif ('ASCII' in ans):
        import text
        text.main(loc)

    elif ('PDF' in ans):
        import pdf
        pdf.main(loc)

    elif ('WAVE' in ans):
        import wav
        wav.main(loc)

    elif ('Zip' in ans):
        import Zip
        Zip.main(loc)

    elif ('Microsoft' in ans):
        import officefiles
        officefiles.main(loc)

    else:
        print('file not recognisable')
Ejemplo n.º 7
0
def opion(optin):
    if optin == 1 or optin == 9:
        cre_path = input("Enter the project name :")
        print("Checking if the project exists...")
        trying(cre_path)
        if optin == 9:
            deli(cre_path)
    elif optin == 3:
        def_path = "c:/users/hp/documents/github/html"
        os.chdir(def_path)
        os.system("dir")
        cdir = input("Mention the project name to open")
        try:
            mypath = os.path.join(def_path, cdir)
            ch(mypath)
        except OSError as Error:
            print(Error)
            print(f"the project mention {cdir} doesnt exist")
            t.main(optin)
    elif optin == 2:
        cdir = input(
            "Mention the project name (to say i dont recommend this option)")
        def_path = "c:/users/hp/documents/github/html"
        try:
            mypath = def_path
            os.chdir(mypath)
            print(os.getcwd())
            os.system(f"rd {cdir} /s")
        except OSError as Error:
            print(Error)
            print(f"the project mention {cdir} doesnt exist")
            t.main(optin)
    elif optin == 4:
        cdir = input("Mention the project name to archive")
        def_path = "c:/users/hp/documents/github/html"
        try:
            main.di()
        except OSError as Error:
            print(Error)
            print(f"the project mention {cdir} doesnt exist")
            t.main(optin)

    else:
        do = input("Do you want to exit ? :(Y/N)")
        if (do == "y", "Y"):
            exit()
        elif (do == "n", "N"):
            trying(cre_path)
Ejemplo n.º 8
0
def main():

    pygame.init()

    # create all buttons
    and_gate = Button(pygame.image.load("and.png"), pygame.image.load("and1.png"), "and")
    buttons_list.add(and_gate)
    all_sprites.add(and_gate)
    # set coordinates
    and_gate.rect.x = 50
    and_gate.rect.y = 20

    or_gate = Button(pygame.image.load("or.png"), pygame.image.load("or1.png"), "or")
    buttons_list.add(or_gate)
    all_sprites.add(or_gate)
    or_gate.rect.x = 50
    or_gate.rect.y = 80
    # or_gate.setText('OR')

    not_gate = Button(pygame.image.load("not.png"), pygame.image.load("not1.png"), "not")
    buttons_list.add(not_gate)
    all_sprites.add(not_gate)
    not_gate.rect.x = 50
    not_gate.rect.y = 140

    nand_gate = Button(pygame.image.load("nand.png"), pygame.image.load("nand1.png"), "nand")
    buttons_list.add(nand_gate)
    all_sprites.add(nand_gate)
    nand_gate.rect.x = 50
    nand_gate.rect.y = 200

    nor_gate = Button(pygame.image.load("nor.png"), pygame.image.load("nor1.png"), "nor")
    buttons_list.add(nor_gate)
    all_sprites.add(nor_gate)
    nor_gate.rect.x = 50
    nor_gate.rect.y = 260

    xor_gate = Button(pygame.image.load("xor.png"), pygame.image.load("xor1.png"), "xor")
    buttons_list.add(xor_gate)
    all_sprites.add(xor_gate)
    xor_gate.rect.x = 50
    xor_gate.rect.y = 320

    xnor_gate = Button(pygame.image.load("xnor.png"), pygame.image.load("xnor1.png"), "xnor")
    buttons_list.add(xnor_gate)
    all_sprites.add(xnor_gate)
    xnor_gate.rect.x = 50
    xnor_gate.rect.y = 380

    save_gate = Button(pygame.image.load("save.png"), pygame.image.load("save.png"), "save")
    save_list.add(save_gate)
    all_sprites.add(save_gate)
    save_gate.rect.x = 50
    save_gate.rect.y = 500

    # create user sprite
    user = Button(pygame.image.load("user.jpg"), pygame.image.load("user.jpg"), "user")
    all_sprites.add(user)
    close = False

    global hit
    # main loop
    while close == False:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                close = True
            elif event.type == pygame.MOUSEBUTTONDOWN:  # and len(hit)==1):
                if pygame.sprite.spritecollide(user, save_list, False):
                    print("clicked save")
                    # surf = pygame.display.set_mode((320,240))
                    # display_box(surf,"")
                    # print (ask(surf, "Name") + " was entered")
                    # inp = int(inputbox.ask(screen, 'Message'))
                    text.main()
                    b = text.a
                    print("name:", b, type(b))
                    # b=b+".jpg"
                    pygame.image.save(screen, "h.jpg")  # str(b))
                    print("img saved")
                else:
                    check_button(user)

        screen.fill((255, 255, 255))

        pygame.draw.line(screen, (0, 0, 0), (200, 0), (200, 600))

        pos = pygame.mouse.get_pos()
        # screen.(gate,pos1)

        user.rect.x = pos[0]
        user.rect.y = pos[1]
        all_sprites.draw(screen)
        pygame.display.flip()
Ejemplo n.º 9
0
def new_message(client, message):
    if all(char in chars.keys() for char in message.text):
        text.main(message.text, color)