コード例 #1
0
ファイル: libc_db.py プロジェクト: MatrixLing/libc_db
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
ファイル: main.py プロジェクト: Hydrox6/Stocks-Manager
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
ファイル: main.py プロジェクト: Hydrox6/Stocks-Manager
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
ファイル: DiscordBot.py プロジェクト: louisjmorgan/DiscordBot
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
ファイル: main.py プロジェクト: Hydrox6/Stocks-Manager
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
ファイル: DiscordBot.py プロジェクト: louisjmorgan/DiscordBot
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
ファイル: convert.py プロジェクト: sh4r3m4n/kindle-ttrss
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
ファイル: DiscordBot.py プロジェクト: louisjmorgan/DiscordBot
async def next(ctx):

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

    if voice and voice.is_playing():
コード例 #12
0
ファイル: DiscordBot.py プロジェクト: louisjmorgan/DiscordBot
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}
コード例 #18
0
def get_list():
    return jsonify(get())

@app.route(CONSTANTS['ENDPOINT']['LIST'], methods=['POST'])
コード例 #19
0
ファイル: DiscordBot.py プロジェクト: louisjmorgan/DiscordBot
async def resume(ctx):

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

    if voice and voice.is_paused():