コード例 #1
0
    def POST(self):
        input = web.input(team_id = None)
        if input.team_id == None:
            return output(110)
        try:
            input.team_id = int(input.team_id)
        except:
            return output(111)

        db = getDb()
        team_info = db.select('team', vars = {'id':input.team_id}, where = "team_id=$id")

        if len(team_info) == 0:
            return output(464)

        team = team_info[0]
        team_info = db.select('teaminfo', vars = {'id':input.team_id}, where = "team_id=$id")
        if len(team_info) == 0:
            description = None
            project_desc = None
            logo_base64 = None
        else:
            team_info = team_info[0]
            description = team_info.description
            project_desc = team_info.project_desc
            logo_base64 = team_info.logo_base64
        return output(200, {'team_id':team.team_id, 'team_name':team.team_name,
                            'description':description,
                            'project_description':project_desc,
                            'logo_base64':logo_base64})
コード例 #2
0
    def getTeamApplyList():
        session = web.ctx.session
        if not session.has_key('user_id'):
            return output(411)
        if session['user_type'] != 0:
            return output(410)

        db = getDb()
        results = db.select('application', where = "status='ongoing'",
                            order = "application_id desc")
        app_list = []
        for i in results:
            if i.status == 'ongoing':
                status = 0
            elif i.status == 'accepted':
                status = 1
            else:
                status = 2
            app_list.append({'application_id':i.application_id, 'user_id':i.user_id,
                             'new_team_name':i.new_team_name, 'add_time':i.add_time,
                             'status': status})

        for i in app_list:
            userinfo = db.select('userinfo', vars = {'id':i['user_id']},
                             where = "user_id=$id", what = "name, phone")[0]
            i['phone'] = userinfo.phone
            i['name'] = userinfo.name
        return output(200, app_list)
コード例 #3
0
ファイル: zqx.py プロジェクト: potatoQi/Program-FastListen
def main():
    screen.fill(BackColor)
    output.output("开发:周其星(Error_666)", 350, 20)
    output.output("w为进入曲库,e为管理曲库,ESC为退出程序", 350, 200)
    output.output("请按下相应键", 350, 300)
    running = 1
    while running:
        i = pygame.event.wait()
        if i.type == KEYDOWN:
            sta = 0
            if i.key == K_w: sta = musicList()
            elif i.key == K_e: sta = musicUpd()
            elif i.key == K_ESCAPE: running = 0
            if sta == -1:
                screen.fill(BackColor)
                output.output("w为进入曲库,e为管理曲库,ESC为退出程序", 350, 200)
                output.output("请按下相应键", 350, 300)
            elif sta == -2:
                running = 0
コード例 #4
0
ファイル: button.py プロジェクト: pjenke/makerguy
 def run(self):
     output("Button thread started")
     while self.isRunning:
         # Die Überprüfung des Zustandes findet alle 0.5s statt
         time.sleep(0.1)
         # Der letzte Zustand des GPIO wird protokolliert, hier zurückgesetzt.
         # Der Zustand HIGH zeigt, dass der Taster nicht gedrückt ist.
         if (GPIO.input(self.pin) == GPIO.HIGH):
             self.lastState = GPIO.HIGH
         # Wenn der Zustand auf LOW wechselt, wurde der Taster gedrückt; die Routine
         # zum Behandeln des Ereignisses wird aufgerufen
         if (GPIO.input(self.pin) == GPIO.LOW
                 and self.lastState == GPIO.HIGH):
             self.lastState = GPIO.LOW
             # Aufrufen der Ereignis-Verarbeitung
             self.eventHandler()
             # Kurze Pause, bis die nächste Zustandsänderung abgeprüft wird
             time.sleep(1)
     output("Button thread ended")
コード例 #5
0
ファイル: decorator.py プロジェクト: vanshin/reading
 def __(*args, **kwargs):
     reading_json = request.get_json(force=True, silent=True)
     logging.debug('reading_json type=%s' % type(reading_json))
     r_id = reading_json.get('reading_id')
     edit_user_id = kwargs.get('id', 0)
     user_list = Reading.query.filter_by(id=r_id).all()
     if edit_user_id in user_list:
         return func(*args, **kwargs)
     else:
         return output()
