def history(): k = Koalemos.get_instance() n = int(request.args['n'] if 'n' in request.args else 5) n = n if n < len(k.HISTORY) else len(k.HISTORY) history = k.HISTORY[-n:] output = '\n'.join([','.join(map(str, record)) for record in history]) return output, 200
def commit(): if 'r' not in request.form: return 'require param: r', 400 r = request.form['r'] if len(r) < 1 or len(r) > 40: return 'len(r) between [1, 40]', 400 k = Koalemos.get_instance() if not all([x in k.CHARSET for x in r]): return 'all charset in r must in [0-9a-f]', 400 if k.match(r): return '', 204 else: return 'verify failed', 400
def main(): parse_args() f = (lambda n: True) if (OPTIONS['puzzles'] == 0) else (lambda n: n < OPTIONS['puzzles']) cnt = 0 while f(cnt): s, x, n = get_koalemos_status() begin = time.time() r = Koalemos(s, x, n).find() cost = time.time() - begin res, err = commit_koalemos(r) if not err: sys.stdout.write('''[i] %s: %s, %s, %s, %s, %s, %.6s ''' % (cnt + 1, s, x, n, r, int(r, 16), cost)) cnt += 1 else: sys.stderr.write('''[x] commit failed: %s ''' % res)
def puzzle(): k = Koalemos.get_instance() return '%s,%s,%s' % (k.S, k.X, k.N)