def start(self): if(not self.running): self.running = True self.clk.start() self.dataBus.start() for core in self.cores_list: core.start() self.play()
def post(self): global mode if core.mode == STOPPED: core.start() core.mode = RECORDING else: core.port.stopRecording() core.mode = STOPPED
def start(options): thread_array = [] for i in range(0, options.request_number): thread_array.append(StressThread(options, i, VERSION)) if options.one_by_one: core.start_one_by_one(thread_array) elif options.no_limit: core.start_custom_limit(thread_array, options.limit) else: core.start(thread_array) show_stat(thread_array, (options.timeout * 1000))
def __init__(self, parent=None): core.start() super(myui, self).__init__(parent) self.setupUi(self) self.btnOffline.setVisible(False) self.btnOffline.clicked.connect(self.btOffClicked) self.btnOnline.clicked.connect(self.btUpClicked) self.btnSendMsg.clicked.connect(self.btnMsgClicked) self.btnSendFile.clicked.connect(self.btnFileClicked) self.listWidget.clicked.connect(self.btnDownload) self.flushBegin() self.user_list = list() self.receives = list()
def main(): args = parse_args() if args.request != 'load' and args.request != 'get': print('request can be either load or get') sys.exit(0) if args.depth < 0: print('--depth should be non-negative') sys.exit(0) if args.n is None and args.request == 'get': print("Specify -n when request is 'load'") sys.exit(0) is_load_request = (args.request == 'load') start_time = time.time() tracemalloc.start() error, response = core.start( is_load_request, not is_load_request, args.url, args.n, args.depth, ) current, peak = tracemalloc.get_traced_memory() end_time = time.time() if error: print('Error occurred while processing request') sys.exit(0) if is_load_request: print('ok, execution time: {0}s, peak memory usage {1} Mb'.format(end_time - start_time, peak / (1024 ** 2))) else: if error: print(error) if response: print([link.get_title() for link in response])
def main(args=None): """CLI script entry point""" warnings.showwarning = lambda *args, **kwargs: None logging.basicConfig(level=logging.DEBUG, format='[%(asctime)s] %(message)s') option_parser = OptionParser(add_help_option=False) option_parser.add_option('-?', '--help', action='help') add_general_options(option_parser) add_auth_options(option_parser) add_filter_options(option_parser) if not args: args = sys.argv args = [unicode(arg, locale.nl_langinfo(locale.CODESET)) for arg in args] for arg in args: print "%r" % arg opts, args = option_parser.parse_args(args) if opts.debug: for handler in logging.root.handlers: logging.root.handlers.remove(handler) logging.basicConfig(level=logging.DEBUG) if opts.password: opts.password = getpass.getpass("Password:") if opts.replication: opts.extra_options += ' --master-data=2' filter_optgroup = option_parser.get_option_group('--include-databases') filter_options = filter_optgroup.option_list for opt in filter_options: filters = compile_filters(getattr(opts, opt.dest)) setattr(opts, opt.dest, filters) if opts.dry_run: dry_run(opts.__dict__) else: start(opts.__dict__)
import random import time import core QUANT = 7 locations = core.get_available_locations() random.shuffle(locations) r_loc = locations[:QUANT] kinds = core.get_tower_types() random.shuffle(kinds) r_kind = kinds[:QUANT] test = {l: k for l, k in zip(r_loc, r_kind)} tini = time.time() score = core.start(test, drawing=False) delta = time.time() - tini print("Finished for {} quant! Score: {} (took {:.3f})".format(QUANT, score, delta)) input("Press any key to continue")
def btnDownload(self, item): file_info = dict() file_info['type'] = "download_file" file_info['data'] = feiQCoreData.download_file_list[item.row()] feiQCoreData.file_info_queue.put(file_info) feiQCoreData.download_file_list.pop(item.row()) def btUpClicked(self): feiQSendMsg.send_broadcast_online_msg() print(self.textEdit.toPlainText()) self.btnOffline.setVisible(True) def btOffClicked(self): feiQSendMsg.send_broadcast_offline_msg() def btnMsgClicked(self): feiQSendMsg.send_msg_2_ip(self.ipCombo.currentData(), self.textEdit.toPlainText()) def btnFileClicked(self): filename = QFileDialog.getOpenFileName() feiQSendMsg.send_file_2_ip(self.ipCombo.currentData(), filename[0].split('/')[-1]) if __name__ == "__main__": app = QApplication(sys.argv) ex = myui() ex.show() sys.exit(app.exec_()) core.start()
import random import time import core locations = core.get_available_locations() r_loc = random.choice(locations) kinds = core.get_tower_types() r_kind = random.choice(kinds) test = {r_loc: r_kind} tini = time.time() score = core.start(test, drawing=True) delta = time.time() - tini print("Finished! Score: {} (took {:.3f})".format(score, delta))
import json from pathlib import Path import core if __name__ == "__main__": relPath = str(Path(__file__).parent) + "/" with open(relPath + "config.json", "r") as config_file: config_data = json.load(config_file) with open(relPath + "resources/alias/correct_output.json", "r") as correct_output: # dont log loading file, because it is a config too config_data["correct_output"] = json.load(correct_output) webThr = None core.relPath = relPath core.config_data = config_data core.start(config_data)
def __init__(self, filename, beginCB=None, finishCB=None, debugLevel=2, threaded=False, exceptHook=None, rerecord=None, checkpoints=True): global _threaded logutils.set_debugLevel(debugLevel) _threaded = threaded self.beginCB = beginCB self.finishCB = finishCB self.exceptHook = exceptHook self.checkpoints = checkpoints # if False, checkpoints will be ignored try: file = open(filename, "r") except IOError: self.aborted = True raise self.linerunners = [] if rerecord: core.start(rerecord) # More than one execution line can come from a single source # line, if, for example, automatic pauses are inserted. The # execution line number is used to know when to run a line. # The source line number is useful for debugging. lineno = 0 # number of the line being executed srcline = 1 # source line number pausenext = False # add a pause before the next line? lines = file.readlines() self._nfilelines = len(lines) tobecontinued = "" for line in lines: line = line.rstrip() if not line: self.linerunners.append(CommentLine(self, srcline, lineno, "")) lineno += 1 pausenext = False elif line[-1] == '\\': # Lines ending in a backslash aren't processed # immediately. They're prepended to the next line # instead. tobecontinued += line[:-1] else: # line isn't continued line = tobecontinued + line tobecontinued = "" if line.lstrip()[0] == "#": # line is a comment self.linerunners.append( CommentLine(self, srcline, lineno, line.rstrip())) lineno += 1 pausenext = False else: # not a comment try: words = line.split(None, 1) # look for keyword except: words = None if words and words[0] == 'pause': self.linerunners.append( PauseLine(self, srcline, lineno, eval(words[1]))) lineno += 1 pausenext = False elif words and words[0] == "checkpoint": if self.checkpoints: self.linerunners.append( CheckPointLine(self, srcline, lineno, words[1].rstrip())) lineno += 1 pausenext = False elif words and words[0] == "postpone": self.linerunners.append( PostponeLine(self, srcline, lineno, words[1])) lineno += 1 elif logutils.recording() and words and words[0]=="assert": # When rerecording, don't actually run the # tests that may have been inserted in the # log file. ## TODO: When rerecording, assert statements ## should be copied into the log file *after* ## immediately subsequent checkpoints. That ## is, checkpoints that arise after an ## assertion and before any user action should ## precede the assertion in the log file. self.linerunners.append( CommentLine(self, srcline, lineno, line.rstrip())) lineno += 1 pausenext = False else: # not a special line if pausenext and replaydelay > 0: self.linerunners.append( PauseLine(self, srcline, lineno, replaydelay)) lineno += 1 self.linerunners.append( PerformLine(self, srcline, lineno, line.rstrip())) lineno += 1 pausenext = True srcline += 1 file.close() GUILogPlayer.current = self self.aborted = False
if args.dry_run: sys.exit(user.EXIT_OK) # Abort if we need extra input while # stdin is already bound to a pipe. if args.path == "-": if core.getIn() != len(args.input): print "Missing input, aborting..." sys.exit(user.EXIT_INPUT) # Print the header text: if sys.stdout.isatty(): print "DVM running on {} core(s).".format(args.cores) # Start the cores. core.start(args.cores) # Add command line arguments to runtime. if args.input: for data in args.input: data = read.parseValue(data) core.addData(data) # Fetch the remaining input while not core.hasIn(): if sys.stdin.isatty(): data = raw_input("> ") else: data = raw_input("reading input for port {}...\n".format( core.getPort())) data = read.parseValue(data)
def start2(message): start(message)
from core import start start("http://www.leboncoin.fr/electromenager/offres/rhone_alpes/rhone/?f=a&th=1&pe=8&q=machine+%C3%A0+laver&location=Lyon", "machine_laver.db")
def add_game_values(games): with_values = [] for game in games: with_values.append((game, start(game))) return with_values
poison_pill = False log.info("MQTTany {version} starting".format(version=__version__)) if len(__version__.split("-")) > 1: log.warn("") log.warn("######## DEVELOPMENT VERSION ########") log.warn("# #") log.warn("# This is a development version and #") log.warn("# may be incomplete or unstable #") log.warn("# #") log.warn("#######################################") log.warn("") try: core.start(queue_core, args.config_file) while not poison_pill and not signal.exit: try: # to get an item from the queue message = queue_core.get_nowait() except QueueEmptyError: time.sleep(0.1) # 100ms else: poison_pill = True log.debug("Received exit request from {}".format(message)) except: logger.log_traceback(log) poison_pill = True else: if signal.signal == signal.SIGINT:
def play(game, queue): queue.put((game, start(game)))
print '-p,--path: 指定将要扫描的路径' print '-l,--low: 系统/数据库弱密码扫描' def Version(): print 'scan 0.02 BASE' def OutPut(args): print 'Hello, %s'%args def main(argv): try: opts, args = getopt.getopt(argv[1:], 'hvp:', ['path=']) except getopt.GetoptError, err: print str(err) Usage() sys.exit(2) if len(opts) == 0: if len(args): core.start(args[0]) else: print "scanning [options] [param]" for o, a in opts: if o in ('-h', '--help'): Usage() sys.exit(1) elif o in ('-v', '--version'): Version() sys.exit(0) elif o in ('-p',): core.start(a) sys.exit(0) else: Usage() sys.exit(3)
def __init__(self, filename, beginCB=None, finishCB=None, debugLevel=2, threaded=False, exceptHook=None, rerecord=None, checkpoints=True): global _threaded logutils.set_debugLevel(debugLevel) _threaded = threaded self.beginCB = beginCB self.finishCB = finishCB self.exceptHook = exceptHook self.checkpoints = checkpoints # if False, checkpoints will be ignored try: file = open(filename, "r") except IOError: self.aborted = True raise self.linerunners = [] if rerecord: core.start(rerecord) # More than one execution line can come from a single source # line, if, for example, automatic pauses are inserted. The # execution line number is used to know when to run a line. # The source line number is useful for debugging. lineno = 0 # number of the line being executed srcline = 1 # source line number pausenext = False # add a pause before the next line? lines = file.readlines() self._nfilelines = len(lines) tobecontinued = "" for line in lines: line = line.rstrip() if not line: self.linerunners.append(CommentLine(self, srcline, lineno, "")) lineno += 1 pausenext = False elif line[-1] == '\\': # Lines ending in a backslash aren't processed # immediately. They're prepended to the next line # instead. tobecontinued += line[:-1] else: # line isn't continued line = tobecontinued + line tobecontinued = "" if line.lstrip()[0] == "#": # line is a comment self.linerunners.append( CommentLine(self, srcline, lineno, line.rstrip())) lineno += 1 pausenext = False else: # not a comment try: words = line.split(None, 1) # look for keyword except: words = None if words and words[0] == 'pause': self.linerunners.append( PauseLine(self, srcline, lineno, eval(words[1]))) lineno += 1 pausenext = False elif words and words[0] == "checkpoint": if self.checkpoints: self.linerunners.append( CheckPointLine(self, srcline, lineno, words[1].rstrip())) lineno += 1 pausenext = False elif words and words[0] == "postpone": self.linerunners.append( PostponeLine(self, srcline, lineno, words[1])) lineno += 1 elif logutils.recording( ) and words and words[0] == "assert": # When rerecording, don't actually run the # tests that may have been inserted in the # log file. self.linerunners.append( CommentLine(self, srcline, lineno, line.rstrip())) lineno += 1 pausenext = False else: # not a special line if pausenext and replaydelay > 0: self.linerunners.append( PauseLine(self, srcline, lineno, replaydelay)) lineno += 1 self.linerunners.append( PerformLine(self, srcline, lineno, line.rstrip())) lineno += 1 pausenext = True srcline += 1 file.close() GUILogPlayer.current = self self.aborted = False
def OutPut(args): print 'Hello, %s' % args def main(argv): try: opts, args = getopt.getopt(argv[1:], 'hvp:', ['path=']) except getopt.GetoptError, err: print str(err) Usage() sys.exit(2) if len(opts) == 0: if len(args): core.start(args[0]) else: print "scanning [options] [param]" for o, a in opts: if o in ('-h', '--help'): Usage() sys.exit(1) elif o in ('-v', '--version'): Version() sys.exit(0) elif o in ('-p', ): core.start(a) sys.exit(0) else: Usage() sys.exit(3)
import core as co co.start()
def play(game): return game, start(game)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import core import plugins core.start()
from core import start start()
#coding:utf-8 import os import sys import signal import path import core signal.signal(signal.SIGTERM, lambda signo, frame: asyncio.get_event_loop().stop()) if __name__ == '__main__': core.load_biz_dir(path._BIZ_PATH) core.start(host='127.0.0.1', port=7788)