Beispiel #1
0
def main():
    parser = ArgumentParser()
    parser.add_argument('-d',
                        '--debug',
                        action='store_true',
                        help='Debug mode?')
    args = parser.parse_args()

    server.run(args.debug)
    cmd.clear()
    misc.print_title("""
██████╗ ██╗  ██╗██╗   ██╗ ██╗██████╗ 
██╔══██╗██║  ██║██║   ██║███║██╔══██╗
██║  ██║███████║██║   ██║╚██║██║  ██║
██║  ██║╚════██║╚██╗ ██╔╝ ██║██║  ██║
██████╔╝     ██║ ╚████╔╝  ██║██████╔╝
╚═════╝      ╚═╝  ╚═══╝   ╚═╝╚═════╝ 
    """)
    try:
        code = cmd.SUCCESS
        while code != cmd.CLOSING:
            code = cmd.handle(misc.prompt(cmd.__bot), args.debug)
        else:
            server.stop()
    except KeyboardInterrupt:
        print()
        server.stop()
        cmd.__cleanup()
    cmd.clear()
Beispiel #2
0
    def run(self):
        self.init()
        models = [
            constants.getHotwordModel(config.get('hotword', 'wukong.pmdl')),
            constants.getHotwordModel(utils.get_do_not_bother_on_hotword()),
            constants.getHotwordModel(utils.get_do_not_bother_off_hotword())
        ]

        # capture SIGINT signal, e.g., Ctrl+C
        signal.signal(signal.SIGINT, self._signal_handler)
        detector = snowboydecoder.HotwordDetector(models,
                                                  sensitivity=config.get(
                                                      'sensitivity', 0.5))
        print('Listening... Press Ctrl+C to exit')

        # site
        server.run()

        # main loop
        detector.start(detected_callback=[
            self._detected_callback, self._do_not_bother_on_callback,
            self._do_not_bother_off_callback
        ],
                       audio_recorder_callback=self._conversation.converse,
                       interrupt_check=self._interrupt_callback,
                       silent_count_threshold=5,
                       sleep_time=0.03)
        detector.terminate()
Beispiel #3
0
def main():

    #    name = "com.hdezninirola.frequency"
    name = "no.nrk.yr"
    #     name = "com.rovio.angrybirds"
    #     dir = "/Users/Wschive/Desktop/"
    #     name = "com.kabam.underworldandroid"
    #     getApps.run("com.bitdefender.clueful")
    #     risk.run("com.bitdefender.clueful")
    #     recommender.recommend()

    #     s = requests.Session()
    # #     s.auth=('*****@*****.**', '1.9.Alpha')
    #     s.post("https://accounts.google.com/ServiceLogin", {"Email":'*****@*****.**', "Passwd":'1.9.Alpha'})
    #     print s
    #     value = {"id":"com.squareenix.smoothieswipe"}
    # #     r = s.get("https://play.google.com/store/apps/details", params = value)
    # #     print r
    #
    #     g = s.get("http://play.google.com/store/apps/similar", params = value)
    #     print g
    #     print(g.url)
    #     print g.content

    #     works, but limited amount of calls
    #     apiKey = {"key" :"9494f057c1a1a67ab30e5e7afdc6afe2"}
    #     r = requests.get("http://api.playstoreapi.com/v1.1/apps/"+name, params = apiKey)
    #     data = json.loads(r.content)
    #     print data
    #     print data["recommendedApps"]

    db.connect()

    server.run()
    print "it ran!"
Beispiel #4
0
def run():
    import handlers
    import resource
    import seed

    from server import server

    server.run(host='0.0.0.0', port=os.getenv('PORT', 8080), workers=1)
Beispiel #5
0
def main():
    while 1:
        #main daemon process loop
        print "run server with config"
        for line in lines:
            spt = line.split("=")
            print spt
            os.environ[spt[0]] = spt[1]
        run()
Beispiel #6
0
def main():
  while 1:
    #main daemon process loop    
    print "run server with config"
    for line in lines:
      spt=line.split("=")
      print spt
      os.environ[spt[0]] = spt[1]
    run()
