Example #1
0
 def final(self):
     global _port_F
     #import ctypes
     #cytypes.windll.user32.ShowWindow(ctypes.windll.kernel32.GetConsoleWindow(), 0)
     import sys
     sys.stdout = sys.stderr = open(os.devnull, 'w')
     app.run(host='0.0.0.0', port=_port_F, debug=False)
Example #2
0
def main():
    util = Util()
    elastic = Elastic()

    # get config and set logger
    config = util.get_params()
    logger = util.set_logger('main')

    # create index in elastic search
    msg = elastic.create_index()

    # check that it was created
    if msg is None:
        logger.info('Index created successfully!')
    else:
        logger.error(f'Error occurred in creating index:\n {msg}')

    # insert records to elasticsearch
    diff = elastic.insert_elastic()

    # check that it was inserted
    if diff == 0:
        logger.info('Movies inserted successfully to elasticsearch!')
    else:
        logger.error(f'Elasticsearch: Error occurred in {diff} movies!')

    # run web app
    app.run(host='0.0.0.0', port=5002, debug=config['app'].getboolean('debug'))
Example #3
0
def main():
    try:
        cmd = sys.argv[1]
        assert (cmd in cmds)
    except:
        invocations = ["python pypitches.py {0}".format(cmd) for cmd in cmds]
        print "usage:  " + "\n        ".join(invocations)
        sys.exit()
    if cmd == 'initdb':
        setup_postgres.initdb(postgres_db, postgres_user, postgres_password)
        sys.exit()
    else:
        import model
        model.SessionManager.create(postgres_db, postgres_user,
                                    postgres_password)
        import load
        from web.app import app
        import select_gamedirs
        from plot_pitch_locations import do_plots

    if cmd == 'web':
        app.run()
    elif cmd == 'webtest':
        app.run('pypitchestest', 'pypitches', 'slider')
    elif cmd == 'ipython':
        embed()
    elif cmd == 'file':
        # will generate output by a config file
        # a la plot_pitch_locations.py
        assert len(sys.argv) > 2, "usage: python pypitches.py file file.yaml"
        do_plots(sys.argv[2])

    elif cmd == 'download':
        # hit the MLBAM server and get it all
        pass
    elif cmd == 'classify':
        with model.SessionManager.get().begin_nested():
            static_dir = sys.argv[2]
            select_gamedirs.classify_local_dirs_by_filesystem(static_dir)
        model.SessionManager.commit()
    elif cmd == 'load':
        statuses = set(sys.argv[2:]) or set(['final'])
        with model.SessionManager.get().begin_nested():
            load.load(statuses)
        model.SessionManager.commit()
Example #4
0
def main():
    try:
        cmd = sys.argv[1]
        assert(cmd in cmds)
    except:
        invocations = ["python pypitches.py {0}".format(cmd) for cmd in cmds]
        print "usage:  " + "\n        ".join(invocations)
        sys.exit()
    if cmd == 'initdb':
        setup_postgres.initdb(postgres_db, postgres_user, postgres_password)
        sys.exit()
    else:
        import model
        model.SessionManager.create(postgres_db, postgres_user, postgres_password)
        import load
        from web.app import app
        import select_gamedirs
        from plot_pitch_locations import do_plots

    if cmd == 'web':
        app.run()
    elif cmd == 'webtest':
        app.run('pypitchestest', 'pypitches', 'slider')
    elif cmd == 'ipython':
        embed()
    elif cmd == 'file':
        # will generate output by a config file
        # a la plot_pitch_locations.py
        assert len(sys.argv) > 2, "usage: python pypitches.py file file.yaml"
        do_plots(sys.argv[2])

    elif cmd == 'download':
        # hit the MLBAM server and get it all
        pass
    elif cmd == 'classify':
        with model.SessionManager.get().begin_nested():
            static_dir = sys.argv[2]
            select_gamedirs.classify_local_dirs_by_filesystem(static_dir)
        model.SessionManager.commit()
    elif cmd == 'load':
        statuses=set(sys.argv[2:]) or set(['final'])
        with model.SessionManager.get().begin_nested():
            load.load(statuses)
        model.SessionManager.commit()
