def mainLoop(self, a=''): ## Set default configuration if it does not exists yet randomString = random.getrandbits(512) self.config.getKey('project.directories', [ '/var/www/', '/srv/http/' ]) self.config.getKey('ide.openFileCommand', '/usr/bin/kate %path% --line %line%') self.config.getKey('allowedHosts', ['localhost', '::1', '127.0.0.1']) self.config.getKey('security.tokens', [hashlib.sha256(bytes(randomString)).hexdigest()]) webserver.run()
def run(self, opts): with open(opts.config, 'r') as configfile: config = yaml.load(configfile, Loader=yaml.SafeLoader) self.db = dataset.connect('sqlite:///{}'.format(config['db'])) self.periodic_db = dataset.connect('sqlite:///{}'.format(config['db'])) self.config = config if 'debug' not in config: config['debug'] = False if config['debug']: logger.info("Debug mode is ON") """Start the bot.""" # Create the EventHandler and pass it your bot's token. updater = Updater(config['token'], use_context=True) self.bot = updater.bot """Set up handlers""" for handler in HANDLERS.values(): handler.setup(self.config, self.send_message) t = threading.Thread(target=self.scheduler_run) t.start() # Get the dispatcher to register handlers dp = updater.dispatcher dp.add_handler(CommandHandler("help", self.handle_help)) dp.add_error_handler(self.handle_error) # Callback queries from button presses dp.add_handler(CallbackQueryHandler(self.handle_inline_button)) dp.add_handler(MessageHandler(None, self.handle_message)) # Start the Bot updater.start_polling() webserver.init(self.send_message, self.config) webserver.run() updater.idle() self.exit.set() for handler in HANDLERS.values(): handler.teardown()
def checkcommand(command): if command == 'pynote': import pynote pynote.run() elif command == 'datrw': import datrw datrw.run() elif command == 'setup': import setuprerun setuprerun.run() elif command == "webtest": import webtest webtest.run() elif command == "help": import webserver webserver.run() elif command == "pyconsole": import pyconsole pyconsole.run()
while box != "exit": box = input(">") # testa console de ferramentas webexconsole(box) # logica para usuarios if conversa == 0: # usa arvo de decisao própria msg, arquivo = logica_pura(box, usermail) print(msg) print("arquivo:" + str(arquivo)) if conversa == 1: # usa arvore de decisao pronta ou card msg, arquivo = logica(box, usermail, salaid) print(msg) print("arquivo:" + str(arquivo)) elif formato == 'w': run() else: print( "nenhum formato selecionado. Selecione (c) para teste ou (w) para producao" )
import argparse import sys parser = argparse.ArgumentParser() parser.description = """ Run gimber.py in the selected mode """ parser.add_argument("mode", help="Running mode of gimber", choices=["tilesgen", "interactive", "webserver"]) conf = parser.parse_args(sys.argv[1:2]) argv = sys.argv[2:] if conf.mode == "tilesgen": import tilesgen tilesgen.run(argv) elif conf.mode == "webserver": import webserver webserver.run(argv) elif conf.mode == "interactive": import interactive interactive.run(argv)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import webserver webserver.run()
import threading import os windows = (os.name == 'nt') ui = None if gui and not windows: import linuxui ui = linuxui.AgentUI() import tagcloud tagclouder = tagcloud.TagCloud() #threading.Thread(target=tagcloud.update_cloud) tagclouder.setDaemon(True) tagclouder.start() server = threading.Thread(target=lambda: webserver.run(tagclouder)) server.setDaemon(True) server.start() if not PROD: import modreloader reloader = threading.Thread(target=modreloader.update_modules) reloader.setDaemon(True) reloader.start() import phrases phraser = threading.Thread(target=phrases.maintain_phrases) phraser.setDaemon(True) phraser.start() tostop = ""
"""Run the PaKeT funding server.""" import sys import os.path import util.logger import webserver import api.routes # Python imports are silly. sys.path.append(os.path.join(os.path.dirname(__file__), '..')) # pylint: disable=wrong-import-position import api.swagger_specs # pylint: enable=wrong-import-position util.logger.setup() webserver.run(api.routes.BLUEPRINT, api.swagger_specs.CONFIG, api.routes.PORT)
parser = argparse.ArgumentParser(description="Run a simple HTTP server") parser.add_argument( "-l", "--listen", default="localhost", help="Specify the IP address on which the server listens", ) parser.add_argument( "-p", "--port", type=int, default=7000, help="Specify the port on which the server listens", ) args = parser.parse_args() print("Before run") # Run the webserver webserver.run(addr=args.listen, port=args.port, allData=allData) # Run master #global oscBuilder #global lastJsonData #global lastJsonDataTimestamp player = player.PlayerMaster(oscBuilder, allData) player.start() # Start forever loops #waitForever()
def create_app(g): import webserver import logging log = logging.getLogger('werkzeug') log.setLevel(logging.ERROR) webserver.run(g)
if 'delete' in fields.keys(): post_data = fields['delete'][0].split('Delete ')[1] del_rest = session.query(Restaurant).filter_by( name=post_data).one() session.delete(del_rest) session.commit() restaurants = session.query(Restaurant).all() self.render('hello.html', restaurants=restaurants) elif 'name' in fields.keys(): rest_name = fields['name'][0] rest = Restaurant(name=rest_name) session.add(rest) session.commit() restaurants = session.query(Restaurant).all() self.render('hello.html', restaurants=restaurants) elif 'rename_s' in fields.keys(): name = fields['rename_s'][0].split('Rename ')[1] rest_name = fields['rename'][0] print rest_name rest = session.query(Restaurant).filter_by(name=name).one() rest.name = rest_name session.add(rest) session.commit() restaurants = session.query(Restaurant).all() self.render('hello.html', restaurants=restaurants) run(HelloWorld)
import tweet_parser import models import webserver import math def elon_musk_data(): return tweet_parser.generate_data("elon_musk") print("Initalizing data for server") data = elon_musk_data() model = models.init(data) print("Server running") webserver.run(model)
import webserver def getConfig(): with open('./marketsconfig.json') as json_data: return json.load(json_data) logging.basicConfig(level=logging.INFO) config = getConfig() db = marketdb.Database(config) output=[] webserver = webserver.TraderHTTPServer() webserver.run(9080,output) ## start a simple webserver on localhost:9080 and follow the online progress while trading every hour binex = binanceex.Binanceex(config, db) binex.createPortfolioVector() downloader = download.Downloader(config,db,binex) downloader.download() agent = agent.Agent(config, db, neural.Neural(config), output) agent.train() agent.restore("./model/my_test_model-5000") agent.trade()
def main(argv): (options, input_files) = parser.parse_args(args=argv[1:]) # prepare regular expressions link_ignore_expressions = prepare_link_ignore_re(options.ignore_links) print "parsing WARC archives" all_urls = [] for filename in expand_files(input_files): print "WARC: "+filename link_cache_filename = filename+'.urls' if options.persist_links and os.path.exists(link_cache_filename): url_fh = open(link_cache_filename, 'r') urls = pickle.load(url_fh) url_fh.close() all_urls += urls else: urls = [] fh = WarcRecord.open_archive(filename, gzip="auto") for record in fh: record = record """@type : ArchiveRecord """ if not record.is_response(): continue urls.append({ 'url': record.url, 'content-type': record.content_content_type }) # urls.sort(cmp=url_cmp) if options.persist_links: url_fh = open(link_cache_filename, 'w+') pickle.dump(urls, url_fh) url_fh.close() fh.close() all_urls += urls if options.dump_links is not None: f = open(options.dump_links, 'w+') all_urls.sort() for url in all_urls: # skip ignorable links skip_addition = False for expression in link_ignore_expressions: if expression.match(url['url']): skip_addition = True break if not skip_addition: f.write(url['url']) f.write('\n') f.close() if options.web_start is not False: urltree = UrlTree() for url in all_urls: # skip filtered links via regex skip_addition = False for expression in link_ignore_expressions: if expression.match(url['url']): skip_addition = True break # skip links filtered by content_type filter if options.content_type: if not url['content-type'].startswith(options.content_type): skip_addition = True if options.content_type_not: if url['content-type'].startswith(options.content_type_not): skip_addition = True if not skip_addition: urltree.add_url(url['url']) print "Total urls: "+str(urltree.childcount) webserver.run(urltree)