Example #1
0
def Client(conn, ip, port):
    msg = "Bien connecté"
    msg = msg.encode("utf8")
    conn.send(msg)

    while True:
        requete = conn.recv(1024).decode("utf8")
        if not requete:
            print("connection du client fermée")
            conn.close()
            break
        print("requete de l'utilisateur: " + str(requete))  #just for debug
        req = requete.split(" ")
        if (req[0] == "create"):
            if (req[1] == "database"):
                creerBD.creerBD(requete)
            if (req[1] == 'table'):
                creerTable.creeTable(requete)
        if (req[0] == "insert"):
            insertion.insert(requete)
        if (req[0] == "select"):
            selector.select(requete)
        # if(req[0] == "delete"):
        #     supprimer.delete(requete)
        reponse = "Bien passé"
        conn.send(reponse.encode("utf8"))  # send data to the client
Example #2
0
class FindMeetings(Command):
    """ Find meetings points between flights """

    option_list = selector_options + (
        Option('--force',
               action='store_true',
               help='re-analyse all flights, not just the scheduled ones'),
        Option('--async',
               action='store_true',
               help='put flights in celery queue'),
    )

    def run(self, force, async, **kwargs):
        q = db.session.query(Flight)
        q = q.order_by(Flight.id)

        q = select(q, **kwargs)

        if not q:
            quit()

        if not force:
            q = q.filter(Flight.needs_analysis == True)

        if async:
            current_app.add_celery()

        self.incremental(lambda f: self.do(f, async=async), q)
def main():
    stime=time.time()
    i=0
    for im in selector.select(-1):
        imstat.writeStats(im, "imstats/final02/")
        print(str(i) + "\t" + str(time.time()-stime))
        i += 1
Example #4
0
    def __init__(self, screen, width, length, tickrate):
        """a world is an isolated container of blocks and entitys"""
        self._matrix = []

        curses.textpad.rectangle(screen, 0, 0, curses.LINES - 1,
                                 curses.COLS - 2)
        self._game_screen = curses.newwin(20, 20, 1, 2)

        screen.refresh()

        self._selector = selector.select([], curses.newwin(20, 20, 1, 24))
        self.tickrate = tickrate
        self.width = width
        self.length = length

        self.key_press = None
        self.entitys = []

        row = []
        for _ in range(length):
            for _ in range(width):
                r = random.random()
                if r >= 0.1:
                    row.append(block.earth(self))
                else:
                    row.append(block.tree(self))

            self._matrix.append(row)
            row = []
Example #5
0
def openfile():
    '''
    Obsługa kliknięcia "Open file". Otwiera plik z angielskim tekstem i rozpoczyna ankietę.

    :return: None
    '''
    homedir = expanduser("~")
    filename = askopenfilename(initialdir=homedir + "/Desktop",
                               title="Choose text file")
    if filename:
        with open(filename, 'r') as fh:
            words = selector.select(fh)
            init_survey(words, True)
def main():
    methods = [stm.same, stm.predicterror2, lambda x: stm.haar(x, level=3), lambda x: stm.haar(stm.predicterror2(x, raw_image=True), level=3)]
    
    clearlist = selector.select(TRIALS)
    path = "../data/nnopt/" + str(RUN) +'/lists/' + "clear.txt"
    checkpath(path)
    file = open(path, "w")
    file.write(','.join(clearlist))
    file.close
    for im in clearlist:
        imstat.writeStats(im, "imstats/nnopt/" + str(RUN) + "/clear/", img=randLsb.rand(im, 0, flatten=True), methods=methods)
    print "Clear Done"
    
    for rate in [.01,.05,.1,.2,.3,.5,.8,1.0]:
        stegolist = selector.select(TRIALS)
        path = "../data/nnopt/" + str(RUN) +'/lists/' + str(int(rate*100)) + ".txt"
        checkpath(path)
        file = open(path, "w")
        file.write(','.join(stegolist))
        file.close
        for im in stegolist:
            imstat.writeStats(im, "imstats/nnopt/" + str(RUN) + "/" + str(int(rate*100)) + "/", img=randLsb.rand(im, rate, flatten=True), methods=methods)
        print str(rate) + " Done"