コード例 #6
0
ファイル: bfs.py プロジェクト: nickrinaldi/AI
def bfsFindPath(initialState):
    startTime = time.time()
    exploredSet = set()
    fringeSet = set([initialState])
    visitedByDict = {}
    frontierQueue = Queue()
    frontierQueue.put((initialState, 0))

    maxFringeSize = 0
    maxSearchDepth = 0

    while not frontierQueue.empty():
        currentState, searchDepth = frontierQueue.get()

        if currentState in fringeSet:
            fringeSet.remove(currentState)

        if maxSearchDepth < searchDepth:
            maxSearchDepth = searchDepth

        if currentState.isGoalState():
            endTime = time.time()
            output(visitedByDict, initialState, currentState, len(exploredSet),
                   len(fringeSet), maxFringeSize, searchDepth, maxSearchDepth,
                   (endTime - startTime))
            return

        exploredSet.add(currentState)

        connectedStates = currentState.getConnectedStates()
        for connectedState in connectedStates:
            if connectedState[0] not in fringeSet and connectedState[
                    0] not in exploredSet:
                fringeSet.add(connectedState[0])
                visitedByDict[connectedState[0]] = (currentState,
                                                    connectedState[1])
                frontierQueue.put((connectedState[0], searchDepth + 1))

        if maxFringeSize < len(fringeSet):
            maxFringeSize = len(fringeSet)

    # if we reach this far in execution, the goal state is unobtainable
    print "unobtainable goal state"
コード例 #7
0
ファイル: detail.py プロジェクト: rippletec810/base_platform
    def POST(self):
        input = web.input(team_id=None)
        session = web.ctx.session
        if session.has_key('user_id'):
            if input.team_id == None and session['user_type'] in (2, 3, 4):
                input.team_id = session['team_id']
        if input.team_id == None:
            return output(110)
        try:
            input.team_id = int(input.team_id)
        except:
            return output(111)

        db = getDb()
        team_info = db.select('team',
                              vars={'id': input.team_id},
                              where="team_id=$id")

        if len(team_info) == 0:
            return output(464)

        team = team_info[0]
        team_info = db.select('teaminfo',
                              vars={'id': input.team_id},
                              where="team_id=$id")
        if len(team_info) == 0:
            description = None
            project_desc = None
            logo_base64 = None
        else:
            team_info = team_info[0]
            description = team_info.description
            project_desc = team_info.project_desc
            logo_base64 = team_info.logo_base64
        return output(
            200, {
                'team_id': team.team_id,
                'team_name': team.team_name,
                'description': description,
                'project_description': project_desc,
                'logo_base64': logo_base64
            })
コード例 #8
0
 def test_output(self):
     logger = mock.Mock()
     with mock.patch('sys.stdout') as mock_print:
         output(logger, TEST_NEWS_LIST)
         mock_print.assert_has_calls(
             [
                 mock.call.write('--------------------------------------------------------'),
                 mock.call.write('\n'),
                 mock.call.write("Title: Some title"),
                 mock.call.write('\n'),
                 mock.call.write("Date: Sun, 17 Nov 2019 15:35:00 -0500"),
                 mock.call.write('\n'),
                 mock.call.write("Link: link"),
                 mock.call.write('\n'),
                 mock.call.write("Summary: Test text"),
                 mock.call.write('\n'),
                 mock.call.write("Source of image: img_link"),
                 mock.call.write('\n'),
             ]
         )
コード例 #9
0
    def POST(self):
        input = web.input(payment_type_list=None)
        if input.payment_type_list == None:
            return output(110)

        session = web.ctx.session
        if not session.has_key('user_id'):
            return output(411)
        if session['user_type'] not in (0, 1):
            return output(410)

        db = getDb()
        try:
            db.update('payment_type',
                      vars={'id': 1},
                      where="id=$id",
                      data=input.payment_type_list)
        except:
            return output(700)
        return output(200)