Beispiel #7
0
    def run(self):
        self.init()

        # capture SIGINT signal, e.g., Ctrl+C
        signal.signal(signal.SIGINT, self._signal_handler)

        # site
        server.run(self._conversation, self)

        statistic.report(0)

        self.initDetector()
Beispiel #8
0
    def run(self):
        self.init()

        # capture SIGINT signal, e.g., Ctrl+C
        signal.signal(signal.SIGINT, self._signal_handler)

        # site
        server.run(self._conversation, self)

        statistic.report(0)

        try:
            self.initDetector()
        except AttributeError:
            logger.error('初始化离线唤醒功能失败')
            pass
def main():
    parser = argparse.ArgumentParser()
    group = parser.add_mutually_exclusive_group()
    group.add_argument("--run-server", action="store_true")
    group.add_argument("--initialise-db", action="store_true")
    group.add_argument("--add-user", action="store_true")
    args = parser.parse_args()

    if args.run_server:
        init(config["connection_string"])
        server.run(host="0.0.0.0", debug=True)
    elif args.initialise_db:
        initialise_db()
    elif args.add_user:
        add_user()
    else:
        parser.print_help()
def main():
    parser = argparse.ArgumentParser()
    group = parser.add_mutually_exclusive_group()
    group.add_argument("--run-server", action="store_true")
    group.add_argument("--initialise-db", action="store_true")
    group.add_argument("--add-user", action="store_true")
    args = parser.parse_args()

    if args.run_server:
        init(config["connection_string"])
        server.run(host="0.0.0.0", debug=True)
    elif args.initialise_db:
        initialise_db()
    elif args.add_user:
        add_user()
    else:
        parser.print_help()
Beispiel #11
0
    def run(self):
        self.init()
        KeyHandler.start(self)
        # capture SIGINT signal, e.g., Ctrl+C
        signal.signal(signal.SIGINT, self._signal_handler)

        # site
        server.run(self._conversation, self)
        # statistic.report(0)
        # t = threading.Thread(target=self.openBrawer)
        # t.start()
        # Player.play(constants.getData('robot_open.mp3'), onCompleted=self.say_allcomplete(), volum=0.7)

        try:
            self.initDetector()
        except AttributeError:
            logger.error('初始化离线唤醒功能失败')
            pass
Beispiel #12
0
import os

import handlers
import resource
import seed

from server import server

server.run(host='0.0.0.0', port=os.getenv('PORT', 8080), workers=1)
Beispiel #13
0
#!/usr/bin/env python
# The imports bellow are necessary to initialise the dash apps
import os

import candidates
import polls

from server import server as application

application.config.from_object(os.environ['FLASK_SETTINGS'])

if __name__ == '__main__':
    application.run(host='0.0.0.0')
Beispiel #14
0
    return jsonify({"msg": "Bad username or password"}), 401


@server.route("/register", methods=["POST"])
def register():
    username = request.json.get("username", None)
    password = request.json.get("password", None)
    role = request.json.get("role", None)
    if username is not None and password is not None:
        if role is None:
            role = "user"
        UserRepository.create_new_user(username, password, role)
        return jsonify({"msg": "succ"}), 200

    return jsonify({"msg": "Bad username or password"}), 401


@server.route("/test", methods=["GET"])
@jwt_required()
def optionally_protected():
    current_identity = get_jwt_identity()
    if current_identity:
        return jsonify(logged_in_ass=current_identity)
    else:
        return jsonify({"msg": "go away from here"}), 401


if __name__ == "__main__":
    db.create_all()
    server.run(host='0.0.0.0', port=5000)
Beispiel #15
0
from server import server

if __name__ == "__main__":
    server.run(
        host='0.0.0.0',  # какой адрес слушаем
        port=5000,  # на каком порту
        debug=False)
Beispiel #16
0
from server import server, views

server.run(debug=True, host='0.0.0.0', threaded=True)
Beispiel #17
0
def run(ip='localhost', port='8080'):
    address = (ip, port)
    if not SERVER:
        use_default_server()
    server = SERVER
    server.run(request_handler, address)
