def main(): logger.info('Script started.') config.init_web() web.start() driver = web.driver driver.get('https://www.google.com')
def main(): moteProbe_handlers = [] moteConnector_handlers = [] moteState_handlers = [] # create a moteProbe for each mote connected to this computer serialPorts = moteProbe.utils.findSerialPorts() tcpPorts = [TCP_PORT_START+i for i in range(len(serialPorts))] for (serialPort,tcpPort) in zip(serialPorts,tcpPorts): moteProbe_handlers.append(moteProbe.moteProbe(serialPort,tcpPort)) # create a moteConnector for each moteProbe for mp in moteProbe_handlers: moteConnector_handlers.append(moteConnector.moteConnector(LOCAL_ADDRESS,mp.getTcpPort())) # create a moteState for each moteConnector for mc in moteConnector_handlers: moteState_handlers.append(moteState.moteState(mc)) # create an openWeb web = MoteStateWeb(moteProbe_handlers, moteConnector_handlers, moteState_handlers) # start threads for ms in moteState_handlers: ms.start() for mc in moteConnector_handlers: mc.start() web.start()
def reset(): logger.info('Script started.') config.init_web() web.start() driver = web.driver driver.implicitly_wait(3) driver.get(config.url) driver.set_window_size(1680, 947) driver.find_element(By.ID, "showlogininfo").click() driver.find_element(By.ID, "txt_Username").send_keys(config.username) driver.find_element(By.ID, "txt_Password").send_keys(config.password) driver.find_element(By.ID, "loginbutton").click() driver.find_element(By.ID, "name_addconfig").click() driver.find_element(By.ID, "name_maintaininfo").click() driver.switch_to.frame(0) time.sleep(2) driver.find_element(By.ID, "btnsaveandreboot").click() driver.switch_to.alert.accept() wait_time = 75 logger.info('Request submitted, sleeping {} seconds'.format(wait_time)) time.sleep(wait_time)
def start(): fileConfig('conf/log.conf') logging.getLogger('garage').log(logging.DEBUG, 'Log setup complete') logging.getLogger('garage').log(logging.DEBUG, 'Initializing datastore ') db = DataStore(setup='true') db.shutdown() logging.getLogger('garage').log(logging.DEBUG, 'Complete') #butler = None butler = Butler() web.start(butler)
def main(): search_q = ['who is', 'what is', 'tell me about', 'show me about'] bye_q = ['goodbye', 'turn off', 'shutdown', 'packup', 'bye', 'close'] while True: query = input("Enter Command:- ").lower() # query = takecommand().lower() if "google" in query: web.start(query) elif "time" in query: speak(cloak.time()) elif "date" in query: speak(cloak.date()) elif 'search' in query: web.search(query) elif "youtube" in query: web.start(query) elif 'open' in query: file_open.File(query) elif 'how are you' in query: speak("Fine") elif 'note' in query: qry = " "+' ' + '\n' + f'{cloak.date()} ' + \ f'{cloak.time()}' + '\n' + query[5:] + '\n' with open("note.txt", 'a') as file: file.writelines(qry) speak("Ok Boss") elif 'nickname' in query: with open('nickname.txt', mode='r') as nick_file: name = nick_file.read() speak(f"My nickname is {name}") elif query in bye_q: speak("Good bye sir, see you soon") quit() else: for item in search_q: if item in query: speak("Searching...") web.search(query) for item in ['hi', 'hello']: if item in query: speak("Hello sir, How can I help you")
def start(): setup_logging() logging.getLogger('pyro').info("started") db = DataStore(setup=True) db.apply_active_profile() settings = db.get_settings() settings['enabled'] = 0 db.save_settings(settings) settings = db.get_settings() logging.getLogger('pyro').debug('starting with settings: %s' % settings) control = Control() control.start() print('starting web') web.start()
def start(): setup_logging() logging.getLogger('pyro').info("started") db = DataStore(setup=True) db.apply_active_profile() settings = db.get_settings() settings['enabled'] = 0 db.save_settings(settings) settings = db.get_settings() logging.getLogger('pyro').debug('starting with settings: %s'% settings) control = Control() control.start() print('starting web') web.start()
def __init__(self): logging.info(":: RemonPi Initialize...") # Vendor vendor = os.getenv('REMONPI_VENDOR') if vendor is None: raise Exception("REMONPI_VENDOR is not defined!") # Model model = os.getenv('REMONPI_MODEL') if model is None: raise Exception("REMONPI_MODEL is not defined!") logging.info(":: Vendor/Model choosed: %s/%s" % (vendor, model)) # Web Server HTTP_PORT = os.getenv('HTTP_PORT') if HTTP_PORT is None: HTTP_PORT = 8080 web.start(self, HTTP_PORT)
def evaluate(eval_corpus_file, theta, start_url): docs = gen_docs.get_all_docs(eval_corpus_file) random.shuffle(docs) docs = docs[:100] driver = web.start(start_url) correct_docs = 0 correct_cmds = 0 total_cmds = 0 for doc in docs: driver.get(start_url) doc_correct = True for cmd in doc: total_cmds += 1 text_cmd, (cmd_type, wtid, arg) = cmd # do it state = web.build_state(driver, web.tokenize_command(text_cmd)) actions = state.enumerate_actions() action, best_score, probs = state.get_action_probs(actions, theta) if action and \ action.type == cmd_type and \ action.element.get_attribute('x-wtid') == wtid and \ (action.params == None or text_classification.untokenize_subcommand(action.params).lower() == arg.lower()): correct_cmds += 1 else: print "Failed: ", action, " for ", text_cmd doc_correct = False if action: action.perform(driver) if doc_correct: correct_docs += 1 driver.quit() return float(correct_docs) / len(docs), float(correct_cmds) / total_cmds
def setUpModule(): web.start() lasersaur.local()
def setUpModule(): web.start(debug=False) time.sleep(0.5) lasersaur.local()
#coding=utf-8 #Created by xutao on 2017-04-14. import logging from Settings import LoggerLevel from utils import ConfigUtils from utils.ConfigUtils import KEYMAP from web import start from utils.LogUtils import LoggingFormatter, LoggingHandle if __name__ == "__main__": # logging.basicConfig(level=LoggerLevel, # format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s') formater = LoggingFormatter(filename='startFlask') handle = LoggingHandle() handle.setLevel(LoggerLevel) handle.setFormatter(formater) logging.getLogger('').addHandler(handle) start(host=ConfigUtils.getWebPorperties(KEYMAP.HOST), port=int(ConfigUtils.getWebPorperties(KEYMAP.PORT)))
def setUpModule(): web.start(threaded=True, debug=False) time.sleep(0.5) lasersaur.local()
def prepare_swarm_from_web(locust, hatch_rate=1, max=1): web.start(locust, hatch_rate, max) gevent.sleep(200000)
# otherwise some initialization will use the wrong values. import web try: import Tkinter except ImportError: args.cli = True if not args.cli: import window root = window.init() print "DriveboardApp v" + config.conf['version'] # start server in thread web.start(browser=(not args.nobrowser), debug=args.debug) # main thread loop while 1: try: if not args.cli: try: root.update() except Tkinter.TclError: break time.sleep(0.1) except KeyboardInterrupt: break web.stop() print "END of DriveboardApp"
def policy_gradient(command_documents, start_url = "http://localhost:8000", visualize=False, ITERATIONS=50): theta = np.zeros(len(web.Action.FEATURE_NAMES)) for i in range(len(web.Action.FEATURE_NAMES)): theta[i] = (((random.random() * 2) - 1) / 1000) theta_history = [copy.copy(theta)] reward_history = [] driver = web.start(start_url) try: for i in range(ITERATIONS): avg_dist = 0 for doc_num, document in enumerate(command_documents): driver.get(start_url) state_actions = [] action_choices = [] rewarder = Rewarder([command[1] for command in document]) # STEP 3 for t in range(len(document)): cmd, annotation = document[t] state = web.build_state(driver, web.tokenize_command(cmd)) actions = state.enumerate_actions() action, best_score, probs = state.get_action_probs(actions, theta) # we got to page where we cant do anything any more so end # the history here if action == None: break # pick an action weighted by how likely it is r = random.random() acc_prob = 0 for a in probs: acc_prob += probs[a] if acc_prob > r: action = a break logging.debug(state.phi_dot_theta_str(action, theta)) rewarder.update_reward(state, action) logging.debug("Performing... %s for %s",action, cmd) action.perform(driver, dry=False) state_actions.append(( state, action, best_score )) action_choices.append(probs) gradient = np.zeros(len(web.Action.FEATURE_NAMES)) for t in range(len(state_actions)): phi_t = state_actions[t][1].as_numeric_vector() # STEP 4 weighted_actions = np.zeros(len(web.Action.FEATURE_NAMES)) for action in action_choices[t]: prob_action = action_choices[t][action] weighted_actions = np.add(weighted_actions, \ np.multiply(action.as_numeric_vector(), prob_action)) gradient = np.add(gradient, np.subtract(phi_t, weighted_actions)) # STEP 5 r = rewarder.get_reward() #reward_gold_standard(state_actions, document) logging.info("Reward: %d",r) reward_history.append(r) theta = np.add(theta, np.multiply(r, gradient)) theta_history.append(copy.copy(theta)) if len(theta_history) > 1: avg_dist += distance.euclidean(theta, theta_history[-2]) / len(command_documents) logging.info("Avg_dist: %f", avg_dist) if avg_dist < .1: logging.info("Theta is not changing much in the latest iteration, breaking") break finally: driver.quit() if visualize: from matplotlib import pyplot as plt plt.plot(reward_history, 'o') for i in range(len(web.Action.FEATURE_NAMES)): plt.plot([x[i] for x in theta_history]) plt.legend(['reward'] + web.Action.FEATURE_NAMES) plt.show() return theta
datefmt='%Y/%m/%d %H:%M:%S %z', level=LOG_LEVEL) if len(sys.argv) < 3: print("Usage: hexpi <gpio> <http|hex [code...]|ir [signals...]|sensors>") sys.exit(0) # default = 2 gpio = int(sys.argv[1]) mode = sys.argv[2] signal = [] if mode == "http": port = os.getenv("HTTP_PORT") if port is None: port = "8081" web.start(port, gpio) elif mode == "hex": def f(n): return int(n, 0) for s in sys.argv[3:]: hexCode = list(map(f, s.split(","))) signal.append(hexCode) signal = aeha.toCode(430, signal, 13300) ir.send(gpio, signal) elif mode == "ir": signal = list(map(int, sys.argv[3:])) ir.send(gpio, signal)
for db_name, db_config in conf['databases'].iteritems(): databases[db_name] = adbapi.ConnectionPool(*db_config) db = databases['default'] pluginreg.reload_commands(ctlg) command_handler = command.CommandHandler( conf, result_sets, ctlg) for server, server_config in conf['servers'].iteritems(): servers[server] = f = factory.BotFactory() f.ircnet = server f.channels = [c for c in server_config['channels']] f.irc_host = server_config['host'] f.irc_port = server_config['port'] f.nickname = server_config['nickname'] f.realname = server_config['realname'] f.password = server_config['password'] f.username = server_config['username'] f.prefix = server_config['command_prefix'] f.conf = conf f.request_factory = request.Request f.protocol = proto.BotProtocol f.handler = command_handler reactor.connectTCP(f.irc_host, f.irc_port, f) web.start(result_sets, ctlg) linerecv.start(command_handler, servers) reactor.run()
import web as Server Server.start()
args = argparser.parse_args() try: import Tkinter except ImportError: args.cli = True if not args.cli: import window root = window.init() print "DriveboardApp v" + conf['version'] conf['usb_reset_hack'] = args.usbhack # start server in thread web.start(browser=(not args.nobrowser), debug=args.debug) # main thread loop while 1: try: if not args.cli: try: root.update() except Tkinter.TclError: break time.sleep(0.1) except KeyboardInterrupt: break web.stop() print "END of DriveboardApp"
import random import readline from data import gen_docs import sys parser = argparse.ArgumentParser(description="Launch an interactive web talk session attached to Chrome") parser.add_argument("theta_file", type=file, help="A file containing a theta vector in the text output format of numpy, pass as an argument or pipe in through stdin", default=sys.stdin, nargs='?') args = parser.parse_args() theta = np.loadtxt(args.theta_file) try: driver = web.start("http://localhost:8000") cmd = "" sys.stdin = open('/dev/tty') while cmd != "QUIT": cmd = raw_input('> ') state = web.build_state(driver, web.tokenize_command(cmd)) actions = state.enumerate_actions() action, best_score, probs = state.get_action_probs(actions, theta) print "Performing... ", action print "With prob: ", probs[action] print state.phi_dot_theta_str(action, theta)
def startup() : deamonize(router.midiOutput) deamonize(router.midiInput) deamonize(router.oscInput) web.start()
db = databases['default'] users = userdb.UserDB(db) pluginreg.reload_commands(catalog) command_handler = command.CommandHandler( db, users, conf, result_sets, catalog) for server, server_config in conf['servers'].iteritems(): servers[server] = f = factory.BotFactory() f.db = db f.channels = [c for c in server_config['channels']] f.irc_host = server_config['host'] f.irc_port = server_config['port'] f.nickname = server_config['nickname'] f.realname = server_config['realname'] f.password = server_config['password'] f.username = server_config['username'] f.prefix = server_config['command_prefix'] f.conf = conf f.users = users f.request_factory = request.Request f.protocol = proto.BotProtocol f.handler = command_handler f.youtube_playlist = yt_playlist reactor.connectTCP(f.irc_host, f.irc_port, f) web.start(result_sets, yt_playlist) linerecv.start(command_handler, servers) reactor.run()
async def start_webserver(self): import web web.start(self) await uasyncio.sleep_ms(500)
import os from util import ir, aeha import web if len(sys.argv) < 3: print("Usage: hexpi <gpio> <http|hex|ir> [code...]") sys.exit(0) # default = 2 gpio = int(sys.argv[1]) mode = sys.argv[2] signal = [] if mode == "http": port = os.getenv("HTTP_PORT") if port is None: port = "8081" web.start(port) elif mode == "hex": def f(n): return int(n, 0) for s in sys.argv[3:]: hexCode = list(map(f, s.split(","))) signal.append(hexCode) signal = aeha.toCode(430, signal, 13300) elif mode == "ir": signal = list(map(int, sys.argv[3:])) ir.send(gpio, signal)
def start(): fileConfig('conf/log.conf') logging.getLogger('lumens').log(logging.DEBUG, 'Log setup complete') _lumens = Lumens() web.start(_lumens)
def network_found(self): # logging.info("network found") if not web.running: web.start(self, self.messages) self.locontrol.start_info_screen()
def startup(): deamonize(router.midiOutput) # deamonize(router.midiInput) deamonize(router.oscInput) web.start()
def startWeb(self): web.start(self)
import mqtt import web mqtt.start() web.start()