コード例 #10
0
def print_rating(a, t, tokens_lists, blacklist=set(), rating_limit=20):
    """Returns three numbers:
1) count of all types of tokens,
2) count of all real words in dictionary,
3) count of 'whitelisted' words."""
    words = {}
    for i, _list in enumerate(tokens_lists):
        for j, token in enumerate(_list):
            if token in words:
                words[token] = words[token] + 1
            else:
                words[token] = 1
    nominees = sorted(words.keys(), key=lambda v: words[v], reverse=True)
    real_words = filter(lambda v: lexem_type(v[0]) == 'L', nominees)
    whitelist = filter(lambda v: v not in blacklist, real_words)
    for i, word in enumerate(whitelist):
        if i >= rating_limit:
            break
        place = i + 1
        output(a, t, u"""{:5} {:5} {}""".format(place, words[word], word))
    return len(words), len(real_words), len(whitelist)
コード例 #11
0
    def GET(self):
        input = web.input(application_id=None)
        if input.application_id == None:
            return output(110)

        try:
            input.application_id = int(input.application_id)
        except:
            return output(111)

        session = web.ctx.session
        if not session.has_key('user_id'):
            return output(411)
        if session['user_type'] not in (0, 1):
            return output(410)

        db = getDb()
        results = db.select('application',
                            vars={'id': input.application_id},
                            where="application_id=$id",
                            what="excel_file")
        if len(results) == 0:
            return output(469)

        return output(200, {'content': results[0].excel_file})
コード例 #12
0
    def getApplyList():
        session = web.ctx.session
        if not session.has_key('user_id'):
            return output(411)

        db = getDb()
        apply_list = []
        if session['user_type'] in (0, 1):
            results = db.select('room_apply',
                                where="status='ongoing'",
                                order='add_time desc, room_apply_id desc')
        else:
            results = db.select('room_apply',
                                order='add_time desc, room_apply_id desc')
        for i in results:
            if i.status == 'ongoing':
                status = 0
            elif i.status == 'approved':
                status = 1
            else:
                status = 2

            apply_list.append({
                'room_apply_id': i.room_apply_id,
                'team_name': i.team_name,
                'user_id': i.user_id,
                'place_name': i.place_name,
                'begin_time': i.begin_time,
                'end_time': i.end_time,
                'add_time': i.add_time,
                'status': status
            })

        for i in apply_list:
            name = db.select('userinfo',
                             vars={'id': i['user_id']},
                             where='user_id=$id',
                             what='name')[0].name
            i['name'] = name
        return output(200, apply_list)
コード例 #13
0
    def getTeamApplyDetailGet():
        input = web.input(application_id=None)
        if input.application_id == None:
            return output(110)

        try:
            input.application_id = int(input.application_id)
        except:
            return output(111)

        session = web.ctx.session
        if not session.has_key('user_id'):
            return output(411)
        if session['user_type'] != 0:
            return output(410)

        db = getDb()
        results = db.select('application',
                            vars={'id': input.application_id},
                            where="application_id=$id",
                            what="materials")
        if len(results) == 0:
            return output(469)

        return output(200, {'content': results[0].materials})
コード例 #14
0
ファイル: gym.py プロジェクト: jgblight/halite3
def run_matches(db_path, hlt_path, output_dir, map_dimensions, iterations):
    flags = []

    if output_dir:
        abs_output_dir = os.path.abspath(output_dir)
        os.makedirs(abs_output_dir, exist_ok=True)
        flags = ['-i', abs_output_dir]

    for i in range(iterations):
        map_size = random.choice(map_dimensions)
        with connect(db_path) as conn:
            all_bots = list_bots(conn)
            num_players = random.choice((2, 4))
            if len(all_bots) < MIN_PLAYERS:
                output.error('Need at least {} bots registered to play.'.format(MIN_PLAYERS))
                sys.exit(1)
            elif len(all_bots) < num_players:
                num_players = MIN_PLAYERS

            random.shuffle(all_bots)
            bots = all_bots[:num_players]

        overrides = []
        for bot in bots:
            overrides.append('-o')
            overrides.append(bot['name'])
        raw_results = compare_bots._play_game(hlt_path,
                                              map_size[0], map_size[1],
                                              [bot['path'] for bot in bots],
                                              flags + overrides)
        results = json.loads(raw_results)
        with connect(db_path) as conn:
            add_match(conn, bots, results)

        output.output('Played {}/{} matches...'.format(i + 1, iterations),
                      progress=i + 1,
                      iterations=iterations,
                      results=results,
                      participants=bots)
    output.output('Done playing games.', progress=iterations, iterations=iterations)