Example #5
0
def start_web_view(options, experiment_config, chooser):
    '''Start the web view in a separate process.'''

    from web.app import app    
    port = get_available_port(options.web_status_port)
    print "Using port: " + str(port)
    if options.web_status_host:
        print "Listening at: " + str(options.web_status_host)
    app.set_experiment_config(experiment_config)
    app.set_chooser(options.chooser_module,chooser)
    debug = (options.verbose == True)
    start_web_app = lambda: app.run(debug=debug, port=port, host=options.web_status_host)
    proc = multiprocessing.Process(target=start_web_app)
    proc.start()

    return proc
Example #6
0
def start_web_view(options, experiment_config, chooser):
    '''Start the web view in a separate process.'''

    from web.app import app
    port = get_available_port(options.web_status_port)
    print "Using port: " + str(port)
    if options.web_status_host:
        print "Listening at: " + str(options.web_status_host)
    app.set_experiment_config(experiment_config)
    app.set_chooser(options.chooser_module, chooser)
    debug = (options.verbose == True)
    start_web_app = lambda: app.run(
        debug=debug, port=port, host=options.web_status_host)
    proc = multiprocessing.Process(target=start_web_app)
    proc.start()

    return proc
Example #7
0
from web.app import app
from config import host

if __name__ == "__main__":
    app.run(host=host, debug=True)
Example #8
0
def run():
    if __name__ == "__main__":
        app.run(host='0.0.0.0', port=2000)
    return app
Example #9
0
from web.app import app

if __name__ == '__main__':
	app.run(host='0.0.0.0', port=80)
Example #10
0
from config import port
from web.app import app

app.run(port=port)
    

    img_dir = config['DEFAULT']['images_directory']
    results_dict = {}
    images = list(get_image_files(img_dir))
    for image in tqdm.tqdm(images):
        info = hash_file(image)
        if info == 0:
            continue

        hash_value = info['hash']

        if hash_value not in results_dict:
            file_name = os.path.basename(info['_id'])
            results_dict[hash_value] = [file_name, 1]
        else:
            results_dict[hash_value][1] += 1

    count = list(results_dict.values())
    sorted_count = sorted(count, key=lambda x: x[1], reverse=True)
    
    with ImagesDB(IMG_INFO_DB_FILENAME) as imgDb:        
        imgDb.insert_batch(sorted_count)

if __name__ == "__main__":
    process()
    if len(sys.argv) > 1:
        if sys.argv[1] == "web":
            from web.app import app
            app.run(1111)
    
Example #12
0
def run_web():
    app.run(host='0.0.0.0')
Example #13
0
#!/usr/bin/env python
from web.app import app

if __name__ == "__main__":
    app.run(debug=True, host='0.0.0.0', use_reloader=True)
Example #14
0
def main():
    app.run(debug=True, host="0.0.0.0", port=80)
Example #15
0
from web.app import app


if __name__ == '__main__':
    app.run(host='0.0.0.0', port=81, debug=False)
Example #16
0
from web.app import app

app.run(host="0.0.0.0", port=int("1337"), debug=True)
Example #17
0
def profile(length=25, profile_dir=None):
    """Start the application under the code profiler."""
    from werkzeug.contrib.profiler import ProfilerMiddleware
    app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[length],
                                      profile_dir=profile_dir)
    app.run()
Example #18
0
import logic.browser
from web.app import app

if __name__ == '__main__':
    HOST = app.config['HOST']
    PORT = app.config['PORT']
    app.run(HOST, PORT, debug=True)
Example #19
0
from config import web_port_number
from web.app import app

app.run(port=web_port_number)
Example #20
0
 def web(self):
     app.run(host='0.0.0.0', port=5000)
Example #21
0
from web.app import app
import web.handler

options = {
    'debug': True,
    'host': '0.0.0.0',
    'port': 8000,
}

if __name__ == '__main__':
    app.run(**options)
Example #22
0
def main():
    app.run(host='0.0.0.0', port=5000)
Example #23
0
from web.app import app

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000)
Example #24
0
import sys
from web.app import app

if len(sys.argv) < 2:
    raise Exception('require more than 2 args')

