Пример #1
0
def main():
    if len(argv) == 1:
        usage()

    if argv[1] == 'get':
        if len(argv) == 2:
            get()
        elif argv[2] in ['ubuntu', 'fedora', 'debian', 'arch']:
            get(argv[2])
        else:
            usage()
    elif argv[1] == 'add':
        try:
            libc_file = argv[2]
            add_local_libc(libc_file)
        except:
            usage()
    elif argv[1] == 'find':
        try:
            fun_name = argv[2]
            fun_addr = argv[3]
            find(fun_name, fun_addr)
        except:
            usage()
    elif argv[1] == 'identify':
        try:
            libc_file = argv[2]
            identify(libc_file)
        except:
            usage()
    elif argv[1] == 'status':
        status()
    else:
        usage()
Пример #2
0
def Communication(pool, conn):
    while True:
        try:
            data = conn.recv(1024)
            if not data: break
            print('客户端的数据为', data)

            cmds = data.decode('utf-8').split()
            if cmds[0] == 'get':
                get(cmds, conn)
        except ConnectionResetError:
            break
    pool.put_thread()
    conn.close()
Пример #3
0
def init():
    if os.path.exists("store.csv"):
        fl = open("store.csv","r")
        r = fl.read().split("\n")[:-1]
        fl.close()
        try:
            for x in r:
                d = x.split(",")
                code = d[0]
                dictt = {}
                for y in range(0,2):
                    dictt[columns[y*2][0]] = d[y]
                dictt["initPrice"] = d[2]
                dictt["buydate"] = d[3]
                extra = get(code).dictify()
                dictt.update(extra)
                dictt["Total Price"] = float(dictt["Price"])*float(dictt["Amount"])
                while True:
                    ucode = uuid.uuid4()
                    if not ucode in data:break
                dictt["uuid"] = ucode
                datad[ucode] = dictt
                data.append(ucode)
        except:
            top = Toplevel()
            Label(top,text="The format of store.csv is incorrect.\nData could not be loaded").pack()
            Button(top,text="Ok",command=top.destroy).pack()
Пример #4
0
def actuallyAdd(t,d):
    global datad,data
    t.destroy()
    try: float(d[1])
    except ValueError: pass
    else:
        d[1] = int(d[1].strip())
        nd = {}
        nd["Code"] = d[0].strip().upper()
        nd["Amount"] = d[1]
        extra = get(nd["Code"]).dictify()
        nd["Total Price"] = float(extra["Price"])*float(nd["Amount"])
        nd["initPrice"] = extra["Price"]
        nd["initCur"] = extra["Currency"]
        date = time.gmtime()
        nd["buydate"] = str(date[2])+"/"+str(date[1])+"/"+str(date[0])
        nd.update(extra)
        while True:
            ucode = uuid.uuid4()
            if not ucode in data:break
        nd["uuid"] = ucode
        datad[ucode] = nd
        data.append(ucode)
        save()
        redraw()
Пример #5
0
def client():
    #主逻辑
    from config import setting
    print(setting.PORT)
    phone = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    phone.connect((setting.HOST, setting.PORT))

    while 1:
        #发命令
        msg = input('--')
        if not msg: continue
        phone.send(msg.encode('utf-8'))
        cmds = msg.split()
        if cmds[0] == 'get':
            get(cmds, phone)

    phone.close()
Пример #6
0
async def leave(ctx):
    channel = ctx.message.author.voice.channel
    voice = get(bot.voice_clients, guild=ctx.guild)

    if voice is not None:
        await voice.disconnect()
        print(f'{bot.user} has left {channel}\n')
        await ctx.send(f'Left {channel}')
    else:
        print(f'{bot.user} Unable to leave {channel}\n')
        await ctx.send(f'Unable to leave {channel}')
Пример #7
0
def fetchone(uuid):
    o = datad[uuid]
    cc = o["Currency"]
    extraraw = get(o["Code"])
    extra = extraraw.dictify()
    o["Total Price"] = float(extra["Price"])*float(o["Amount"])
    if not cc == extra["Currency"]:
        extraraw.curconv(cc)
        extra = extraraw.dictify()
    o.update(extra)
    datad[uuid] = o
Пример #8
0
async def join(ctx):
    channel = ctx.message.author.voice.channel
    voice = get(bot.voice_clients, guild=ctx.guild)

    try:
        if voice is not None:
            return await voice.move_to(channel)
        else:
            await channel.connect()

    except AttributeError:
        print('User is not connected to a voice channel')
        return await ctx.send(f'You must be in a voice channel before {bot.user} can join')

    await ctx.send(f'Joined {channel}')