コード例 #15
0
    def addUkn(cls, conf):
        """check if the outputer is known

        """

        # create a fake object for checking method name
        o = output.output()

        if not o.checkMethodName(conf['engine']):
            logging.error(
                "unknown output method name '{}', possible values are : {}".
                format(conf['engine'], ", ".join(o.getMethodName())))
            assert False, "bad output name"
コード例 #16
0
ファイル: edit.py プロジェクト: rippletec810/base_platform
    def POST(self):
        input = web.input(goods_id = None, goods_name = None, goods_price = None)
        if input.goods_id == None or (input.goods_name == None and input.goods_price == None):
            return output(110)
        try:
            input.goods_id = int(input.goods_id)
            if input.goods_price != None:
                input.goods_price = float(input.goods_price)
        except:
            return output(111)

        if input.goods_price != None and input.goods_price <= 0:
            return output(112)

        if input.goods_name != None:
            input.goods_name = input.goods_name.strip()
            length = len(input.goods_name)
            if length > 20 or length < 1:
                return output(112)

        session = web.ctx.session
        if not session.has_key('user_id'):
            return output(411)
        if session['user_type'] not in (0, 1):
            return output(410)

        db = getDb()
        try:
            vars = {'id':input.goods_id}
            where = "good_id=$id"

            if len(db.select('goods', vars = vars, where = where)) == 0:
                return output(472)
            if input.goods_name == None:
                db.update('goods', vars = vars, where = where, price = input.goods_price)
            elif input.goods_price == None:
                db.update('goods', vars = vars, where = where, good_name = input.goods_name)
            else:
                db.update('goods', vars = vars, where = where, good_name = input.goods_name, price = input.goods_price)
        except:
            return output(700)

        return output(200)
コード例 #17
0
 def prevSong(self):
     output("Prev-Button - prev song")
     self.last_interaction_time = datetime.datetime.now()
     if self.current_album in self.songs:
         album = self.songs[self.current_album]
         if self.current_song_index > 0:
             self.current_song_index = self.current_song_index - 1
             output('{}{}'.format("Playing prev song with index ",
                                  self.current_song_index))
             self.player.stop()
             self.player.play(album.titelliste[self.current_song_index])
             self.printCurrentSong()
         else:
             output("Reached first song of album!")
     else:
         output("Invalid album: " + self.current_album)
コード例 #18
0
ファイル: add.py プロジェクト: potatoQi/Program-FastListen
def add():
	screen.fill(BackColor)
	file_path = filedialog.askopenfilenames()
	flag = 0
	for f in file_path:
		shutil.copy(f, "music")
		f1 = f[::-1]
		f2 = ""
		for c in f1:
			if c == '/': break
			f2 = f2 + c
		f2 = f2[::-1]
		f2 = f2[:-4]
		id = f2
		content = open("txt/id.txt", "a", encoding="utf-8")
		tot = getLine() + 1
		if tot == 1: content.write("1: " + id)
		else: content.write('\n' + str(tot) + ": " + id)
		content.close()
		flag = 1
	if flag == 1:
		output.output("添加成功!", 350, 200)
		time.sleep(3)
コード例 #19
0
    def POST(self):
        input = web.input(login_name=None, password=None)
        if input.login_name == None or input.password == None:
            return output(110)

        db = getDb()
        results = db.select('user',
                            vars={'login_name': input.login_name},
                            where="login_name=$login_name")
        if len(results) == 0:
            return output(422)
        user = results[0]
        if user.type == '2':
            return output(422)
        if user.password != encrypt(input.password):
            return output(430)

        session = web.ctx.session
        session['user_id'] = user.user_id
        session['login_name'] = user.login_name
        session['user_type'] = int(user.type)

        return output(200, {'type': int(user.type)})