Example #7
0
def find_and_open_note(dirpath):
    filenames = [x for x in os.listdir(dirpath) if not x.startswith('.')]
    result = select(
        options_by_appending_option(options_from_list(filenames), '+ create'))
    if not result.selected:
        return
    selected_create_new_note = len(result.options) == 1
    if selected_create_new_note:
        filename = result.typed
        if '.' not in filename:
            filename += DEFAULT_EXTENSION
    else:
        filename = result.selected
    subprocess.call(['vim', os.path.join(dirpath, filename)])
Example #8
0
    def run(self, force, **kwargs):
        q = db.session.query(Flight)
        q = q.options(joinedload(Flight.igc_file))
        q = q.order_by(Flight.id)

        q = select(q, **kwargs)

        if not q:
            quit()

        if not force:
            q = q.filter(Flight.needs_analysis == True)

        self.incremental(self.do, q)
    def run(self, force, **kwargs):
        q = db.session.query(Flight)
        q = q.options(joinedload(Flight.igc_file))
        q = q.order_by(Flight.id)

        q = select(q, **kwargs)

        if not q:
            quit()

        if not force:
            q = q.filter(Flight.needs_analysis == True)

        self.incremental(self.do, q)
Example #10
0
 def play(self):
     printer.print_color_text("\n開始:", printer.textPink)
     user = selector.select(self.items)
     computer = random.randint(0, len(self.items) - 1)
     printer.print_color_text("", printer.textPink)
     printer.print_color_text(
         "你選擇" + self.items[user] + ",電腦出" + self.items[computer] + "。",
         printer.textPink)
     if user - computer == -1:
         printer.print_color_text("恭喜,你贏了!!", printer.textGreen)
     elif user - computer == 1:
         printer.print_color_text("你輸了!!", printer.textRed)
     else:
         printer.print_color_text("平手,再來一次!!", printer.default)
         self.play()
Example #11
0
    def run(self, force, **kwargs):
        current_app.add_celery()

        q = db.session.query(Flight)
        q = q.options(joinedload(Flight.igc_file))
        q = q.order_by(Flight.id)

        q = select(q, **kwargs)

        if not q:
            quit()

        if not force:
            q = q.filter(Flight.needs_analysis == True)

        for flight in q:
            self.do(flight.id)
Example #12
0
    def run(self, force, **kwargs):
        current_app.add_celery()

        q = db.session.query(Flight)
        q = q.options(joinedload(Flight.igc_file))
        q = q.order_by(Flight.id)

        q = select(q, **kwargs)

        if not q:
            quit()

        if not force:
            q = q.filter(Flight.needs_analysis == True)

        for flight in q:
            self.do(flight.id)
Example #13
0
def find_and_open_note(dirpath):
    filenames = [x for x in os.listdir(dirpath) if not x.startswith('.')]
    result = select(
        options_by_appending_option(
            options_from_list(filenames),
            '+ create'
        )
    )
    if not result.selected:
        return
    selected_create_new_note = len(result.options) == 1
    if selected_create_new_note:
        filename = result.typed
        if '.' not in filename:
            filename += DEFAULT_EXTENSION
    else:
        filename = result.selected
    subprocess.call(
        ['vim', os.path.join(dirpath, filename)]
    )
Example #14
0
    def run(self, confirm, **kwargs):

        query = db.session.query(Flight) \
            .outerjoin(Flight.takeoff_airport) \
            .join(IGCFile) \
            .order_by(Flight.id)

        query = select(query, **kwargs)

        if not query:
            quit()

        for flight in query:
            print "Flight: " + str(flight.id) + " " + flight.igc_file.filename

            if confirm:
                files.delete_file(flight.igc_file.filename)
                db.session.delete(flight)
                db.session.delete(flight.igc_file)
                db.session.commit()
Example #15
0
    def run(self, confirm, **kwargs):

        query = db.session.query(Flight) \
            .outerjoin(Flight.takeoff_airport) \
            .join(IGCFile) \
            .order_by(Flight.id)

        query = select(query, **kwargs)

        if not query:
            quit()

        for flight in query:
            print("Flight: " + str(flight.id) + " " + flight.igc_file.filename)

            if confirm:
                files.delete_file(flight.igc_file.filename)
                db.session.delete(flight)
                db.session.delete(flight.igc_file)
                db.session.commit()