if sys.argv[1] == 'runserver':
    port = 10203
    if len(sys.argv) > 2:
        port = int(sys.argv[2])
    app.run(host='0.0.0.0', port=port)
else:
    raise Exception('not exists command')
Example #25
0
'''
This python file is the main control
component for all web requests from
the client to the server.
This file shall import from
the "app" module and run it.
The "host" and "port" values are
needed to allow remote access
(non-localhost) and reachable from
localhost/IP address of the machine
running this file.
'''
if __name__ == '__main__':
    from sequence.sequence import Sequence
    from web.app import app
    app.run(host='0.0.0.0', debug=True, port=80)
Example #26
0
#!/usr/bin/env python
from web.app import app

if __name__ == "__main__":
  app.run(debug=True, host='0.0.0.0', use_reloader=True)
Example #27
0
def service():

    app.debug = False
    app.run(host='0.0.0.0', port=1081)
Example #28
0
from web.app import app

if __name__ == "__main__":
    app.run(debug=False)
Example #29
0
from web.app import app

if __name__ == "__main__":
    app.run(host='0.0.0.0')
Example #30
0
from web.app import app

app.run(debug=True)
Example #31
0
        pass
        print "POST a Message:", request.data,"--"
        body = json.loads(request.data)
        if body[ProtocolItem.MESSAGES][ProtocolItem.DEST_TYPE] == ProtocolItem.VALUE_IOS:
            threading.Thread(target=Util.push_ios,args=([body[ProtocolItem.MESSAGES][ProtocolItem.DEST_ID]], "alarm", body[ProtocolItem.MESSAGES][ProtocolItem.CONTENT])).start()
#            Util.push_ios([body[ProtocolItem.MESSAGES][ProtocolItem.DEST_ID]], 'alarm', body[ProtocolItem.MESSAGES][ProtocolItem.CONTENT])
        return {'_id':'0'}

    def get(self):
        return {'get':'None'}


api.add_resource(Messages, '/bd/api/messages')



if __name__ == '__main__':
    app.run(debug=True,port= 5001)












Example #32
0
import sys
sys.path.insert(0, './')
from web.app import app
from flask_cors import CORS
CORS(app)

if __name__ == '__main__':
    app.run()
Example #33
0
# -*- coding: utf-8 -*-

from flask_failsafe import failsafe

# for flask failsafe
@failsafe
def create_app():
    from web.app import app
    return app

if(__name__ == "__main__"):
    app = create_app()
    from web.app import auth
    app.debug = app.config["DEBUG_MODE"]
    # move this to script 
    from web.model import Label, Inspiration, LabelInspirationRelationShip
    init_class = [auth.User, Label, Inspiration, LabelInspirationRelationShip]

    for kls in init_class:
        kls.create_table(fail_silently=True)

    app.run(host='0.0.0.0')
Example #34
0
                   methods=['POST', 'PATCH'],
                   preprocessors={'POST': [pre_post_test]},
                   url_prefix='/bd/api/v1.0')


class Messages(Resource):
    def post(self):
        pass
        print("POST a Message:", request.data, "--")
        body = json.loads(request.data)
        if body[ProtocolItem.MESSAGES][
                ProtocolItem.DEST_TYPE] == ProtocolItem.VALUE_IOS:
            threading.Thread(
                target=Util.push_ios,
                args=([body[ProtocolItem.MESSAGES][ProtocolItem.DEST_ID]
                       ], "alarm",
                      body[ProtocolItem.MESSAGES][ProtocolItem.CONTENT]
                      )).start()


#            Util.push_ios([body[ProtocolItem.MESSAGES][ProtocolItem.DEST_ID]], 'alarm', body[ProtocolItem.MESSAGES][ProtocolItem.CONTENT])
        return {'_id': '0'}

    def get(self):
        return {'get': 'None'}

api.add_resource(Messages, '/bd/api/messages')

if __name__ == '__main__':
    app.run(debug=True, port=5001)
from web.app import app

DEBUG = True

app.run(debug=DEBUG)
Example #36
0
from web.app import app


if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8080, debug=True, ssl_context=("config/ssl.crt", "config/ssl.key"))
Example #37
0
from web.app import app as application

if __name__ == '__main__':
    application.run()