コード例 #20
0
ファイル: play.py プロジェクト: potatoQi/Program-FastListen
def play(fl, tag):
    if fl == "error": return -1
    screen.fill(BackColor)
    global val, tim
    if tag == -1:
        val = music.get_volume()
        tim = 1
    else:
        val = 0.5
        tim = 1
        music.load(fl)
        music.play()
        music.set_volume(val)
    name = erase.getName(fl)
    output.output(name, 350, 100)
    output.output("音量:%d" % int(val * 100) + '%', 350, 200)
    output.output("空格为暂停/播放,↑↓键调节音量", 350, 350)
    output.output("s为上一首,d为下一首", 350, 380)
    output.output("w回到曲库,ESC退出程序", 350, 410)
    while True:
        if music.get_busy() == 0: return fl
        i = pygame.event.wait()
        if i.type == KEYDOWN:
            volUpd(i.key, name)
            sta = staUpd(i.key)
            if sta == -1: return fl
            if sta == -2: return "exit^"
            if i.key == K_s:
                id = erase.getId(fl)
                if add.getLine() == id: id = 1
                else: id = id + 1
                return str(id)
            elif i.key == K_d:
                id = erase.getId(fl)
                if id == 1: id = add.getLine()
                else: id = id - 1
                return str(id)
コード例 #21
0
ファイル: app.py プロジェクト: iglee/outrunJulesVerne
def get_topics():

    unique_n = np.random.randint(10000000000)

    user_data = request.json
    input_topics = np.where(user_data['topics'])[0]
    tour_io, _, tour, map_ = output(input_topics, unique_n)
    #results = {'tour_results' : tour_io.getvalue(), 'map_results' : map_io.getvalue()}
    #return jsonify(results)
    #return map_io.getvalue(), 200, {'Content-Type':'image/png'}
    tour_table = tour_io.getvalue()

    return render_template('results.html',
                           map_url="static/img/map{}.png".format(unique_n),
                           tour_html=tour_table)
コード例 #22
0
 def nextSong(self):
     output("Next-Button - next song")
     self.last_interaction_time = datetime.datetime.now()
     if self.current_album in self.songs:
         album = self.songs[self.current_album]
         if len(album.titelliste) > self.current_song_index + 1:
             self.current_song_index = self.current_song_index + 1
             output('{}{}'.format("Playing next song with index ",
                                  self.current_song_index))
             self.player.stop()
             self.player.play(album.titelliste[self.current_song_index])
             self.printCurrentSong()
         else:
             output("Album has no more songs!")
             self.printCurrentSong()
     else:
         output("Invalid album: " + self.current_album)
コード例 #23
0
ファイル: disconnect.py プロジェクト: Dot-Liu/Oletter
    def POST(self):
        session = web.ctx.session
        if not session.have_key('user_id'):
            return output(411)
        if session['user_type'] == '0':
            return output(410)
        db = getDb()

        user={'id':session['user_id']}
        result = db.select('mate',user,
                           where = 'user_id=$id',
                           what = 'mate_id')
        res = result[0]
        t = db.transaction()
        try:
            db.update('userinfo',user,
                      where = 'user_id=$id',have_connect= '0')
            db.update('userinfo',var={'id':res.mate_id},
                      where = 'user_id=$id',have_connect = '0')
            t.commit()
        except:
            t.rollback()
            return output(700)
        return output(200)
コード例 #24
0
 def run(self):
     head = ["id", "Accuracy", "Predicted"]
     rsl = []
     files = listdir(self.path)
     reader = InputData(self.dataset_type, self.path)
     for filename in files:
         question = reader.read(filename)
         references = [
             parsers.stem(r["text"]) for r in question["references"]
         ]
         # create the grading model
         g = grading(references)
         for answer in question["student_answers"]:
             # get points for an anser
             points = g.grade(answer["text"])
             # convert point based result to test based grade
             predicted = self.predict(points)
             rsl.append({
                 "id": answer["id"],
                 "Accuracy": answer["accuracy"],
                 "Predicted": predicted
             })
     output(self.output_filename, head, rsl)
     return
コード例 #25
0
    def on_btn_sure_clicked(self):  #7
        global j
        if name02 == name03 != "":
            recognition_result = [{
                'Name': name02,
                'Recognition_status': 'Success'
            }]
            output.output().PushResult(recognition_result)
            for i in range(0, 4):
                if i == 0:
                    item = QTableWidgetItem()
                    item.setText(name02)
                    self.ui.tableWidget.setItem(j, 0, item)
                if i == 1:
                    item = QTableWidgetItem()
                    item.setText("计算机科学与技术")
                    self.ui.tableWidget.setItem(j, 1, item)
                if i == 2:
                    item = QTableWidgetItem()
                    item.setText("17级")
                    self.ui.tableWidget.setItem(j, 2, item)
                if i == 3:
                    item = QTableWidgetItem()
                    item.setText(s)
                    self.ui.tableWidget.setItem(j, 3, item)
            j = j + 1
            self.ui.Videoshow.setText("")
            QApplication.processEvents()
        else:
            dialog = QDialog()
            label = QLabel('不是同一个人', dialog)

            label.move(50, 50)
            dialog.setWindowTitle('别想蒙混过关')
            dialog.setWindowModality(Qt.ApplicationModal)
            dialog.exec()  # 显示对话框