Example #16
0
    def run(self, dest, **kwargs):
        if not os.path.exists(dest):
            print "Creating destination directory: " + dest
            os.makedirs(dest)

        query = db.session.query(Flight) \
            .join(Flight.takeoff_airport) \
            .join(IGCFile) \
            .order_by(Flight.id)

        query = select(query, **kwargs)

        if not query:
            quit()

        for flight in query:
            print "Flight: " + str(flight.id) + " " + flight.igc_file.filename
            src = os.path.join(current_app.config['SKYLINES_FILES_PATH'],
                               flight.igc_file.filename)
            shutil.copy(src, dest)
Example #17
0
    def __init__ (self,stdscr):
        curses.curs_set(False)
        os.chdir("./entries")
        self.ax = 2
        self.ay = 2
        self.ex = curses.COLS-2
        self.ey = curses.LINES-3
        self.width = self.ex - self.ax
        self.height = self.ey -self.ay
        self.control_entrys = ["--------","<new>","<options>"]
        
        curses.init_pair(1,curses.COLOR_WHITE,curses.COLOR_GREEN)
        curses.init_pair(2,curses.COLOR_WHITE,curses.COLOR_YELLOW)
        curses.init_pair(3,curses.COLOR_WHITE,curses.COLOR_RED)
        
        self.screen = stdscr
        rectangle(self.screen,0,0,curses.LINES-1,curses.COLS-2)
        self.screen.refresh()


        
        self.body = curses.newwin(self.height,self.width,self.ay,self.ax)
        
        
        self.s_select_data = self.body.subwin(self.height,int(self.width*(2/3)), \
                                           self.ay,int(self.width/3))

        s_selection = curses.newwin(self.height,int(self.width/3-2),self.ay,self.ax)
        self.selector = selector.select([],s_selection)

        self._loadentries()


        
        
        self.data = {"title":"Welcome to this programm","desc":"Tutorial coming soon","info":"","from":"","until":"","importance":1}
        self.mode = "select"
        self.display()

        while True:
            self.loop()
Example #18
0
    def run(self, dest, **kwargs):
        if not os.path.exists(dest):
            print("Creating destination directory: " + dest)
            os.makedirs(dest)

        query = db.session.query(Flight) \
            .join(Flight.takeoff_airport) \
            .join(IGCFile) \
            .order_by(Flight.id)

        query = select(query, **kwargs)

        if not query:
            quit()

        for flight in query:
            print("Flight: " + str(flight.id) + " " + flight.igc_file.filename)
            src = os.path.join(
                current_app.config['SKYLINES_FILES_PATH'],
                flight.igc_file.filename
            )
            shutil.copy(src, dest)
Example #19
0
 def __init__(self, target_num=10):
     ''' 当日全部股票 '''
     self.stocks_info = select(read_cache=False)
     self.target_num = target_num
     self.trader = trader()
Example #20
0
File: n.py Project: ch3pjw/selector
from selector import select, make_fuzzy_matcher_from_list, append_msg
import os
import sys
import subprocess

dirpath = os.path.expanduser('~/Dropbox/Notes/')
default_extension = '.md'

l = os.listdir(dirpath)
l = [x for x in l if not x.startswith('.')]
msg = '+ create'
_, typed, selected = select(append_msg(make_fuzzy_matcher_from_list(l), msg))
if not selected:
    sys.exit(0)

filename = selected
if msg == selected:
    filename = typed
    if '.' not in filename:
        filename += default_extension
    open(os.path.join(dirpath, filename), 'a').close()
subprocess.call(
    'subl "{}"'.format(os.path.join(dirpath, filename)),
    shell=True,
)
Example #21
0
 def adjust(self):
     # 10支最小市值股票
     target_stocks_info = select()
     print(target_stocks_info)
Example #22
0
 def adjust(self):
     # 10支最小市值股票 
     target_stocks_info = select()
     print(target_stocks_info)