def test_E2E(): with open('src/test/E2E_output.txt', 'w+') as text_file: text_file.write('') app.run('src/test/E2E_input.txt', 'src/test/E2E_output.txt') with open('src/test/E2E_output.txt', 'r') as text_file: contents = text_file.read() assert contents == '20|toaster_1|8|SOLD|12.50|3|20.00|7.50\n20|tv_1||UNSOLD|0.00|2|200.00|150.00\n'
def run(ctx, download_to, no_download, no_parse, no_cleanup, verbose): """Run the app""" set_verbosity(verbose) app.run(to, no_cleanup=no_cleanup, no_download=no_download, no_parse=no_parse)
def main(): loggers.standard_config() try: app.run() except Exception as e: logger.exception("Process failed.")
def test_main(self): app.run(hidden=300, layer=1, dropout=0.0, learning_rate=0.01, iteration=5, save=10, train='./data/starwars.txt', test=False)
def testDataRetrieval(self): keywords = [""] scraper = ScraperInterface(keywords) scraper.storeInIncidentsCollection(["Carbon Dioxide, Test Chemicals"], "12/22/2019", "Detroit", ["This is the official statement"], ["www.testUrl.com"]) app.run()
def main(args=None): app.run(debug=True) """Console script for {{cookiecutter.lname}}.""" click.echo("Replace this message by putting your code into " "{{cookiecutter.lname}}.cli.main") click.echo("See click documentation at http://click.pocoo.org/") return 0
def test_run(self, mocked_executor): self.args = mock.MagicMock() self.args.email = "*****@*****.**" self.args.master = "master" self.args.exec_tasks = "RecipesTransformationTask" app.run(self.args) # Check only RecipesTransformationTask is called self.assertIn("RecipesTransformationTask", str(mocked_executor.call_args)) self.assertNotIn("SaveRecipesParquetTask", str(mocked_executor.call_args))
def test_default_pipeline(self, mocked_executor): self.args = mock.MagicMock() self.args.email = "*****@*****.**" self.args.master = "master" self.args.exec_tasks = "" app.run(self.args) mocked_executor.assert_called() self.assertIn("RecipesTransformationTask", str(mocked_executor.call_args)) self.assertIn("SaveRecipesParquetTask", str(mocked_executor.call_args))
def run_app(app): parser = OptionParser() parser.add_option('-d', '--debug', dest='debug', default=False, action='store_true', help='Turn on debugging') parser.add_option('-p', '--port', dest='port', type=int, default=5000, help='Specify the server port') parser.add_option('-l', '--listen', dest='listen_addr', default='::1', help='Specify the listening address') options, args = parser.parse_args() app.run(host=options.listen_addr, port=options.port, debug=options.debug)
def serve(self): parser = argparse.ArgumentParser( description='Download objects and refs from another repository') # NOT prefixing the argument with -- means it's not optional parser.add_argument('--site,s', dest='site', default='./_site') parser.add_argument('--hostname,h', dest='hostname', default='localhost') parser.add_argument('--port,p', dest='port', type=int, default=80) args = parser.parse_args(sys.argv[2:]) if not os.path.isdir(args.site): print '\033[91m\r', 'Site directory "', args.site, '" does not exist', '\033[0m' return app.run(args.site, args.hostname, args.port)
def main() -> None: args = parse_args() try: if args.config: configs = load_config_file(args.config) else: configs = load_config_environ(args.debug) except Exception: print(strings.FAILED_TO_LOAD_CONFIG) return app.init(configs, debug=args.debug) app.run()
def main(): #read config file conf_dic = toml.load('config.toml') #determine if program set for testing or deployment if (conf_dic['use_test'] == True): files = conf_dic['files']['test'] else: files = conf_dic['files']['deploy'] #extract paths for passwd and group files and port for webserver passwd_path = files['passwd'] users_path = files['group'] port = conf_dic['port'] run(passwd_path, users_path, port)
def restart(): back = input('\nWould you like to go to another calculator? y/n ') if back == 'y': print('Aight, bringing you back!') import app app.run() elif back == 'n': if e.used: e.wb.save('Rocket Parameters.xls') print('OK!') else: print('Invalid! Try Again') restart()
def test_validate_number_in_interval_double(self): prod, cons = app.run(Config.K_MONITOR_TEST_TOPIC, Config.PS_DATABASE_NAME, Config.PS_TEST_WEBSITE_TABLE_NAME, "tests/t_monitor_heavy_test.yml") interval = File.read_time_interval("tests/t_monitor_heavy_test.yml") time.sleep(interval * 2) app.stop_monitor(prod, cons) admin_client = KafkaAdminClient( bootstrap_servers=[Config.K_HOST + ':' + Config.K_PORT], security_protocol=Config.K_SECURITY_PROTOCOL, ssl_cafile=Config.K_SSL_CAT_FILE, ssl_certfile=Config.K_SSL_CERT_FILE, ssl_keyfile=Config.K_SSL_KEY_FILE) admin_client.delete_topics([Config.K_MONITOR_TEST_TOPIC]) monitors = File.read_monitors("tests/t_monitor_heavy_test.yml") #send messages equals total urls count in 2 cycle is double the urls size self.assertEqual(prod.get_message_count(), len(monitors) * 2)
async def runner(): asyncio.create_task(app.run(loop)) try: await self.start(*args, **kwargs) finally: if not self.is_closed(): await self.close()
def start(self, func=None, when_done=None, delay=0): assert not self.is_running() def default_func(thread): while not thread.is_stopping(): events = yield from thread.idle() def default_done(future): app.log.future(future) def run(): if delay: yield from asyncio.sleep(delay) yield from (func or default_func)(self) def done(future): self._pending.clear() self._scheduled.clear() try: (when_done or default_done)(future) except: app.log.exception("async: done: %r", self) del self._coro self._coro = asyncio.ensure_future(run()) self._coro.add_done_callback(done)
def test_b_corrupted_monitor_file(self): self.assertRaises( Exception, lambda: app.run( Config.K_MONITOR_TEST_TOPIC, Config.PS_DATABASE_NAME, Config. PS_TEST_WEBSITE_TABLE_NAME, "tests/t_monitor_corrupted_interval.yml"))
def test_can_extract_transfer_and_insert_data(self): ''' Passes test if data is extracted, transferd and inserted in database ''' data_before_insertion = QueryHelper.query_result_formatter( DatabaseHelper.select(self.select_query)) run(self.insert_path, self.data_path) data_after_insertion = QueryHelper.query_result_formatter( DatabaseHelper.select(self.select_query)) difference = list( QueryHelper.query_comparor(data_before_insertion, data_after_insertion)) self.assertEqual(difference, [['John', 'Smith', '100', 'male', 'American']])
async def main(): log.init() log.msg('Awaiting main futures...') futures = [disp.run(), app.run()] await asyncio.wait(futures) log.finalize()
def main(argv): mode = '' try: opts, args = getopt.getopt(argv,"m:h",["mode="]) except getopt.GetoptError: print('run.py -m <TESTING/LIVE_TESTING/TRADING/FETCH_DATA>') sys.exit(2) for opt, arg in opts: if opt == '-h': print('run.py -m <TESTING/LIVE_TESTING/TRADING/FETCH_DATA>') sys.exit() elif opt in ("-m", "--mode"): if arg in TradingMode.__members__: mode = TradingMode[arg] else: raise UnsupportedModeError(arg, "The given mode is not supported!") app.run(mode)
def main(): if len(sys.argv) < 2: eprint("Please include a file as an argument!") sys.exit(1) filename = sys.argv[1] if not os.path.isfile(filename): eprint("{!r} is not a file!".format(filename)) sys.exit(1) print(app.run(filename)) sys.exit(0)
def test_db(self): aiven_results = 0 try: psql_conn = Database(Config.PS_DATABASE_NAME) print("DB Connected!") query = """ CREATE TABLE IF NOT EXISTS """ + Config.PS_TEST_WEBSITE_TABLE_NAME + """ ( name varchar(255) NOT NULL, url varchar(255) NOT NULL, status_code integer NOT NULL, reason varchar(255) NOT NULL, response_time decimal NOT NULL, checked_at timestamp NOT NULL, pattern varchar(255), has_pattern boolean DEFAULT FALSE, PRIMARY KEY(url, checked_at) ) """ psql_conn.query(query) print("Table created successfully in PostgreSQL ") query = "DELETE FROM " + Config.PS_TEST_WEBSITE_TABLE_NAME + " WHERE url = 'https://aiven.io'" psql_conn.query(query) prod, cons = app.run(Config.K_MONITOR_TOPIC, Config.PS_DATABASE_NAME, Config.PS_TEST_WEBSITE_TABLE_NAME, "tests/t_monitor_db.yml") print("all 'aiven.io' is deleted from PostgreSQL ") interval = File.read_time_interval("tests/t_monitor_corrupted.yml") time.sleep(interval - 1) app.stop_monitor(prod, cons) query = "SELECT * FROM " + Config.PS_TEST_WEBSITE_TABLE_NAME + " WHERE url = 'https://aiven.io'" cursor = psql_conn.query(query) aiven_results = cursor.fetchall() psql_conn = Database(Config.PS_DATABASE_NAME) query = "DROP TABLE " + Config.PS_TEST_WEBSITE_TABLE_NAME psql_conn.query(query) psql_conn.close() except Exception as error: print("Error while connecting to PostgreSQL", error) self.assertEqual(len(aiven_results), 1)
def main(): args = sys.argv[1:] # env_settings if len(args) > 1 and args[0] in ['-e', '--env']: env = args[1] args = args[2:] else: env = 'develop' # help if len(args) > 0 and args[0] in ['-h', '--help']: usage_exit() # config_initialize try: init_config(env=env) except Exception as e: print(e) exit(1) run(env=env)
def test_paging_mission_control(self): dirname = os.path.dirname(__file__) ifile = os.path.join(dirname, "data", "input.txt") ofile = os.path.join(dirname, "data", "output.txt") result = json.load(io.StringIO(app.run(ifile))) output = open(ofile) expected = json.load(output) output.close() for left, right in zip(result, expected): self.assertDictEqual(left, right)
def main(): # Reads project-config.json config = pc.read() # Helpful variables tools_path = config['toolsPath'] module_name = config['moduleName'] module_path = config['modulePath'] module_build_path = config['moduleBuildPath'] module_destination_path = config['moduleDestinationPath'] app_name = config['appName'] app_path = config['appPath'] app_build_path = config['appBuildPath'] app_main_canonical_path = config['appMainCanonicalPath'] # Module and Application build module.build(module_name, module_path) module.copy(module_name, module_build_path, module_destination_path) os.system(f"echo \"{bash.divider()}\"") app.build(app_name, app_path) app.install(app_name, tools_path, app_build_path) app.run(app_name, tools_path, app_main_canonical_path)
def Run(): """This must be called from __main__ modules main, instead of app.run(). app.run will base its actions on its stacktrace. Returns: app.run() """ app.parse_flags_with_usage = ParseFlagsWithUsage original_really_start = app.really_start def InterceptReallyStart(): original_really_start(main=_CommandsStart) app.really_start = InterceptReallyStart app.usage = _ReplacementAppUsage return app.run()
def A__init__(self, schema: str = ""): self.webapp = run({ "server": { "webserver": { "name": "test_client", "port": 5001, "TESTING": True, "reloader": False } } }) self.app = self.webapp.app self.schema = schema self.init = {"headers": {'Content-Type': 'application/json'}}
def test_producer_equal_consumer(self): prod, cons = app.run(Config.K_MONITOR_TEST_TOPIC, Config.PS_DATABASE_NAME, Config.PS_TEST_WEBSITE_TABLE_NAME) interval = File.read_time_interval() time.sleep(interval - 1) app.stop_monitor(prod, cons) admin_client = KafkaAdminClient( bootstrap_servers=[Config.K_HOST + ':' + Config.K_PORT], security_protocol=Config.K_SECURITY_PROTOCOL, ssl_cafile=Config.K_SSL_CAT_FILE, ssl_certfile=Config.K_SSL_CERT_FILE, ssl_keyfile=Config.K_SSL_KEY_FILE) admin_client.delete_topics([Config.K_MONITOR_TEST_TOPIC]) self.assertEqual(prod.get_message_count(), cons.get_message_count())
def escritorio(): import app app.run()
CELERY_RESULT_BACKEND = "redis://localhost:6379" app = Flask(__name__) app.config.from_object(__name__) db = SQLAlchemy(app) Bootstrap(app) # Initialize Celery celery = Celery(app.name, broker=app.config["CELERY_BROKER_URL"]) celery.conf.update(app.config) from view.main.main import main app.register_blueprint(main) @app.errorhandler(404) def page_not_found(error): return render_template("error.html", error=error) @app.errorhandler(401) def no_permission(error): return render_template("error.html", error=error) if __name__ == "__main__": app.run(host="0.0.0.0", port=5000)
Routes and views for the flask application. """ from datetime import datetime from flask import render_template import app from songdictionary import getSentValue from songdictionary import getSongUrlFromValue from flask import request from flask import abort, redirect, url_for from html_rip import link_or_nah, to_text, get_html, visible from mood import determineSubject if __name__ == '__main__': app.debut = True app.run(debug=True) @app.route('/', methods=['POST', 'GET']) def home(): if request.method == 'POST': text = request.form['weblink'] soundtype = request.form['soundtype'] # print("from soundtype: ") return redirect(url_for('music', text=text, soundtype=soundtype)) else: return render_template('index.html') @app.route('/music') def music(): text = request.args['text']
def run_web(): run()
if __name__ == "__main__": from {$name} import app from {$name}.views import * app.run(debug=True, host='127.0.0.1', port=5000)
return defaults.rating() @app.route('/api/v1/apps/rating/<id>/flag/', methods=['POST']) def app_rating_flag(id): return '' @app.route('/api/v1/fireplace/app/<slug>/') def app_(slug): return defaults.app('Something something %s' % slug, slug) @app.route('/api/v1/installs/record/', methods=['POST']) def record_free(): return {'error': False} @app.route('/api/v1/receipts/install/', methods=['POST']) def record_paid(): return {'error': False} @app.route('/api/v1/apps/<id>/statistics/', methods=['GET', 'POST']) def app_stats(id): return json.loads(open('./fixtures/3serieschart.json', 'r').read()) if __name__ == '__main__': app.run()
from app import run from datetime import datetime print "run", datetime.now().isoformat() if __name__ == "__main__": run()
from {{APP_NAME}}.app import app import os if __name__ == '__main__': port = int(os.environ.get('PORT',5000)) app.run(host='0.0.0.0',port=port,debug=True)
#!/usr/bin/python3 import app, sys if app.run() == "Why doesn't this work!?": sys.exit(0) sys.exit(1)
from {{cookiecutter.repo_name}} import app app.run(port=9999, debug=True)
import os os.environ['JAVA_HOME'] = '/usr/lib/jvm/java-11-openjdk-amd64' os.environ['SPARK_HOME'] = '/home/michalo/spark-demo/spark-3.0.0-bin-hadoop2.7' os.environ['HADOOP_HOME'] = os.environ['SPARK_HOME'] import findspark findspark.init() import app app.run()
if len(path)==1: path = "" if hd_lang.find("pt")>=0: return redirect("pt" + path) else: return redirect("en" + path) @app.route('/<lang>/blog', methods=['GET']) @app.route('/<lang>/blog/<page>', methods=['GET']) def blog_main(lang,page=None): return blog.main(request,lang,page) @app.route('/<lang>/app', methods=['GET']) @app.route('/<lang>/app/<page>', methods=['GET']) def app_main(lang,page=None): return app.main(request,lang,page) @app.route('/<lang>', methods=['GET','POST']) def recruit_main(lang): return recruit.main(request,lang) @app.route('/validate_code', methods=['POST']) def recruit_validate_code(): return recruit.validate_code(request) if __name__ == '__main__': port = int(os.environ.get("PORT", 5000)) app.run(host='0.0.0.0', port=port)
import app from log import lg app = app.create_app() if __name__ == '__main__': app.run(host='0.0.0.0', port=5000)
def serve(expenses): import app app.make_app(expenses) app.run(debug=False)
# . venv/bin/activate # pip install -r requirements.txt # # Then run local_deploy.py script - # # python local_deploy.py import argparse import logging ## LOCAL_ENV_IMPORT ## from {{cookiecutter.app_name}}.{{cookiecutter.app_name}} import app if __name__ == '__main__': parser = argparse.ArgumentParser(description='{{cookiecutter.app_description}}') parser.add_argument('--host', default='127.0.0.1', help='Host bind location') parser.add_argument('--port', default=2700, type=int, help='Port') parser.add_argument('--debug', default="True", type=str, help='Enable of disable debug, default True') args = parser.parse_args() args.debug = True if args.debug in ['True', 'T', 'true', 't', 'Yes', 'Y', 'yes', 'y', '1'] else False # Logging logging_format = '[%(asctime)s] %(levelname)s: %(message)s' logging.basicConfig(format=logging_format, level=logging.INFO) # Starting the application app.debug = args.debug app.run(host=args.host, port=args.port)
# run.py import os #from flasktaskr import app import app port = int(os.environ.get('PORT', 5000)) app.run(host='0.0.0.0', port=port, debug=False)
'''Defines the run method of the Flask application. Registers the functions `before_request()` and `after_request()` to run before and after each request, respectively (both functions located in app/views/index). Essentially, these functions open and close a connection to the MySQL database with each request made to the server. ''' from flask import Flask from flask_json import FlaskJSON import app from config import * from app import app from app.views import * if __name__ == '__main__': app.run(host=HOST, port=PORT, debug=DEBUG)
from python-demo.views import app if __name__ == '__main__': app.run(debug=False, threaded=True, port=8090, host='0.0.0.0')
import app app = app.create_app() if __name__ == '__main__': app.run(host='0.0.0.0', port=8080, debug=True)
def runserver(): app.run(host='0.0.0.0', debug=app.config['DEBUG'])
def main(): import app app.run()
# -*- coding: utf-8 -*- import sys import app reload(sys) sys.setdefaultencoding('utf-8') app = app.create_app() if __name__ == '__main__': app.run(host='0.0.0.0', debug=True)
from {{MODULE_NAME}}.web import app if __name__ == '__main__': app.debug = True app.run(host='0.0.0.0', port=5001)
#!/usr/bin/python # -*- coding: utf-8 -*- """ Web server """ import os import app import json URL_FILE = 'urls.json' if __name__ == '__main__': # Ensure to be in the os.chdir(os.path.dirname(os.path.realpath(__file__))) if os.path.exists(URL_FILE): with open(URL_FILE) as file: app.URLS = json.load(file) else: app.URLS = ['www.example.com'] args = { 'host': os.environ.get('APP_HOST', 'localhost'), 'port': os.environ.get('APP_PORT', 8080), 'debug': os.environ.get('APP_DEBUG', False), } app.run(**args)
# True if you don't run as root (you shouldn't run as root) # be sure to add something like the following to your sudoers file: # yourusername ALL=NOPASSWD:/etc/init.d/httpd USE_SUDO=False SERVICES= { # Edit these services to match the ones you want to manage 'apache2': { 'title': 'Apache Web Server', 'ops': ['status', 'stop','start','graceful'], 'status': 'status' }, 'ssh': { 'title': 'SSH Server', 'ops': ['status','stop','start','restart'], 'status': 'status' }, } LOGINS = { # username and password hash # Generate new password hashes by running ./webinitd.py --password yourpasswordhere 'admin': 'sha256:1024:C6vwpHVe:H9QumIJLvdQeb7ZR2izY092umM9TPqPlgVaPZRGeZiY=', } if __name__=="__main__": import app app.run(USE_SUDO,SERVICES,LOGINS)
def runserver(t): import app app.run(host="0.0.0.0")
def test_run(self): app.run() self.assertTrue(True)
show this help -p [port] use this port -s [ip] bind this ip """ import sys import getopt if __name__ == "__main__": try: opts, args = getopt.getopt(sys.argv[1:], "hp:s:") except getopt.GetoptError as err: print str(err) print __doc__ sys.exit(2) port = None ip = '0.0.0.0' for o, a in opts: if o == '-h': print __doc__ sys.exit(1) elif o == '-p': port = int(a) elif o == '-s': ip = a from <%= packageName %>.basemain import app app.run(debug=True, host=ip, port=port)
# -*- coding: utf-8 -*- """ ~~ BeyondCP - run.py ~~ @author WoodyTheWoo @licence 2014 @version v 0.1 """ from os.path import exists from apscheduler.scheduler import Scheduler from app import run from database import db_create_table, DATABASE_PATH if __name__ == "__main__": if exists(DATABASE_PATH): print("Database OK") else: print("Database KO") db_create_table() sched = Scheduler() # sched.add_interval_job(hello, seconds=1) sched.start() run(host='0.0.0.0', debug=True)
prediction=rfmodel.predict(dff) if(prediction==-1): d_entry=open('blacklist.txt','a') d_entry.write("\n") d_entry.write(url) d_entry.close() value="Phishing Website" return render_template("home.html",error=value) elif(rank==-1): d_entry=open('blacklist.txt','a') d_entry.write("\n") d_entry.write(url) d_entry.close() value="Phishing Website" return render_template("home.html",error=value) else: value=url+""+" is not Phishing Website!!" return render_template("home.html",error=value) @app.route('/getAbout') def getAbout(): return render_template('about.html') @app.route('/getAbout1') def getAbout1(): return render_template('about1.html') if __name__=="__main__": app.run(debug=True)
def run(): """ Run app in debug mode (for development). """ app.run()