コード例 #26
0
    def POST(self):
        input = web.input(is_refresh=None, flow_count=10, last_flow_id=None)
        try:
            input.is_refresh = int(input.is_refresh)
            input.flow_count = int(input.flow_count)
            if input.last_flow_id != None:
                input.last_flow_id = int(input.last_flow_id)
        except:
            #返回类型错误 状态码
            return output(111)

        if input.is_refresh == 0 and input.last_flow_id == None:
            #返回缺少必填参数 状态码
            return output(110)

        if input.flow_count <= 0:
            #返回参数值非法 状态码
            return output(112)

        session = web.ctx.session
        if not session.has_key('user_id'):
            return output(411)
        if session['user_type'] not in (2, 3, 4):
            return output(410)

        db = getDb()
        flow_list = []
        order = "add_time desc, flow_id desc"
        limit = '0,$count'
        if input.is_refresh == 0:
            vars = {
                'id': session['team_id'],
                'count': input.flow_count,
                'last_id': input.last_flow_id
            }
            where = 'team_id=$id and flow_id<$last_id'
            results = db.select('flow', vars=vars, where=where, order=order)
        else:
            vars = {'id': session['team_id'], 'count': input.flow_count}
            where = 'team_id=$id'
            results = db.select('flow', vars=vars, where=where, order=order)

        for i in results:
            flow_list.append({
                'flow_id': i.flow_id,
                'description': i.description,
                'amount': i.amount,
                'operator_name': i.operator_name,
                'add_time': i.add_time,
                'payment_type_name': i.payment_type_name
            })
        return output(200, flow_list)
コード例 #27
0
    def POST(self):
        input = web.input(team_id=None)
        if input.team_id == None:
            return output(110)

        try:
            input.team_id = int(input.team_id)
        except:
            return output(111)

        session = web.ctx.session
        if not session.has_key('user_id'):
            return output(411)
        if session['user_type'] != 0:
            return output(410)

        db = getDb()
        if len(
                db.select('team',
                          vars={'id': input.team_id},
                          where="team_id=$id")) == 0:
            return output(464)

        recruit_id_list = []
        for i in db.select('recruit',
                           vars={'id': input.team_id},
                           where="team_id=$id",
                           what="recruit_id"):
            recruit_id_list.append(i.recruit_id)
        t = db.trasaction()
        try:
            myvars = {'id': input.team_id}
            db.delete('team', vars=myvars, where="team_id=$id")
            db.delete('recruit', vars=myvars, where="team_id=$id")
            for i in recruit_id_list:
                db.delete('request', vars={'id': i}, where="recruit_id=$id")
            db.update('user',
                      vars=myvars,
                      where="team_id=$id",
                      team_id=None,
                      type='5')
            t.commit()
        except:
            t.rollback()
            return output(700)
        return output(200)
コード例 #28
0
ファイル: approve.py プロジェクト: rippletec810/base_platform
    def POST(self):
        input = web.input(request_id=None)
        if input.request_id == None:
            return output(110)
        try:
            input.request_id = int(input.request_id)
        except:
            return output(111)
        session = web.ctx.session
        if not session.has_key('user_id'):
            return output(411)
        if session['user_type'] not in (2, 3):
            return output(410)

        db = getDb()
        vars = {'id': input.request_id}
        where = "request_id=$id"
        result = db.select('request',
                           vars=vars,
                           where=where,
                           what='user_id,recruit_id')
        if len(result) == 0:
            return output(471)

        t = db.transaction()
        try:
            result = result[0]
            team_id = db.select('recruit',
                                vars={'id': result.recruit_id},
                                where='recruit_id=$id',
                                what='team_id')[0].team_id
            user_id = result.user_id
            db.update('request', vars=vars, where=where, status='approved')
            db.update('user',
                      vars={'id': user_id},
                      where="user_id=$id",
                      team_id=team_id,
                      type='4')
            db.delete('request',
                      vars={'id': user_id},
                      where="user_id=$id and status='ongoing'")
            t.commit()
        except:
            t.rollback()
            return output(700)
        return output(200)