Beispiel #18
0
#!/usr/bin/env python3

import sys, yaml
with open("/etc/ergotime/ergotime.yaml", "r") as f:
    try:
        config = yaml.load(f)
    except yaml.YAMLError as err:
        print("Cannot load config, err: %s" % err)
        sys.exit(1)
sys.path.insert(0, config['basedir'] )


from server import server

# app.config['myconf'] = config

server.run(host='0.0.0.0', debug=True)
Beispiel #19
0
import resource
import seed

from server import server

server.run(host='0.0.0.0', port=8080, workers=1)
Beispiel #20
0
from server import server as app
from app1 import app as app1
from app2 import app as app2

if __name__ == '__main__':
	app.run()
Beispiel #21
0
from server import server
import logging

logging.basicConfig(level=logging.INFO,
                    format="%(asctime)s:%(levelname)s:%(message)s")

if __name__ == '__main__':
    server.run(host='127.0.0.1', port=8000)
Beispiel #22
0
import sys

import fire

from robot import config
from robot.Conversation import Conversation
from server import server
from wukong import Wukong

wukong = None
conversation = None

if __name__ == '__main__':
    if len(sys.argv) == 1:
        conversation = Conversation(False)
        wukong = Wukong(conversation)
        config.init()

        server.run(conversation, wukong)
        # wukong.run()
    else:
        fire.Fire(Wukong)
Beispiel #23
0
import config
from server import server, api

# Import Models and Schemas
from models import ToDo
from schemas import todos_schema, todo_schema

# Import Routes
from routes import todosRoute

# Import Error Handlers
from routes import errorHandlers

# Register Error Handlers
server.register_blueprint(errorHandlers)

# Add Routes to API
api.add_namespace(todosRoute, path='/todos')

# Start Server
if __name__ == '__main__':
    server.run(port=3000, debug=config.debug)
Beispiel #24
0
from server import server
from app1 import app as app1
from app2 import app as app2
if __name__ == '__main__':
    server.run()
#!/usr/bin/env python
# The imports bellow are necessary to initialise the dash apps
import candidates
import polls

from server import server


server.config.from_object('settings.DevelopmentConfig')


if __name__ == '__main__':
    server.run(host='0.0.0.0')
Beispiel #26
0
            return
        tzname = args[1]
        try:
            tzname = int(tzname)
        except ValueError:
            pass

        tzname = management.set_user_timezone(message.chat.id, tzname)
        bot.reply_to(message, f'Your time zone set to {tzname}')
    except ValueError as e:
        bot.reply_to(message, str(e))


@bot.message_handler(func=text_trigger('My timezone'))
@bot.message_handler(commands=['gettimezone'])
def get_user_timezone(message):
    tzname = management.get_user_timezone(message.chat.id)
    bot.reply_to(message, f'Your current time zone: {tzname}')


# Any testing functions I need
@bot.message_handler(func=lambda msg: True)
def default_message_handler(message):
    msg = message.text.split()
    if msg and msg[0] == Config.TOKEN:
        bot.reply_to(message, str(server.config))


if __name__ == '__main__':
    server.run(host='0.0.0.0', port=Config.PORT)
Beispiel #27
0
    if not config.config.is_valid():
        logger.init_logger(True)
        log = logging.getLogger(__name__)
        log.error("Config parser Error")
        sys.exit(1)

    logger.init_logger(config.config.daemon)
    log = logging.getLogger(__name__)

    parser = argparse.ArgumentParser()
    parser.add_argument("-g",
                        "--debug",
                        help="run in debug mode",
                        action="store_true")
    args = parser.parse_args()

    signal.signal(signal.SIGTERM, signal_handler)
    signal.signal(signal.SIGHUP, signal_handler)

    try:
        if args.debug:
            log.info('======== Debug starting service application listen ' +
                     str(PORT) + '... ========')
            server.run(host=HOST, port=PORT, debug=True)
        else:
            log.info('========  Starting service application listen ' +
                     str(PORT) + '...========')
            wsgi_server = WSGIServer(('', PORT), server)
            wsgi_server.serve_forever()
    except KeyboardInterrupt:
        log.info("ctrl+c Stopping service application...")