Пример #9
0
def recurse(subreddit, hot_list=[], after=None):
    """Reddit API uses pagination for separating pages of responses."""
    url = 'https://www.reddit.com/r/{}/hot.json'.format(subreddit)
    Agents = {'User-Agent': 'Agent-Subscribe'}
    Response = get(url, headers=Agents,
                   allow_redirects=False, params={'after': after})
    if Response.status_code != 200:
        return None
    else:

        AfterData = Response.json()['data']['after']
        ChildTitles = Response.json()['data']['children']
        for HotArticles in ChildTitles:
            hot_list.append(HotArticles['data']['title'])
        if AfterData is None:
            return hot_list
        return recurse(subreddit, hot_list, AfterData)
Пример #10
0
def genhtml(fecha, url, sid, filename = 'out.html', verbose = False):
    """ Genera un fichero HTML con el resumen de los arículos sin leer."""
    if verbose: print 'Cargando template básico'
    template = open('template.html').read().decode('utf-8')
    if verbose: print 'Obteniendo artículos'
    articulos = get(url, sid, verbose)
    articulos = reversed(articulos) # Ordeno del más viejo al más nuevo
    html = ''
    indice = ''

    for art in articulos:
    	md = ""
    	md += '## [%s](%s)\n' % (art['title'], art['link'])
    	md += '#### Link: [%s](%s)\n' % (art['link'], art['link'])
    	md += '#### Feed: %s\n' % art['feed_title']
    	md += '#### Autor: %s\n' % art['author']
    	md = markdown(md)
    	i = art['id']
    	unread = "Para marcar como no leido, subrayar: __UNREAD__%s" % i 
    	html += '<article id="art-%s">%s\n%s\n%s</article><hr />\n' % (i, md,
    			art['content'], unread)

    	indice += '<li>%s: %s (ART%s)</li>' % \
    			(art['feed_title'], art['title'], i)

    # Escribimos en el fichero, teniendo el HTML básico en template.html
    if verbose: print 'Guardando HTML en', filename
    document_code = random.randint(0,99999999) # Identificador único
    write = template % dict(html=html, indice=indice, fecha=fecha, 
    		readall = '__READALL__%s'%document_code)
    arc = open(filename,'w')
    arc.write(write.encode('utf-8'))
    arc.close()

    # Guardamos la lista de artículos del documento
    database = 'db_%s' % document_code
    if verbose: print 'Guardando base de datos en', database
    f = open(database, 'w')
    f.write(','.join([str(art['id']) for art in \
    		articulos])) # IDs separados por coma
    f.close()
Пример #11
0
async def next(ctx):

    voice = get(bot.voice_clients, guild=ctx.guild)

    if voice and voice.is_playing():
Пример #12
0
async def stop(ctx):

    voice = get(bot.voice_clients, guild=ctx.guild)
Пример #13
0
        elif 'open notepad plus plus' in query:
            npath = "C:/Program Files (x86)/Notepad++/notepad++.exe"
            os.startfile(npath)
            speak("open notepad plus plus")
        elif "close notepad plus plus" in query:
            os.system("taskkill /f /im notepad++.exe")
            speak("okay sir, closing notepad plus plus")
        elif "open command prompt" in query or "open cmd" in query:
            os.system("start cmd")
            speak("open CMD")
        elif "close command prompt" in query or "close cmd" in query:
            os.system("taskkill /f /im cmd.exe")
            speak("okay sir, closing CMD")

        elif "ip address" in query:
            ip = get("https://api.ipify.org").text
            speak(f'your IP address is {ip}')
        elif "open message" in query:
            kit.sendwhatmsg("+919799623173", "hello", 3, 22)
        elif "play song on youtube" in query:
            speak("tell me songe ")
            song = takeCommand()
            kit.playonyt(song)
        elif "open notepad" in query:
            speak("okay sir, open notepad ")
            os.system("notepad.exe")

        elif "open vlc" in query or "open vlc player" in query:
            speak("okay sir, open vlc player ")
            os.system("start vlc")
Пример #14
0
class BookResource(pyrestful.rest.RestHandler): @get(_path="/books/json/{isbn}", _types=[int], _produces=mediatypes.APPLICATION_JSON) def getBookJSON(self, isbn):		book = Book()		book.isbn = isbn		book.title = "My book for isbn "+str(isbn)
Пример #15
0
def cmdline_download(*args):
    '''
    download <url> <targetdir> [<result>]
    '''
    get(*args)
    return 0
Пример #16
0
#C'est dans fichier qu'on va mettre le script pour se connecter sur facebook
import os.environ import get
from browser import navigateur

numero_email = get('numero')
passwd = get('mdp')

    

Пример #17
0
class EchoService(pyrestful.rest.RestHandler): @get(_path="/echo/{name}", _produces=mediatypes.APPLICATION_JSON) def sayHello(self, name): return {"Hello":name}
def get_list():
    return jsonify(get())

@app.route(CONSTANTS['ENDPOINT']['LIST'], methods=['POST'])
Пример #19
0
async def resume(ctx):

    voice = get(bot.voice_clients, guild=ctx.guild)

    if voice and voice.is_paused():