コード例 #29
0
ファイル: add.py プロジェクト: rippletec810/base_platform
    def POST(self):
        input = web.input(title=None, content=None, type=None)
        if input.title == None or input.content == None or input.type == None:
            return output(110)
        try:
            input.type = int(input.type)
        except:
            return output(111)

        if input.type not in (0, 1, 2):
            return output(112)

        if input.type == 0:
            input.type = 'base'
        elif input.type == 1:
            input.type = 'match'
        else:
            input.type = 'activity'

        input.title = input.title.strip()
        if len(input.title) == 0:
            return output(112)

        session = web.ctx.session
        if not session.has_key('user_id'):
            return output(411)
        if session['user_type'] not in (0, 1):
            return output(410)

        db = getDb()
        try:
            db.insert('notice',
                      title=input.title,
                      content=input.content,
                      type=input.type,
                      add_time=int(time.mktime(time.localtime())))
        except:
            return output(700)

        return output(200)
コード例 #30
0
    def run(self):
        output("Started Register thread.")
        self.display.clear()
        self.display.printCentered("Willkommen bei", 1)
        self.display.printCentered("der Kinderkasse", 2)

        self.buttonQuit.start()
        self.buttonOne.start()
        self.buttonTwo.start()
        self.buttonThree.start()
        self.buttonFour.start()
        self.buttonFive.start()
        self.buttonSix.start()
        self.buttonSeven.start()
        self.buttonEight.start()
        self.buttonNine.start()
        self.buttonZero.start()
        self.buttonAccept.start()

        while self.isRunning:
            symbol = self.qrcodescanner.pullSymbol()

            # Spezialfall: Übergang zur MusicBox-App
            if symbol == "startmusicbox":
                self.running = False
                break

            product = self.getProductForSymbol(symbol)
            if product != -1:
                self.addProductToCart(product)
                self.printProductState(product)
        output("Quitting Register application")
        self.display.clear()
        self.display.printCentered("Tschuess", 1)
        self.buttonQuit.stop()
        self.buttonOne.stop()
        self.buttonTwo.stop()
        self.buttonThree.stop()
        self.buttonFour.stop()
        self.buttonFive.stop()
        self.buttonSix.stop()
        self.buttonSeven.stop()
        self.buttonEight.stop()
        self.buttonNine.stop()
        self.buttonZero.stop()
        self.buttonAccept.stop()
        # Diese Zeile auskommentieren, wenn man beim Beenden nicht den Pi ausschalten will
        #self.shutdown()
        output("Register application ended")
コード例 #31
0
ファイル: main.py プロジェクト: kshvmdn/uoft-exams
def main():
    args = parser.parse_args()
    courses, ln, season, year, format_ = args.courses, args.last_name, \
        args.semester[0], args.semester[1:], args.format

    if season.upper() not in ('W', 'F') or not year.isnumeric():
        print('Unexpected semester argument (run -h for details).')
        return

    date = ('apr' if season == 'W' else 'dec') + year

    exam_data = scrape(BASE_URL.format(date))
    if exam_data is not None:
        user_exams = search(exam_data, courses, ln)
        if user_exams is not None:
            return output(user_exams, format_, '{}-exams'.format(ln) + '.{}')
        else:
            print('Couldn\'t find exam information for given courses.')
            return
    else:
        print('Couldn\'t find exam information for given semester.')
        return
コード例 #32
0
 def get_serie(self):
     # main function
     
     self.output = output(self.gui)
     
     self.output.ready("...")
     
     # Chrome Session erstellen
     self.create_session()
     
     # Seite Aufrufen
     self.get_site()
     
     # Erstellt einen Array mit den einzelnen Folgen
     self.get_episode()
     
     self.output.ready("ok")
     
     # Downloaded alle Folgen
     self.download()
     
     self.browser.quit()