Beispiel #28
0
#!/usr/bin/python2
# -*- coding: utf-8 -*-


from server import server
server.run()
Beispiel #29
0
    return dict(height="100%",
                width="100%",
                backgroundColor="#ABEBC6",
                textAlign='center')


@app.callback(Output("markdown-preview-renderer", 'children'),
              [Input("blog-writing-markdown-textarea", 'value')])
def make_markdown_previewed_again(text_):
    if not text_:
        return ""
    print(text_)
    return text_


# counts the number of words/characters in your text/textlet post, turn red if the number goes over depending on the post_type
# counts the number of words in your blog post, estimates reading time, turns red if the number goes over 5,000
# warn you from leaving if you have unsaved content in the blog post section
# submits settings changes
# posts a post
# posts a comment
# generates feed content & store in Store
# depends on vllg context - but either way, it stores it in the browser
# maybe create preexisting hidden buttons for commenting and upvoting - 20 preexisting buttons (for 20 pieces of content per page)
# each time the user moves to the next page, the buttons get reassigned to the next 1-20 content pieces
# ...how to deal with a potentially unlimited amount of comments?
# generate next page of feed content & store in Store as next page i.e. dict(page1:[content1,content2...],page2:[content1,content2...]...)

if __name__ == "__main__":
    server.run(debug=False, threaded=True)
Beispiel #30
0
        sql = "SELECT * FROM users"
        rows = db.conn.select_all(sql)
    return jsonify( data=rows )


@server.route("/api/user", methods=["POST"])
def newUser():
    print("saveUser")
    t = {}
    d = request.form
    for key in d.keys():
        t[key] = d[key]
    print("t", t)
    _id = db.conn.insert("users", t, "_id")
    return jsonify( _id=_id )


@server.route("/api/user", methods=["PUT"])
def updateUser():
    abort(403, { 'message': "Not implemented" })


@server.route("/api/user", methods=["DELETE"])
def deleteUser():
    abort(403, { 'message': "Not implemented" })


if __name__ == '__main__':
    """For testing"""
    server.run(debug=True, host="0.0.0.0")
Beispiel #31
0
#!flask/bin/python
from server import server
server.run(debug = True, host= '0.0.0.0')
Beispiel #32
0
from server import server

from dashapp1 import app as app1
from dashapp2 import app as app2


if __name__ == '__main__':
    server.run(debug=True)
Beispiel #33
0
#! /usr/bin/env python

import os
import sys
import time
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

print "run server with config"
lines = [x.strip() for x in open(".env")]
for line in lines:
    spt=line.split("=")
    print spt
    os.environ[spt[0]] = spt[1]


from server.server import run
from tests.graph_test import start

"""start()"""


max_attempts = 3
for i in xrange(max_attempts):
    try:
        run()
    except:
        time.sleep(10)


Beispiel #34
0
from server import server

print '\nStarting server'
if __name__ == '__main__':
    server.run(port=server.config['PORT'], debug=server.config['DEBUG'])
from server import server as application

if __name__ == 'main':
    application.run()
Beispiel #36
0
    global conversation
    if conversation:
        conversation.stop()
    Player.player('static/beep_hi.wav', False)

def signal_handler(signal, frame):
    global interrupted
    interrupted = True


def interrupt_callback():
    global interrupted
    return interrupted

conversation = Conversation()
server.run(conversation)
# 更改唤醒词为配置文件中的值,默认为snowboy文件夹中的
model = config.get('/snowboy/hotword','snowboy/resources/jarvis.pmdl')

# capture SIGINT signal, e.g., Ctrl+C
signal.signal(signal.SIGINT, signal_handler)

detector = snowboydecoder.HotwordDetector(model, sensitivity=config.get('/snowboy/sensitivity', 0.38))
print('""""""""""""""""""""""""""""""'
      'robot'
      '"""""""""""""""""""""""""""""""')
# Player.hello()
logger.info('Listening... Press Ctrl+C to exit')


# main loop
Beispiel #37
0
#!flask/bin/python
from server import server
server.run(debug=True)