示例#1
0
        button2 = tk.Button(self,
                            text="Page Two",
                            command=lambda: controller.show_frame(PageTwo))
        button2.pack()


class PageTwo(tk.Frame):
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        label = tk.Label(self, text="Page Two!!!", font=LARGE_FONT)
        label.pack(pady=10, padx=10)

        button1 = tk.Button(self,
                            text="Back to Home",
                            command=lambda: controller.show_frame(StartPage))
        button1.pack()

        button2 = tk.Button(self,
                            text="Page One",
                            command=lambda: controller.show_frame(PageOne))
        button2.pack()


if __name__ == "__main__":
    rook.start(
        token=
        'eaffdcffc205a2a475278a038ef15c86feae68ce0d9fff73630e56837ca78549',
        labels={"env": "dev"})
app = SeaofBTCapp()
app.mainloop()
示例#2
0
@app.route("/render")
def render_bad_template():
    try:
        invalid_oper = 42 / 0
    except Exception as e:
        print('Operation failed to complete')
    animal_list = ['dog', 'cat', 'turtle', 'fish', 'bird', 'cow', 'sealion']
    time = datetime.now()
    number = 0.01 * randint(10, 200) + 0.1
    return render_template('doesnotexist.html',
                           animal_list=animal_list,
                           time=time,
                           number=number)


@app.route("/")
def home():
    time.sleep(0.01 * randint(10, 200) + 0.1)
    return 'Index Main Page'


@app.route('/hello')
def hello():
    time.sleep(0.01 * randint(10, 200) + 0.1)
    return 'Hello, World'


if __name__ == "__main__":
    rook.start()
    app.run(host="0.0.0.0", port=5000, threaded=True)
示例#3
0
# we allow the user to set a configuration location via an already-set
# env var if they wish, but it'll default to config.toml in the running
# directory
CONFIG_LOCATION = os.environ.get("CONFIG_LOCATION", "config.toml")
with open(CONFIG_LOCATION, "rb") as f:
    toml_dict = tomli.load(f)
    for key, value in toml_dict.items():
        os.environ[key] = str(value)

importlib.reload(utils)  # refresh the dev guild id

try:
    import rook

    if os.environ.get("ROOK_TOKEN"):
        rook.start(token=os.environ["ROOK_TOKEN"],
                   labels={"env": os.environ["ROOK_ENV"]})
except ImportError:
    pass

logger = logging.getLogger("dis.naff")
logger.setLevel(logging.INFO)
handler = logging.FileHandler(filename=os.environ["LOG_FILE_PATH"],
                              encoding="utf-8",
                              mode="a")
handler.setFormatter(
    logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s"))
logger.addHandler(handler)


class RealmsPlayerlistBot(utils.RealmBotBase):
    @naff.listen("startup")
示例#4
0
    vote = None

    if request.method == 'POST':
        redis = get_redis()
        vote = request.form['vote']
        data = json.dumps({'voter_id': voter_id, 'vote': vote})

        redis.rpush('votes', data)
        print("Registered vote")
        return app.response_class(response=json.dumps(data),
                                  status=200,
                                  mimetype='application/json')
    else:
        return app.response_class(response=json.dumps({}),
                                  status=404,
                                  mimetype='application/json')


if __name__ == "__main__":
    if rookout_token:
        rook.start(
            token=rookout_token,
            labels={
                "env": "dev",
                "service": "api",
                "instance_id": instance_id
            },
        )

    app.run(host='0.0.0.0', port=8080, debug=True, threaded=True)
示例#5
0
def start_rook():
    token = os.getenv("ROOKOUT_TOKEN")

    if token:
        rook.start(token=token)
示例#6
0
        try:
            ResponseAdapter(oppwa_response, response_obj).adapt_response()
        except Exception as e:
            self.report_error(HTTPStatus.BAD_REQUEST,
                              "Exception while adapting response", e)
            return

        content = json.dumps(response_obj).encode("utf-8")
        code = HTTPStatus.OK

        self.send_response(code)
        self.send_header("Content-Type", "application/json; charset=utf-8")
        self.send_header("Content-Length", len(content))
        self.end_headers()
        self.wfile.write(content)

    def report_error(self, code, msg, e):
        self.log_error(msg + ": %s", format(e))
        self.send_error(code, msg, format(e))


if __name__ == "__main__":
    rook.start(
        token='e2fe21957bb07aba7b222bd7ec9ef1ce2ba6b2c051e3d7120afaebdd2572d6fc'
    )

port = int(environ["PORT"])
httpd = HTTPServer(("", port), HttpHandler)
print("Listening on port " + str(port))
httpd.serve_forever()
示例#7
0
@app.route('/todos', methods=['GET'])
def get_todos():
    todos = Store.getInstance().todos
    return json.dumps(todos)


@app.route('/todo/dup/<todoId>', methods=['POST'])
def duplicate_todo(todoId):
    todos = Store.getInstance().todos
    for todo in todos:
        if todoId == todo['id']:
            dup = {
                'title': todo['completed'],
                'id': unsafeRandId(10),
                'completed': todo['title']
            }
            todos.append(dup)
            break
    return ('', 204)


import rook

rook.start(
    token='d1fee9a4a26620c993fb180677fad4ea6939677b82e6082265f889026f1cd71a',
    tags=["codefresh-rookout-webinar"])

if __name__ == "__main__":
    app.run(host='0.0.0.0')
示例#8
0
 def run_rookout():
     import rook
     rook.start()
示例#9
0
app = Flask(__name__)

@app.route("/")
def home():
    time.sleep(0.01 * randint(10, 200) + 0.1)
    return 'Index Main Page'

@app.route('/hello')
def hello():
    time.sleep(0.01 * randint(10, 200) + 0.1)
    return 'Hello, World'  # Set bp here


def debug_here(i):
    j = i * i
    return j  # Set bp here


def child_routine():
    for i in range(30):
        debug_here(i)
        time.sleep(5)


if __name__ == "__main__":
    rook.start(throw_errors=True, fork=True)
    if 0 == os.fork():
        app.run(host="0.0.0.0", port=5000, threaded=True)
    else:
        child_routine()
示例#10
0
from celery import Celery

import rook
rook.start(fork=True)

app = Celery('tasks',
             broker='amqp://host.docker.internal',
             backend='redis://host.docker.internal')


@app.task
def add(x, y):
    return x + y
示例#11
0
import flask
import re
import os
import string
import random
import json
import requests
import rook

from datetime import datetime
from random import randint
from todos_store import Store

if __name__ == "__main__":
    rook.start(
        token='a7236965859705c80e116cde3ec0396eef5242dd6e454cf635e6cc708fbbc1bd'
    )

app = flask.Flask(__name__, static_url_path='/static')

# unsafeRandId generates a random string composed from english upper case letters and digits
# it's called unsafe because it doesn't use a crypto random generator

url = "https://service.eu.apiconnect.ibmcloud.com/gws/apigateway/api/da713fba861ff19ef7cc15e87072dfd6ce556d30c2b0caac7f307ef844741e9a/281a066c-00fc-40a6-b272-0139a590ce7b/rookout"


def unsafeRandId(len):
    return ''.join(
        random.choice(string.ascii_uppercase + string.digits)
        for _ in range(len))