def action_distribute(action, hosts, options): try: action = action.split('.') if len(action) != 2: raise ImportError model_name = action[0] func_name = action[1] # print(model_name, func_name, options) model_obj = __import__("module.%s" %model_name) model_obj = getattr(model_obj, model_name) func = getattr(model_obj, func_name) # print(model_obj, func) freeze_support() pool = Pool(conf.MULT_NUM) # 定义进程池子 for host in hosts: pool.apply_async(func = func, args = (host ,options, ), callback = callback ) pool.close() pool.join() except ImportError as e: error_msg = 'Module is not exit!' callback('error|%s' %error_msg) print(error_msg) exit(1) except AttributeError as e: error_msg = 'Function is not exit!' callback('error|%s' %error_msg) print(error_msg) exit(1)
def Main(): """The main function.""" multiprocessing.freeze_support() input_reader = cli_tools.StdinInputReader() tool = PsortTool(input_reader=input_reader) if not tool.ParseArguments(): return False have_list_option = False if tool.list_analysis_plugins: tool.ListAnalysisPlugins() have_list_option = True if tool.list_output_modules: tool.ListOutputModules() have_list_option = True if tool.list_language_identifiers: tool.ListLanguageIdentifiers() have_list_option = True if tool.list_timezones: tool.ListTimeZones() have_list_option = True if have_list_option: return True tool.ProcessStorage() return True
def loadWig(filename, smooth = True, strand = '+'): freeze_support() lines, count = readWigFile( filename ) outQ = Queue() wig = {} print "loading wig --------------" NUM_PROCESSES = 3 if not smooth: NUM_PROCESSES = 4 processID = 1 processes = [] offset = 5 for i in range( NUM_PROCESSES ): processes.append(Process( target = processChrom, args = ( lines, outQ, processID, offset, smooth, strand ) )) processes[-1].start() processID += 1 for i in range( count ): temp = outQ.get() print 'storing ', temp[0], ' ', type(temp[0]), ' ', temp[1].shape if temp[0] in wig: wig[temp[0]] = np.concatenate((wig[temp[0]], temp[1]), axis=0) else: wig[ temp[0] ] = temp[1] for i in range( NUM_PROCESSES ): lines.put( "STOP" ) for i in range( NUM_PROCESSES ): processes[i].join() print 'Done loading ', filename return wig
def run_cli(): from multiprocessing import freeze_support freeze_support() setup_logging() # Use default matplotlib backend on mac/linux, but wx on windows. # The problem on mac is that the wx backend requires pythonw. On windows # we are sure to wx since it is the shipped with the app. setup_mpl(backend='WXAgg' if os.name == 'nt' else None) setup_sasmodels() if len(sys.argv) == 1 or sys.argv[1] == '-i': # Run sasview as an interactive python interpreter try: from IPython import start_ipython sys.argv = ["ipython", "--pylab"] sys.exit(start_ipython()) except ImportError: import code code.interact(local={'exit': sys.exit}) elif sys.argv[1] == '-c': exec(sys.argv[2]) else: thing_to_run = sys.argv[1] sys.argv = sys.argv[1:] import runpy if os.path.exists(thing_to_run): runpy.run_path(thing_to_run, run_name="__main__") else: runpy.run_module(thing_to_run, run_name="__main__")
def main(): mp.freeze_support() appsettings = AppSettings() settings = ConvertSettings(appsettings.convertfile) app = wx.App(False) frame = MainWindow(None, appsettings, settings) app.MainLoop()
def ServiceMain(self): multiprocessing.freeze_support() win32api.SetConsoleCtrlHandler(self.ctrlHandler, True) parser=argparse.ArgumentParser(self._svc_display_name_, epilog=self.epilog, fromfile_prefix_chars="@") customInstallOptions="" for k,v in self.options.iteritems(): customInstallOptions+=k[1:]+":" parser.add_argument(k, type=str, default=v.get("default", None),help=v.get("help", None)) parser.add_argument("--username", type=str, default=None, help="User name") parser.add_argument("--password", type=str, default=None, help="Password") parser.add_argument("--startup", type=str, default="manual", help="Startup type (auto, manual, disabled)") subparsers=parser.add_subparsers(help="Subcommands") parserInstall=subparsers.add_parser("install", help="Install Service") parserUninstall=subparsers.add_parser("remove", help="Remove Service") parserConfig=subparsers.add_parser("update", help="Update Service") parserDebug=subparsers.add_parser("debug", help="Debug") parserStart=subparsers.add_parser("start", help="Start Service") parserStop=subparsers.add_parser("stop", help="Stop Service") parserRestart=subparsers.add_parser("restart", help="Restart Service") self.__name__=self.__class__.__name__ win32serviceutil.HandleCommandLine(self,customInstallOptions=customInstallOptions, customOptionHandler=self.customOptionHandler)
def MPRunner_actor(pipe,filename): multiprocessing.freeze_support() is_success = False old_stdin = sys.stdin old_stdout = sys.stdout old_stderr = sys.stderr tmpfilename = tempfile.mktemp()+".n" res_std_out = u"" old_exit = sys.exit sys.exit = lambda x: 0 try: sys.stdout = codecs.open(tmpfilename,"w","utf-8") sys.stderr = sys.stdout executer = ezhil.EzhilFileExecuter(filename,debug=False,redirectop=False,TIMEOUT=3,encoding="utf-8",doprofile=False,safe_mode=True) executer.run() is_success = True except Exception as e: print(u" '{0}':\n{1}'".format(filename, unicode(e))) finally: print(u"######- நிரல் இயக்கி முடிந்தது-######") sys.exit = old_exit sys.stdout.flush() sys.stdout.close() with codecs.open(tmpfilename,u"r",u"utf-8") as fp: res_std_out = fp.read() sys.stdout = old_stdout sys.stderr = old_stderr sys.stdin = old_stdin #print(pipe) #print("sending data back to source via pipe") pipe.send([ res_std_out,is_success] ) pipe.close()
def MPRunner_actor(pipe,filename): multiprocessing.freeze_support() GObject.threads_init() is_success = False ezhil.EzhilCustomFunction.set(GtkStaticWindow.dummy_input) old_stdin = sys.stdin old_stdout = sys.stdout old_stderr = sys.stderr tmpfilename = tempfile.mktemp()+".n" res_std_out = u"" old_exit = sys.exit sys.exit = lambda x: 0 try: sys.stdout = codecs.open(tmpfilename,"w","utf-8") sys.stderr = sys.stdout executer = ezhil.EzhilFileExecuter(filename) executer.run() is_success = True except Exception as e: print(u" '{0}':\n{1}'".format(filename, unicode(e))) finally: print(u"######- நிரல் இயக்கி முடிந்தது-######") sys.exit = old_exit sys.stdout.flush() sys.stdout.close() with codecs.open(tmpfilename,u"r",u"utf-8") as fp: res_std_out = fp.read() sys.stdout = old_stdout sys.stderr = old_stderr sys.stdin = old_stdin #print(pipe) #print("sending data back to source via pipe") pipe.send([ res_std_out,is_success] ) pipe.close()
def startServer(): freeze_support() print('MagneticPendulum -Cluster/Server') print('--------------------------------------------') print('Image resolution: {0}x{0} Output: {1}'.format(Parameter.RESOLUTION, Parameter.IMG_NAME)) print('============================================') print('Now waiting to have some working clients.') import Simulation manager = ClusterQueueManager() data = [] coordinates = manager.getCoordinates() values = manager.getValues() im= Image.new('RGB', (Parameter.RESOLUTION, Parameter.RESOLUTION)) pixel = [] + [0]*(Parameter.RESOLUTION**2) Simulation.createAllCoordinates(coordinates, data) start = time.time() manager.start() while not coordinates.empty(): while manager.getRunningClients() > 0: if not values.empty(): Simulation.drawImage(im, data, pixel, values) time.sleep(Parameter.REPAINT) time.sleep(.5) print("Coordinates are now completely distributed.") while manager.getRunningClients() > 0: time.sleep(Parameter.REPAINT) print('Waiting for {0} clients to be done'.format(manager.getRunningClients())) Simulation.drawImage(im, data, pixel, values) print('Image succeeded. Time consumed: {0:.2f}s'.format((time.time() - start))) print('Exiting...') sys.exit(0)
def create_zoomtig(out_dir, num_levels, images, PROCESSES): multiprocessing.freeze_support() #pool = multiprocessing.Pool(PROCESSES) for level in range(num_levels, -1, -1): tile_dir = out_dir + str(level) + "/" if not os.path.exists(tile_dir): os.mkdir(tile_dir) last_col = 0 c = 0 col_offsets = [] last_col = 0 for image_name in images: img = Image.open(image_name + ".png") image_width, image_height = img.size num_cols = int(math.ceil(float(image_width) / TILE_SIZE)) col_offsets.append(last_col) last_col += num_cols TASKS = [] for idx, image_name in enumerate(images): #TASKS.append((tile_image, (tile_dir, image_name, col_offsets[idx]))) tile_image(tile_dir, image_name, col_offsets[idx]) #pool.map_async(calculatestar, TASKS).get(9999999) #for idx, image_name in enumerate(images): # tile_image(tile_dir, image_name, col_offsets[idx]) resize_images(images) images = merge_images(images, out_dir)
def run(): argc = len(sys.argv) if argc != 4 and argc != 5: printUsage() return if argc == 4: sys.argv.append("0") [pyFile, op, srcDir, dstDir, num] = sys.argv try: num = long(num) freeze_support() if op == "file": mergeObjectFile(srcDir, dstDir, num) elif op == "result": mergeResult(srcDir, dstDir) else: print "merge type should be file or result!" printUsage() return except Exception, e: print e #printUsage() return
def run(): """start GUI The function will create the main thread for Qt Gui. It will set the language to system locals an start an instance of the main window. """ def install_translator(filename, folder, app): locale = QtCore.QLocale.system().name() translator = QtCore.QTranslator() if translator.load(filename.format(locale), folder): app.installTranslator(translator) return translator args = handle_cli_args() sys.excepthook = handle_exception multiprocessing.freeze_support() app = QtWidgets.QApplication(sys.argv) # set translation language folder = godirec.resource_filename("godirec", 'data/language') translator1 = install_translator("godirec_{}", folder, app) if hasattr(sys, "frozen"): qt_folder = godirec.resource_filename("godirec", "translations") else: qt_folder = QLibraryInfo.location(QLibraryInfo.TranslationsPath) translator2 = install_translator("qtbase_{}", qt_folder, app) window = main.GodiRecWindow() window.show() if "gdr_file" in args: window.setupProject(args["gdr_file"], False) else: audio.WaveConverter.confirm_converter_backend() if window.isNewProjectCreatedDialog(): window.createNewProject() sys.exit(app.exec_())
def setup_and_run(): # import only on run # Dont import always this, setup.py will fail from ninja_ide import core from multiprocessing import freeze_support #from PyQt4.QtCore import QDir import os #import shutil ''' HOME_DIR = QDir.toNativeSeparators(QDir.homePath()) if os.path.exists(os.path.join(HOME_DIR, '.alexa_ide')) is False: script_path = os.path.realpath(__file__) #script_path = os.path.abspath(__file__) script_path = os.path.dirname(script_path) #alexa_user_dir = QDir.toNativeSeparators("../") #alexa_user_dir = os.path.join(alexa_user_dir, script_path) alexa_user_filesdir = os.path.join(os.path.dirname(script_path), "user_files" + os.sep + "alexa_ide") #print alexa_user_filesdir shutil.copytree(alexa_user_filesdir, os.path.join(HOME_DIR, ".alexa_ide")) ''' # Used to support multiprocessing on windows packages freeze_support() # Run NINJA-IDE core.run_ninja()
def main(): """Entry point of the Bajoo client.""" multiprocessing.freeze_support() # Start log and load config with log.Context(): logger = logging.getLogger(__name__) cwd = to_unicode(os.getcwd(), in_enc=sys.getfilesystemencoding()) logger.debug('Current working directory is : "%s"', cwd) config.load() # config must be loaded before network log.set_debug_mode(config.get('debug_mode')) log.set_logs_level(config.get('log_levels')) # Set the lang from the config file if available lang = config.get('lang') if lang is not None: set_lang(lang) with network.Context(): with encryption.Context(): app = BajooApp() app.run()
def main_function(): import sys, os import multiprocessing multiprocessing.freeze_support() #if ( len(sys.argv) > 1): # t=sys.argv[1] #else: print "Working directory : %(n)s" % {"n": os.getcwd()} #t=raw_input("Enter the name of parameter file (*.yaml) : ") #t=None parameters=ReadParameters() if not os.path.exists(parameters.projectdirectory): print "There is no directory named: "+parameters.projectdirectory+" under "+ prjroot+os.sep + " directory.\n" print "Please create one using the template (myproject) provided.\n" sys.exit() if not os.path.exists(parameters.projectdirectory+os.sep+parameters.resultsdirectory): os.makedirs(parameters.projectdirectory+os.sep+parameters.resultsdirectory) if not os.path.exists(parameters.projectdirectory+os.sep+parameters.datadirectory): print "Hell! there's no directory named : " + parameters.projectdirectory+os.sep+parameters.datadirectory +"\n" print "I quit. Check param.yaml file and try again" sys.exit() import cProfile, pstats app = QtGui.QApplication(sys.argv) swmmea=SwmmEA() swmmea.setParams(parameters=parameters, display=True) swmmea.start() app.exec_()
def test(): QueueManager.register('get_task_queue', callable=return_task_queue) QueueManager.register('get_result_queue', callable=return_result_queue) #绑定端口5000,设置验证码'abc' manager=QueueManager(address=('127.0.0.2',5007),authkey=b'abc') #启动Queue manager.start() #获得通过网络访问的queue对象: task=manager.get_task_queue() result=manager.get_result_queue() #放几个任务进去 for i in range(10): n=random.randint(0,10000) print('Put task %d...' % n) task.put(n) #从result对读取结果 print('Try get results...') for i in range(10): r=result.get(timeout=10) print('Result: %s' % r ) #关闭 manager.shutdown() print('master exit.') if __name__='__main__': freeze_support() test()
def main(): if iswindows: if '--multiprocessing-fork' in sys.argv: # We are using the multiprocessing module on windows to launch a # worker process from multiprocessing import freeze_support freeze_support() return 0 # Close open file descriptors inherited from parent # On Unix this is done by the subprocess module os.closerange(3, 256) if isosx and 'CALIBRE_WORKER_ADDRESS' not in os.environ and 'CALIBRE_SIMPLE_WORKER' not in os.environ and '--pipe-worker' not in sys.argv: # On some OS X computers launchd apparently tries to # launch the last run process from the bundle # so launch the gui as usual from calibre.gui2.main import main as gui_main return gui_main(['calibre']) csw = os.environ.get('CALIBRE_SIMPLE_WORKER', None) if csw: mod, _, func = csw.partition(':') mod = importlib.import_module(mod) func = getattr(mod, func) func() return if '--pipe-worker' in sys.argv: try: exec (sys.argv[-1]) except Exception: print('Failed to run pipe worker with command:', sys.argv[-1]) raise return address = cPickle.loads(unhexlify(os.environ['CALIBRE_WORKER_ADDRESS'])) key = unhexlify(os.environ['CALIBRE_WORKER_KEY']) resultf = unhexlify(os.environ['CALIBRE_WORKER_RESULT']).decode('utf-8') with closing(Client(address, authkey=key)) as conn: name, args, kwargs, desc = eintr_retry_call(conn.recv) if desc: prints(desc) sys.stdout.flush() func, notification = get_func(name) notifier = Progress(conn) if notification: kwargs[notification] = notifier notifier.start() result = func(*args, **kwargs) if result is not None and os.path.exists(os.path.dirname(resultf)): cPickle.dump(result, open(resultf, 'wb'), -1) notifier.queue.put(None) try: sys.stdout.flush() except EnvironmentError: pass # Happens sometimes on OS X for GUI processes (EPIPE) try: sys.stderr.flush() except EnvironmentError: pass # Happens sometimes on OS X for GUI processes (EPIPE) return 0
def run(): freeze_support() global opMap if len(sys.argv) < 3: showHelp() return Pebble.hdfsRoot = sys.argv[1] opStr = sys.argv[2] sys.argv = sys.argv[3:] if not opMap.has_key(opStr): showHelp() return opInfo = opMap[opStr] #print len(sys.argv),sys.argv #print opInfo["argNum"] if opInfo["argNum"] != len(sys.argv): showHelp(opStr) return startFunc = opInfo["startFunc"] startFunc()
def do_serve(): freeze_support() setrundir() xml_serve('start')
def show(self): if not self.proc_started: multiprocessing.freeze_support() self.process.start() self.proc_started = True else: self.showWindow()
def main(): """ Entry point for GNS3 server """ if sys.platform.startswith("win"): # necessary on Windows to use freezing software multiprocessing.freeze_support() current_year = datetime.date.today().year print("GNS3 server version {}".format(gns3server.__version__)) print("Copyright (c) 2007-{} GNS3 Technologies Inc.".format(current_year)) # we only support Python 2 version >= 2.7 and Python 3 version >= 3.3 if sys.version_info < (2, 7): raise RuntimeError("Python 2.7 or higher is required") elif sys.version_info[0] == 3 and sys.version_info < (3, 3): raise RuntimeError("Python 3.3 or higher is required") try: tornado.options.parse_command_line() except (tornado.options.Error, ValueError): tornado.options.print_help() raise SystemExit # FIXME: log everything for now (excepting DEBUG) logging.basicConfig(level=logging.INFO) from tornado.options import options server = gns3server.Server(options.host, options.port, ipc=options.ipc) server.load_modules() server.run()
def searchExecute(self): print 'searchExecute' input = self.input + self._testMethodName + ".csv" target = self.target + self._testMethodName cmd = "python ../src/jbmst.py " + input + " " + target freeze_support() p = subprocess.Popen(cmd, stdout=subprocess.PIPE,shell=True) result = p.stdout.read() print result if result != "": self.rslt = result rsltList = result.split(',') if "," in result: self.rslt_number = rsltList[0].strip() self.rslt_filepath = self.getNormpath(rsltList[1].strip()) self.rslt_hit = rsltList[2].strip() steps = rsltList[3].strip() if(steps != ""): if(steps == 1): self.rslt_steps = [1] else: self.rslt_steps = steps.split(' ') else: self.rslt_steps = None
def main(): freeze_support() logging.basicConfig(format='%(levelname)s, PID: %(process)d, %(asctime)s:\t%(message)s', level=logging.INFO) config = json.load(open('server_config.json')) orchestrator = Orchestrator(config) orchestrator.retrieve_file_data() orchestrator.init_server() orchestrator.server.generate_data() manager = multiprocessing.Manager() received_data = manager.dict() pp = ProcessParallel() pp.add_task(orchestrator.server.run, (received_data,)) pp.add_task(orchestrator.send_data_to_server, ()) pp.start_all() starts = time.time() pp.join_all() orchestrator.locate(received_data) ends = time.time() logging.info('%.15f passed for SEND/RECEIVE/CALCULATE.', ends - starts) orchestrator.get_results()
def __call__(self, func, args=(), kwargs={}, timeout=1, default=None, raise_error=None): multiprocessing.freeze_support() if self.using_dill: payloads = dill.dumps((func, args, kwargs)) else: payloads = func, args, kwargs queue = multiprocessing.Queue() process = multiprocessing.Process(target = self.__class__.container, args = (queue, payloads, self.using_dill)) result = default raise_error = raise_error if isinstance(raise_error, bool) else self.raise_error try: process.start() result = queue.get(block=True, timeout=timeout) except Empty: process.terminate() if hasattr(func, '__name__'): message = 'Method:{func_name}-{func_args}'.format(func_name=func.__name__, func_args=signature(func)) else: message = 'Method:{func_obj}'.format(func_obj=func) result = TimeoutError('{message}, Timeout:{time}\'s'.format(message=message, time=timeout)) finally: queue.close() process.join() if isinstance(result, Exception): if raise_error: raise result # pylint: disable=E0702 return default return result
def run(self): if self.debug==False: freeze_support() Process(target=self.f).start() else: self.f()
def startout(seconds,name): freeze_support() print name+':pid '+str(os.getpid())+' is created' startTime=time.time() while (time.time()-startTime)<seconds: time.sleep(1) winsound.PlaySound('SystemQuestion', winsound.SND_ALIAS) print name+' end'
def freeze_support(): if main_is_frozen(): sys.path.insert(0, '') try: import multiprocessing multiprocessing.freeze_support() except ImportError: pass
def main(): # logging.basicConfig(level=logging.DEBUG) AppBase().add_default_module_path() from djangoautoconf import DjangoAutoConf DjangoAutoConf.set_settings_env() # The following is required for freeze app for django freeze_support() DjangoAutoConf.exe()
def main(): # Fixes issues with multiprocessing with cx_freeze on windows freeze_support() """ Start doit. """ import sys from doit.doit_cmd import DoitMain sys.exit(DoitMain().run(sys.argv[1:]))
def __init__( self, skip_background=False ): self.db = Db self.users = {} self.threads = {} self.sched = Scheduler() self.skip_background = skip_background multiprocessing.freeze_support()
if i%prog_dec==0: print ('.',end='') # progress indicator x = nodes.values()[i]['metadata']['node_coordinates']['x'] y = nodes.values()[i]['metadata']['node_coordinates']['y'] z = nodes.values()[i]['metadata']['node_coordinates']['z'] r = nodes.values()[i]['metadata']['node_squared_radius'] # in some json files instead of ['node_squared_radius'] use ['node_radius'] # then comment the below line: data[:,3] = np.sqrt(data[:,3]) return x,y,z,r; def worker_get_data(start,end,nodes,prog_dec): return np.asarray(map(lambda i: get_data(nodes,i,prog_dec), range(start,end))) if __name__ == '__main__': mp.freeze_support() #required for pyinstaller cores=mp.cpu_count()-1; cores = max (1,cores) #set number of cores #general initialization stuff space=' '; slash='/'; if sys.platform=="win32": slash='\\' # not really needed, but looks nicer ;) Program_name = os.path.basename(sys.argv[0]); if Program_name.find('.')>0: Program_name = Program_name[:Program_name.find('.')] python_version=str(sys.version_info[0])+'.'+str(sys.version_info[1])+'.'+str(sys.version_info[2]) # sys.platform = [linux2, win32, cygwin, darwin, os2, os2emx, riscos, atheos, freebsd7, freebsd8] if sys.platform=="win32": os.system("title "+Program_name) #TK initialization TKwindows = tk.Tk(); TKwindows.withdraw() #hiding tkinter window TKwindows.update() # the following tries to disable showing hidden files/folders under linux
R is the total number of events meeting the criterion: n is the total number of events in this specific reference gene-set: r is the number of events meeting the criterion in the examined reference gene-set: """ N = float(N) ### This bring all other values into float space z = (r - n * (R / N)) / math.sqrt(n * (R / N) * (1 - (R / N)) * (1 - ((n - 1) / (N - 1)))) return z if __name__ == '__main__': """ This script iterates the LineageProfiler algorithm (correlation based classification method) to identify sample types relative two one of two references given one or more gene models.""" try: import multiprocessing as mlp mlp.freeze_support() except Exception: mpl = None ################ Default Variables ################ species = 'Hs' platform = "RNASeq" useMulti = False output_dir = None eventDir = None PSI_dir = None ################ Comand-line arguments ################ if len( sys.argv[1:] ) <= 1: ### Indicates that there are insufficient number of command-line arguments
analysis_type) elif (analysis_type == "Abundance" and not self.user_settings["Use Abundance"]) or ( analysis_type == "neutromer spacing" and not self.user_settings["Use neutromer spacing"]): print "{0} graphs was not possible due to user settings.".format( analysis_type) else: QtGui.QMessageBox.information( self, "Error", "Graphs for {0} could not be completed due to lack of data" .format(analysis_type)) QtGui.QMessageBox.information(self, "Done", "Your Analysis is Complete") self.Update_User.setText("Waiting for Command") app.processEvents() def Magic_Button(self): import MIDA_Calculator_vrs4 as mc message = mc.Recalculate(self.user_settings, self.static_filters) QtGui.QMessageBox.information(self, "Done", message) if __name__ == '__main__': import sys mp.freeze_support() app = QtGui.QApplication(sys.argv) cheese = InteractWithUser(None) cheese.show() app.exec_()
if data[0] != _player_: pipe[_player_] = data # checking if viable data is available to be sent if pipe[data[0]]: udp.sendto( dumps(pipe[data[0]] + [wall_pos]) + b"||||", address, ) pipe[data[0]] = [] else: udp.sendto(dumps([":server:", wall_pos]) + b"||||", address) if __name__ == "__main__": multiprocessing.freeze_support() host = "127.0.0.1" port = 9000 udp_port = 9002 team = [] sock = socket.socket() try: sock.bind((host, port)) except OSError: print(f"Port {port} is busy") sock.listen(1) print("Backend Active...") player_entry()
def Load(self): #t0 = time.clock() #self.GL.__del__() fn = ("d:\\JOBS\\modoPipeline\\OUT\\tl211_0010.0000.exr") exrimage = OpenEXR.InputFile(fn) dw = exrimage.header()['dataWindow'] (width,height) = (dw.max.x - dw.min.x + 1, dw.max.y - dw.min.y + 1) #multiprocessing.cpu_count() multiprocessing.freeze_support() # this shows up 2 for my core2duo e9300 parent_conn1, child_conn1 = multiprocessing.Pipe(False) parent_conn2, child_conn2 = multiprocessing.Pipe(False) parent_conn3, child_conn3 = multiprocessing.Pipe(False) parent_conn4, child_conn4 = multiprocessing.Pipe(False) #texArr = numpy.empty((150,1920,1080,3),dtype=float) #so now if we iterate this like that start = 1 end = 50 self.GL.clearTexBuffer(start,end) texArr = [] self.mainGui.ui.firstFrameLineEdit.setText(str(start)) self.mainGui.ui.lastFramelineEdit.setText(str(end)) self.mainGui.ui.TimeLineSlider.setRange(start, end) chunk = (end-start+1)/4 s0 ="" e0 ="" imglist = numpy.arange(end-start+1) + start #print imglist startFrames = imglist[::chunk] data = "mich" frameRange = (end-start)/multiprocessing.cpu_count() t0 = time.clock() multiprocessing.freeze_support() #print "arf" #p1 = run("mich" ,str(start),str(startFrames[0]+chunk-1)) p1 = openExrSeq("mich" ,str(start),str(startFrames[0]+chunk-1), child_conn1,width,height) p2 = openExrSeq("mich2",str(startFrames[1]),str(startFrames[1]+chunk-1), child_conn2,width,height) p3 = openExrSeq("mich3",str(startFrames[2]),str(startFrames[2]+chunk-1), child_conn3,width,height) p4 = openExrSeq("mich4",str(startFrames[3]),str(end), child_conn4,width,height) #p3 = openExrSeq("mich4") #p4 = openExrSeq("mich3") p1.start() p2.start() p3.start() p4.start() #print p1.instances.shape texArr1 = parent_conn1.recv() texArr2 = parent_conn2.recv() texArr3 = parent_conn3.recv() texArr4 = parent_conn4.recv() #q.get() p1.join() p2.join() p3.join() p4.join() #p1.instances[1] texArr = numpy.concatenate((texArr1,texArr2)) texArr1 = [] texArr2 = [] texArr = numpy.concatenate((texArr,texArr3)) texArr3 = [] texArr = numpy.concatenate((texArr,texArr4)) texArr4 = [] #self.GL.instances = [] self.loadTextures(texArr,start,end) self.GL.update() texArr = []
def is_running(self): glow_switch = False chams_switch = False chams_reset_switch = False aimbot_switch = False rcs_switch = False triggerbot_switch = False rapidfire_switch = False silent_aim_switch = False crosshair_switch = False thirdperson_switch = False fov_switch = False fov_reset_switch = False hitsound_switch = False soundesp_switch = False noflash_switch = False noflash_reset_switch = False bhop_rage_switch = False bhop_legit_switch = False show_money_switch = False show_money_reset_switch = False radar_switch = False radar_reset_switch = False fake_lag_switch = False multiprocessing.freeze_support() t_skinchanger = Process(target=skinchanger_func) t_skinchanger.start() multiprocessing.freeze_support() t_knifechanger = Process(target=knifechanger_func) t_knifechanger.start() try: pm = pymem.Pymem("csgo.exe") except: MessageBox = ctypes.windll.user32.MessageBoxW MessageBox(None, 'Could not find the csgo.exe process !', 'Error', 16) return engine = pymem.process.module_from_name(pm.process_handle, "engine.dll").lpBaseOfDll while True: try: time.sleep(0.3) engine_state = pm.read_int(engine + dwClientState) if pm.read_int(engine_state + dwClientState_State ) != 6 and t_knifechanger.is_alive( ) and t_skinchanger.is_alive(): t_skinchanger.terminate() t_knifechanger.terminate() elif pm.read_int(engine_state + dwClientState_State ) == 6 and not t_knifechanger.is_alive( ) and not t_skinchanger.is_alive(): multiprocessing.freeze_support() t_skinchanger = Process(target=skinchanger_func) t_skinchanger.start() multiprocessing.freeze_support() t_knifechanger = Process(target=knifechanger_func) t_knifechanger.start() read() if check.glow_active and glow_switch == False: multiprocessing.freeze_support() t_glow = Process(target=glow) t_glow.start() glow_switch = True elif not check.glow_active and glow_switch == True: t_glow.terminate() glow_switch = False if check.chams_active and chams_switch == False: if chams_reset_switch == True: t_chams_reset.terminate() chams_reset_switch = False multiprocessing.freeze_support() t_chams = Process(target=chams) t_chams.start() chams_switch = True elif not check.chams_active and chams_switch == True: t_chams.terminate() multiprocessing.freeze_support() t_chams_reset = Process(target=chams_reset) t_chams_reset.start() chams_reset_switch = True chams_switch = False if check.aimbot and aimbot_switch == False: multiprocessing.freeze_support() t_aimbot = Process(target=aimbot) t_aimbot.start() aimbot_switch = True elif not check.aimbot and aimbot_switch == True: t_aimbot.terminate() aimbot_switch = False if check.rcs and rcs_switch == False: multiprocessing.freeze_support() t_rcs = Process(target=rcs) t_rcs.start() rcs_switch = True elif not check.rcs and rcs_switch == True: t_rcs.terminate() rcs_switch = False if check.triggerbot and triggerbot_switch == False: multiprocessing.freeze_support() t_triggerbot = Process(target=triggerbot) t_triggerbot.start() triggerbot_switch = True elif not check.triggerbot and triggerbot_switch == True: t_triggerbot.terminate() triggerbot_switch = False if check.rapid_fire and rapidfire_switch == False: multiprocessing.freeze_support() t_rapid_fire = Process(target=rapidfire) t_rapid_fire.start() rapidfire_switch = True elif not check.rapid_fire and rapidfire_switch == True: t_rapid_fire.terminate() rapidfire_switch = False if check.silent_aim and silent_aim_switch == False: multiprocessing.freeze_support() t_silent_aim = Process(target=silent) t_silent_aim.start() silent_aim_switch = True elif not check.silent_aim and silent_aim_switch == True: t_silent_aim.terminate() silent_aim_switch = False if check.crosshair and crosshair_switch == False: multiprocessing.freeze_support() t_crosshair = Process(target=crosshair_hack) t_crosshair.start() crosshair_switch = True elif not check.crosshair and crosshair_switch == True: t_crosshair.terminate() crosshair_switch = False if check.third_person and thirdperson_switch == False: multiprocessing.freeze_support() t_thirdperson = Process(target=thirdperson) t_thirdperson.start() thirdperson_switch = True elif not check.third_person and thirdperson_switch == True: t_thirdperson.terminate() thirdperson_switch = False if check.fov and fov_switch == False: if fov_reset_switch == True: t_fov_reset.terminate() fov_reset_switch = False multiprocessing.freeze_support() t_fov = Process(target=fov) t_fov.start() fov_switch = True elif not check.fov and fov_switch == True: t_fov.terminate() multiprocessing.freeze_support() t_fov_reset = Process(target=fov_reset) t_fov_reset.start() fov_reset_switch = True fov_switch = False if check.hitsound and hitsound_switch == False: multiprocessing.freeze_support() t_hitsound = Process(target=hitsound) t_hitsound.start() hitsound_switch = True elif not check.hitsound and hitsound_switch == True: t_hitsound.terminate() hitsound_switch = False if check.sound_esp and soundesp_switch == False: multiprocessing.freeze_support() t_soundesp = Process(target=sound_esp) t_soundesp.start() soundesp_switch = True elif not check.sound_esp and soundesp_switch == True: t_soundesp.terminate() soundesp_switch = False if check.no_flash and noflash_switch == False: if noflash_reset_switch == True: t_noflash_reset.terminate() noflash_reset_switch = False multiprocessing.freeze_support() t_noflash = Process(target=noflash) t_noflash.start() noflash_switch = True elif not check.no_flash and noflash_switch == True: t_noflash.terminate() multiprocessing.freeze_support() t_noflash_reset = Process(target=noflash_reset) t_noflash_reset.start() noflash_reset_switch = True noflash_switch = False if check.bhop_rage and bhop_rage_switch == False: multiprocessing.freeze_support() t_bhop_rage = Process(target=bhop_rage) t_bhop_rage.start() bhop_rage_switch = True elif not check.bhop_rage and bhop_rage_switch == True: t_bhop_rage.terminate() bhop_rage_switch = False if check.bhop_legit and bhop_legit_switch == False: multiprocessing.freeze_support() t_bhop_legit = Process(target=bhop_legit) t_bhop_legit.start() bhop_legit_switch = True elif not check.bhop_legit and bhop_legit_switch == True: t_bhop_legit.terminate() bhop_legit_switch = False if check.show_money and show_money_switch == False: if show_money_reset_switch == True: t_show_money_reset.terminate() show_money_reset_switch = False multiprocessing.freeze_support() t_show_money = Process(target=money) t_show_money.start() show_money_switch = True elif not check.show_money and show_money_switch == True: t_show_money.terminate() multiprocessing.freeze_support() t_show_money_reset = Process(target=money_reset) t_show_money_reset.start() show_money_reset_switch = True show_money_switch = False if check.radar and radar_switch == False: if radar_reset_switch == True: t_radar_reset.terminate() radar_reset_switch = False multiprocessing.freeze_support() t_radar = Process(target=radar) t_radar.start() radar_switch = True elif not check.radar and radar_switch == True: t_radar.terminate() multiprocessing.freeze_support() t_radar_reset = Process(target=radar_reset) t_radar_reset.start() radar_reset_switch = True radar_switch = False if check.fake_lag and fake_lag_switch == False: multiprocessing.freeze_support() t_fake_lag = Process(target=fake_lag) t_fake_lag.start() fake_lag_switch = True elif not check.fake_lag and fake_lag_switch == True: t_fake_lag.terminate() fake_lag_switch = False except Exception as e: print(e)
dict_doc.filter_extremes(no_below=2,no_above=.1,keep_n=100000) bow_corpus = [dict_doc.doc2bow(x) for x in process_doc] # print(bow_corpus) # lda_model = LdaMulticore(bow_corpus,num_topics=8,id2word=dict_doc,workers=2,passes=8) # lda_model = LdaMulticore(bow_corpus) # print(lda_model) #for unseen document unseen_doc = "Javascript add row and calculate multiple rows from html" bow_vec = dict_doc.doc2bow(preprocess(unseen_doc)) # print(bow_vec) if __name__ == '__main__': multiprocessing.freeze_support() #for windows system lda_model = LdaMulticore(corpus=bow_corpus, id2word=dict_doc, num_topics=4) # print(lda) for idx, topic in lda_model.print_topics(-1): print("Topic: {} \nWords: {}".format(idx, topic)) print("\n") # print("*******************************************") # for index, score in sorted(lda_model[bow_vec], key=lambda tup: -1 * tup[1]): # print("Score: {}\t Topic: {}".format(score, lda_model.print_topic(index, 5))) print((lda_model[bow_vec])) output = lda_model[bow_vec] b = sorted(output,key = lambda x:x[1],reverse = True) print(b[0][0])
nodes_block_submit(block_send) else: print("Invalid signature") tries = 0 except Exception as e: print(e) time.sleep(0.1) if debug_conf == 1: raise else: pass if __name__ == '__main__': freeze_support() # must be this line, dont move ahead (key, private_key_readable, public_key_readable, public_key_hashed, address) = keys.read() connected = 0 while connected == 0: try: s_node = socks.socksocket() if tor_conf == 1: s_node.setproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9050) s_node.connect((node_ip_conf, int(port))) print("Connected") connected = 1 s_node.close() except Exception as e:
curve[3]) - bezier(linear(i - 1, 0, wst, 0, 1), curve[0], curve[1], curve[2], curve[3])) curWeight.append(sum) wsum += sum for i in range(len(curWeight)): curWeight[i] /= wsum for i in range(1, len(curWeight)): curWeight[i] += curWeight[i - 1] curWeight.insert(0, 0) curWeight[-1] = 1 print("Weight process finished.") #print(points) out = [] print("Initializing...") multiprocessing.freeze_support() #并行计算开始 prjCur = multiprocessing.Value('i', 0) pool = multiprocessing.Pool(initializer=initParam, initargs=(points, curWeight, prjCur)) print("Initializing finished.") print("Main calculation start.") out = pool.map_async(mainCalculation, range(start, end + 1)) division = 50 while True: percentage = prjCur.value / prjNum nump = round(percentage * division) print("[{}{}] {:.0%}".format("=" * nump, " " * (division - nump), percentage), end='\r', flush=True) if prjCur.value >= prjNum:
def main(): freeze_support() worker = WorkerCommand() worker.execute_from_commandline()
def patched_main() -> None: maybe_install_uvloop() freeze_support() patch_click() main()
''' 返回结果队列 ''' class QueueManager(multiprocessing.managers.BaseManager): ''' 继承进程管理共享数据 ''' pass if __name__ == '__main__': url = "http://wz.sun0769.com/html/top/report.shtml" TN = 10 url_num = get_url_numbers(url) # 获取页码数,页码会变化 urllist = make_urllist(url_num) # 制作url列表 multiprocessing.freeze_support() # 1. 开启分布式支持 QueueManager.register('get_task', callable=return_task()) # 2. 注册函数给客户端调用 QueueManager.register('get_result', callable=return_result()) manager = QueueManager(address=("10.36.137.37", 8848), authkey='123456') # 3. 创建一个管理器,设置地址与密码 manager.start() task, result = manager.get_task(), manager.get_result() # 4. 任务,结果 # 5. 分发任务 for url in urllist: print('task add data', url) task.put(url) print('=' * 25 + '=' * 25)
def start(): app = QSingleApplication(sys.argv) splash = QSplashScreen( QPixmap(":/picture/resourses/start.jpg")) with open(thisPath + os.sep + 'style.qss', encoding="utf-8", errors='ignore') as f: qss_file = f.read() splash.setWindowFlags(Qt.Window) font_size = 13 if platform.system().lower() == "windows" else 15 splash.setFont(QFont('Arial', font_size)) splash.setStyleSheet(qss_file) icon = QIcon(":/picture/resourses/windowIcon.png") splash.setWindowIcon(icon) splash.show() app.processEvents() splash.showMessage("Checking if the program is already running...", Qt.AlignBottom, Qt.black) if platform.system().lower() == "windows": multiprocessing.freeze_support() # windows必须调用这个,不然会出错 # 异常调试 import cgitb sys.excepthook = cgitb.Hook(1, None, 5, sys.stderr, 'text') ##为了存路径到系统 QApplication.setApplicationName("PhyloSuite_settings") QApplication.setOrganizationName("PhyloSuite") QSettings.setDefaultFormat(QSettings.IniFormat) path_settings = QSettings() path_settings.setValue("thisPath", thisPath) os.chdir(thisPath) dialog = QDialog() dialog.setStyleSheet(qss_file) # 异常处理 def handle_exception(exc_type, exc_value, exc_traceback): rgx = re.compile(r'PermissionError.+?[\'\"](.+\.csv)[\'\"]') if issubclass(exc_type, KeyboardInterrupt): return sys.__excepthook__(exc_type, exc_value, exc_traceback) exception = str("".join(traceback.format_exception( exc_type, exc_value, exc_traceback))) print(exception) if rgx.search(exception): #忽略csv未关闭的报错 return msg = QMessageBox(dialog) msg.setIcon(QMessageBox.Critical) msg.setText( 'The program encountered an unforeseen problem, please report the bug at <a href="https://github.com/dongzhang0725/PhyloSuite/issues">https://github.com/dongzhang0725/PhyloSuite/issues</a> ' 'or send an email with the detailed traceback to [email protected]') msg.setWindowTitle("Error") msg.setDetailedText(exception) msg.setStandardButtons(QMessageBox.Ok) msg.exec_() sys.excepthook = handle_exception # 避免重复运行程序 if app.isRunning(): QMessageBox.information( dialog, "PhyloSuite", "<p style='line-height:25px; height:25px'>App is running!</p>") sys.exit(0) # 界面运行选择 splash.showMessage("Choosing workplace...", Qt.AlignBottom, Qt.black) launcher_settings = QSettings( thisPath + '/settings/launcher_settings.ini', QSettings.IniFormat) launcher_settings.setFallbacksEnabled(False) not_exe_lunch = launcher_settings.value("ifLaunch", "false") workPlace = launcher_settings.value( "workPlace", [thisPath + os.sep + "myWorkPlace"]) # 删除无效的路径 workPlace_copy = deepcopy(workPlace) for num,i in enumerate(workPlace_copy): if not os.path.exists(i): workPlace.remove(i) else: ##替换带.的路径 if re.search(r"^\.", i): workPlace[num] = os.path.abspath(i) # 如果workPlace被删干净了 if not workPlace: workPlace = [thisPath + os.sep + "myWorkPlace"] # 重新保存下路径 if len(workPlace) > 15: workPlace = workPlace[:15] # 只保留15个工作区 launcher_settings.setValue( "workPlace", workPlace) if not_exe_lunch == "true": splash.showMessage("Starting PhyloSuite...", Qt.AlignBottom, Qt.black) myMainWindow = MyMainWindow(workPlace) Factory().centerWindow(myMainWindow) myMainWindow.show() splash.finish(myMainWindow) sys.exit(app.exec_()) else: launcher = Launcher() if launcher.exec_() == QDialog.Accepted: splash.showMessage("Starting PhyloSuite...", Qt.AlignBottom, Qt.black) workPlace = launcher.WorkPlace myMainWindow = MyMainWindow(workPlace) Factory().centerWindow(myMainWindow) myMainWindow.show() splash.finish(myMainWindow) sys.exit(app.exec_())
#if callback_url is not None: # #import requests # #requests. # #callback_url return jobid @register_ibs_method @accessor_decors.default_decorator @register_api('/api/engine/query/web/', methods=['GET']) def start_web_query_all(ibs): """ REST: Method: GET URL: /api/engine/query/web/ """ jobid = ibs.job_manager.jobiface.queue_job('load_identification_query_object_worker') return jobid if __name__ == '__main__': r""" CommandLine: python -m ibeis.web.apis_engine python -m ibeis.web.apis_engine --allexamples """ import multiprocessing multiprocessing.freeze_support() # for win32 import utool as ut # NOQA ut.doctest_funcs()
def main(): freeze_support() logfile = open("makedb.log", "w") args = sys.argv if len(args) > 2: dbname = args[1] args = args[2:] #Checks to prevent overwriting if dbname + ".nal" in os.listdir(".") or dbname + ".pal" in os.listdir( "."): print("Error: a database with this name already exists") sys.exit() if "genbank" in os.listdir("."): print( "A folder named 'genbank' (which is used by MultiGeneBlast to store downloaded GenBank files) is already present in this folder.\n Overwrite? <y/n>" ) user_response = input() if user_response.upper() == "N": sys.exit(1) else: shutil.rmtree("genbank") if "WGS" in args and "wgs" in os.listdir("."): print( "A folder named 'wgs' (which is used by MultiGeneBlast to store downloaded WGS GenBank files) is already present in this folder.\n Overwrite? <y/n>" ) user_response = input() if user_response.upper() == "N": sys.exit(1) else: shutil.rmtree("wgs") else: dbname = "" args = [] get_genbank_db( dbname, args, dbtype="nucl") ##Can be commented out for testing of local parsing #Parse normal SEQ entries, descriptions parse_nseq(dbname, find_seqfiles("genbank")) if "WGS" in args: #Parse WGS entries, descriptions parse_ngnp(dbname, find_ngnpfiles("wgs")) #Combine descriptions files combine_txt_files(dbname) #Combine FASTA files combine_fasta_files(dbname) #Write txt file of names from combined FASTA file fasta_names(dbname + "_all.fasta", dbname + "_all.txt") #Create Blast database and TAR archives try: if "\n" not in open(dbname + "_all.fasta", "r").read(10000): print( "Error making BLAST database; no suitable sequences found in input." ) log("Error making BLAST database; no suitable sequences found in input.", exit=True) except: pass make_blast_db(dbname, dbname + "_all.fasta", dbtype="nucl") #Clean up clean_up(dbname, dbtype="nucl")
#name, testFolder = "WEB", Path( '/mnt/SSDs/Bibles/English translations/WEB (World English Bible)/2012-06-23 eng-web_usfm/' ) # You can put your test folder here if os.access(testFolder, os.R_OK): vPrint('Normal', debuggingThisModule, _("Scanning {} from {}…").format(name, testFolder)) fileList = USFMFilenames.USFMFilenames( testFolder).getMaximumPossibleFilenameTuples() for BBB, filename in fileList: demoFile(name, filename, testFolder, BBB) else: vPrint( 'Quiet', debuggingThisModule, f"Sorry, test folder '{testFolder}' doesn't exist on this computer." ) # end of ESFMBibleBook.fullDemo if __name__ == '__main__': from multiprocessing import freeze_support freeze_support() # Multiprocessing support for frozen Windows executables # Configure basic set-up parser = BibleOrgSysGlobals.setup(SHORT_PROGRAM_NAME, PROGRAM_VERSION, LAST_MODIFIED_DATE) BibleOrgSysGlobals.addStandardOptionsAndProcess(parser) fullDemo() BibleOrgSysGlobals.closedown(PROGRAM_NAME, PROGRAM_VERSION) # end of ESFMBibleBook.py
def main(): freeze_support() parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, description=""" repositories. By default, updates your checkouts of Swift, SourceKit, LLDB, and SwiftPM.""") parser.add_argument("--clone", help="Obtain Sources for Swift and Related Projects", action="store_true") parser.add_argument( "--clone-with-ssh", help="Obtain Sources for Swift and Related Projects via SSH", action="store_true") parser.add_argument("--skip-history", help="Skip histories when obtaining sources", action="store_true") parser.add_argument("--skip-repository", metavar="DIRECTORY", default=[], help="Skip the specified repository", dest='skip_repository_list', action="append") parser.add_argument( "--scheme", help='Use branches from the specified branch-scheme. A "branch-scheme"' ' is a list of (repo, branch) pairs.', metavar='BRANCH-SCHEME', dest='scheme') parser.add_argument('--reset-to-remote', help='Reset each branch to the remote state.', action='store_true') parser.add_argument('--clean', help='Clean unrelated files from each repository.', action='store_true') parser.add_argument("--config", default=os.path.join(SCRIPT_DIR, "update-checkout-config.json"), help="Configuration file to use") parser.add_argument( "--github-comment", help="""Check out related pull requests referenced in the given free-form GitHub-style comment.""", metavar='GITHUB-COMMENT', dest='github_comment') parser.add_argument( '--dump-hashes', action='store_true', help='Dump the git hashes of all repositories being tracked') parser.add_argument( '--dump-hashes-config', help='Dump the git hashes of all repositories packaged into ' 'update-checkout-config.json', metavar='BRANCH-SCHEME-NAME') parser.add_argument( "--tag", help="""Check out each repository to the specified tag.""", metavar='TAG-NAME') parser.add_argument( "--match-timestamp", help='Check out adjacent repositories to match timestamp of ' ' current swift checkout.', action='store_true') parser.add_argument("-j", "--jobs", type=int, help="Number of threads to run at once", default=0, dest="n_processes") args = parser.parse_args() if args.reset_to_remote and not args.scheme: print("update-checkout usage error: --reset-to-remote must specify " "--scheme=foo") sys.exit(1) clone = args.clone clone_with_ssh = args.clone_with_ssh skip_history = args.skip_history scheme = args.scheme github_comment = args.github_comment with open(args.config) as f: config = json.load(f) validate_config(config) if args.dump_hashes: dump_repo_hashes(config) return (None, None) if args.dump_hashes_config: dump_hashes_config(args, config) return (None, None) cross_repos_pr = {} if github_comment: regex_pr = r'(apple/[-a-zA-Z0-9_]+/pull/\d+|apple/[-a-zA-Z0-9_]+#\d+)' repos_with_pr = re.findall(regex_pr, github_comment) print("Found related pull requests:", str(repos_with_pr)) repos_with_pr = [pr.replace('/pull/', '#') for pr in repos_with_pr] cross_repos_pr = dict(pr.split('#') for pr in repos_with_pr) clone_results = None if clone or clone_with_ssh: # If branch is None, default to using the default branch alias # specified by our configuration file. if scheme is None: scheme = config['default-branch-scheme'] skip_repo_list = args.skip_repository_list clone_results = obtain_all_additional_swift_sources( args, config, clone_with_ssh, scheme, skip_history, skip_repo_list) update_results = update_all_repositories(args, config, scheme, cross_repos_pr) fail_count = 0 fail_count += shell.check_parallel_results(clone_results, "CLONE") fail_count += shell.check_parallel_results(update_results, "UPDATE") if fail_count > 0: print("update-checkout failed, fix errors and try again") else: print("update-checkout succeeded") sys.exit(fail_count)
from gonogo.settings.block_handler import BlockHandler from gonogo.settings.resolve import resolve_settings # must import implemented blocks here from gonogo.scenes import * from gonogo.utils import camel_to_snake, snake_to_camel, rush from gonogo.scenes.done import Done from gonogo import __version__ from toon.input import MpDevice, mono_clock from gonogo.devices.custom import Custom from gonogo.devices.keyboard import Keyboard import pip._vendor.pytoml as toml # first, we'll get a window + context up ASAP # this takes a certain amount of time (~750-1000ms) freeze_support() # TODO: can this just live somewhere in toon? can_rush = rush(True) # test if rush will have an effect rush(False) win = Window() # instantiate the device hids = any([e['vendor_id'] == 0x16c0 for e in hid.enumerate()]) ports = list_ports.comports() serials = next((p.device for p in ports if p.pid == 1155), None) # M$ calls it a microsoft device if not hids and serials is None: warn('Special device not attached, falling back to keyboard.') device = MpDevice(Keyboard(keys=['k', 'l'], clock=mono_clock.get_time)) device_type = 'keyboard' else: device = MpDevice(Custom(clock=mono_clock.get_time))
def loop_core(self, tsample=50., tmax=None, path='.', **kwargs): """Main function (internal use).""" import pandas as pd path = Path(path) path.norm() path.mkdir(rmdir=kwargs.get('clean_directory', False)) table = [] dic = { 'tsample': tsample, 'tmax': tmax, 'path': path, 'sys': kwargs.get('sys', None), } reseed = kwargs.get('reseed', 1) if self.model and not reseed: model = deepcopy(self.model[dic['sys']]) model.set_params(regen=1, **kwargs) else: model = self.Model(**kwargs) for i in kwargs: if i in model.export_params(): dic[i] = kwargs[i] if not reseed: self.model[dic[ 'sys']] = model #transmit the model further down the loop instead of recreating it each time if 'replicas' in kwargs: '''Parallel processing''' from multiprocessing import Pool, freeze_support freeze_support() systems = range(kwargs['replicas']) array = [(path.copy(), self.Model, model.export_params(), model.results, tmax, tsample, kwargs.get('keep', 'endpoint'), sys) for sys in systems] pool = Pool() pool.map(mp_run, array) pool.close() pool.join() pool.terminate() else: kwargs.setdefault('converge', 1) kwargs.setdefault('keep', 'endpoint') success = model.evol(tmax=tmax, tsample=tsample, path=path, **kwargs) if not success and not 'model' in kwargs: kwargs['loop_trials'] = kwargs.get('loop_trials', 0) + 1 if kwargs['loop_trials'] < self.MAX_TRIALS: print('### model diverged, trying again! ###') return self.loop_core(tsample=tsample, tmax=tmax, path=path, **kwargs) else: print( '### model diverged {} times, setting results to 0! ###' .format(kwargs['loop_trials'])) for var in model.results: model.results[var][:] = 0 if 'loop_trials' in kwargs: del kwargs['loop_trials'] model.save(path) table.append(dic) pd.DataFrame(table).to_csv(path + 'files.csv') return table
while count: try: is_dulicate, reply_no = check_duplicates(collection, url) if is_dulicate == 1: add_to_mongodb(collection, url, reply_no) break elif is_dulicate == 2: update_to_mongodb(collection, url, reply_no) break else: logger.info('same car exist pass') # break except Exception as e: logger.error("main : ", e) # count -= 1 if __name__ == "__main__": results = [] multiprocessing.freeze_support() # Windows 平台要加上这句,避免 RuntimeError pool = multiprocessing.Pool() cpus = multiprocessing.cpu_count() for i in range(0, cpus): result = pool.apply_async(main) results.append(result) pool.close() pool.join()
def main(): print("Starting Program \n\n") freeze_support() #Set Arguments args = param_parser() template_XML = args.xml template_WD = args.wd variable_file = args.variable_file outputdir = args.outputpath flownyear = args.flownyear fid1 = args.fid1 fid2 = args.fid2 fid3 = args.fid3 fid4 = args.fid4 myvars = {} with open(variable_file) as varfile: for line in varfile: var, val = line.partition(":")[::2] myvars[var.strip()] = val.strip() products = {} products['dem_asc'] = {} products['dem_asc']['uid'] = fid1 products['dem_asc']['surface_type'] = 'DEM' products['dem_asc']['product_type'] = 'GRID' products['dem_asc']['format'] = 'ASCII' products['dem_asc']['xml'] = os.path.join( outputdir, "{0}_{2}_z{1}_DEM_GRID_1_ASCII.xml".format(myvars['#areaname#'], myvars['#zone#'], flownyear)) products['dem_asc'][ 'limitations'] = 'DEM accuracy will be limited by the spatial accuracy of the LiDAR point data and will contain some additional error due to interpolation, particularly in areas of dense vegetation where ground points are sparse. There may also be some minor error due to ground point misclassification.' products['dem_xyz'] = {} products['dem_xyz']['uid'] = fid2 products['dem_xyz']['surface_type'] = 'DEM' products['dem_xyz']['product_type'] = 'GRID' products['dem_xyz']['format'] = 'TEXT' products['dem_xyz']['xml'] = os.path.join( outputdir, "{0}_{2}_z{1}_DEM_GRID_1_TEXT.xml".format(myvars['#areaname#'], myvars['#zone#'], flownyear)) products['dem_xyz'][ 'limitations'] = 'DEM accuracy will be limited by the spatial accuracy of the LiDAR point data and will contain some additional error due to interpolation, particularly in areas of dense vegetation where ground points are sparse. There may also be some minor error due to ground point misclassification.' products['int'] = {} products['int']['uid'] = fid3 products['int']['surface_type'] = 'INT-First' products['int']['product_type'] = 'Other' products['int']['format'] = 'TIFF' products['int']['xml'] = os.path.join( outputdir, "{0}_{2}_z{1}_INT-First_Other_1_TIFF.xml".format( myvars['#areaname#'], myvars['#zone#'], flownyear)) products['int'][ 'limitations'] = 'The intensity image accuracy will be limited by the spatial accuracy of the LiDAR point data.' products['las_ahd'] = {} products['las_ahd']['uid'] = fid4 products['las_ahd']['surface_type'] = 'LiDAR-AHD' products['las_ahd']['product_type'] = 'MassPoints' products['las_ahd']['format'] = 'LAS' products['las_ahd']['xml'] = os.path.join( outputdir, "{0}_{2}_z{1}_LiDAR-AHD_MassPoints_1_LAS.xml".format( myvars['#areaname#'], myvars['#zone#'], flownyear)) products['las_ahd'][ 'limitations'] = 'The workflow and quality assurance processes were designed to achieve the Level 2 requirement for removal of significant anomalies which remain in the ground class (2), vegetation classes (3, 4, 5), buildings and structures (6), water (9), and bridges (10), and achieve a ground point misclassification rate of 2% or less. The classification accuracy was not measured.' print(myvars['#areaname#']) word_Doc = os.path.join( outputdir, "TMR_Metadata_{0}.docx".format(myvars['#areaname#'])) document = Document(template_WD) tables = document.tables for table in tables: for row in table.rows: for cell in row.cells: for para in cell.paragraphs: for key, val in myvars.items(): if key in para.text: para.text = para.text.replace(key, val) document.save(word_Doc) with open(template_XML, encoding='latin-1') as myasciif: data = myasciif.read() for key, val in myvars.items(): if key in data: print(key, val) data = data.replace(key, val) for product, params in products.items(): testdata = data print(product) xmlfile = products[product]['xml'] limitations = products[product]['limitations'] uid = products[product]['uid'] testdata = testdata.replace('#uid#', uid) testdata = testdata.replace('#limitations#', limitations) for key1, value1 in params.items(): testdata = testdata.replace('#{0}#'.format(key1), value1) print(xmlfile) with open(xmlfile, 'wb') as f: #print(testdata) testdata = testdata.encode(encoding='latin-1', errors='strict') f.write(testdata) xmlfile = '' return
logging.info(task) task_queue.put(task) # Start worker processes for i in range(NUMBER_OF_PROCESSES): Process(target=worker, args=(task_queue, done_queue)).start() # Get and print results for i in range(len(TASKS1)): logging.info(done_queue.get()) # Add more tasks using `put()` for task in TASKS2: logging.info(task) task_queue.put(task) # Get and print some more results for i in range(len(TASKS2)): logging.info(done_queue.get()) # Tell child processes to stop for i in range(NUMBER_OF_PROCESSES): task_queue.put('STOP') logging.info("Main stop") return 0 if __name__ == '__main__': freeze_support() sys.exit(main())
def train_classifier(test, blocker=False): number_train = 20 number_valid = 30 number_test = 25 steps = 1000 batch_size = 1024 conv_layers = 3 if test: number_train = 2 number_valid = 2 number_test = 2 steps = 50 batch_size = 20 conv_layers = 2 multiprocessing.freeze_support() episode_paths = frame.episode_paths(input_path) print('Found {} episodes'.format(len(episode_paths))) np.random.seed(seed=42) np.random.shuffle(episode_paths) if blocker: common_hparams = dict(use_action=True, expected_positive_weight=0.05) labeller = humanrl.pong_catastrophe.PongBlockerLabeller() else: common_hparams = dict(use_action=False) labeller = humanrl.pong_catastrophe.PongClassifierLabeller() data_loader = DataLoader(labeller, TensorflowClassifierHparams(**common_hparams)) datasets = data_loader.split_episodes(episode_paths, number_train, number_valid, number_test, use_all=False) hparams_list = [ dict( image_crop_region=((34, 34 + 160), (0, 160)), #image_shape=[42, 42, 1], convolution2d_stack_args=[(4, [3, 3], [2, 2])] * conv_layers, batch_size=batch_size, multiprocess=False, fully_connected_stack_args=[50, 10], use_observation=False, use_image=True, verbose=True) ] start_experiment = time.time() print( 'Run experiment params: ', dict(number_train=number_train, number_valid=number_valid, number_test=number_test, steps=steps, batch_size=batch_size, conv_layers=conv_layers)) print('hparams', common_hparams, hparams_list[0]) logdir = save_classifier_path run_experiments(logdir, data_loader, datasets, common_hparams, hparams_list, steps=steps, log_every=int(.1 * steps)) time_experiment = time.time() - start_experiment print('Steps: {}. Time in mins: {}'.format(steps, (1 / 60) * time_experiment)) run_classifier_metrics()
L = list(range(9)) def progresser(n): interval = 0.001 / (len(L) - n + 2) total = 5000 text = "#{}, est. {:<04.2}s".format(n, interval * total) # NB: ensure position>0 to prevent printing '\n' on completion. # `tqdm` can't autmoate this since this thread # may not know about other bars in other threads #477. for _ in tqdm(range(total), desc=text, position=n + 1): sleep(interval) if __name__ == '__main__': freeze_support() # for Windows support p = Pool(len(L), initializer=tqdm.set_lock, initargs=(RLock(),)) p.map(progresser, L) print('\n' * len(L)) # alternatively, on UNIX, just use the default internal lock p = Pool(len(L)) p.map(progresser, L) print('\n' * len(L)) # a manual test demonstrating automatic fix for #477 on one thread for _ in trange(10, desc="1", position=1): for _ in trange(10, desc="2", position=0): sleep(0.01)
self.abort_trans() self.safe_close() event.accept() else: event.ignore() else: self.safe_close() event.accept() def keyPressEvent(self, k): """按ESC时触发的关闭行为。""" if k.key() == Qt.Key_Escape: self.close() def resizeEvent(self, event): """调整窗口尺寸时触发。""" for inst in self.files: # 根据表格列宽调整截断文件名 changed_text = self.shorten_filename(inst.name, self.file_table.columnWidth(1)) inst.label.setText(changed_text) if __name__ == '__main__': freeze_support() # win平台打包支持 if getattr(sys, 'frozen', False): # 寻找程序运行目录 bundle_dir = getattr(sys, '_MEIPASS', None) else: bundle_dir = os.path.dirname(os.path.abspath(__file__)) app = QApplication(sys.argv) window = ClientWindow() sys.exit(app.exec())
def main() -> None: multiprocessing.freeze_support() sys.setrecursionlimit(10000) # Ideally we would do: # multiprocessing.set_start_method('spawn') # here, to make multiprocessing behave the same across operating systems. # However, that means that arguments to Process are passed across using # pickling, which mysteriously breaks with pycparser... # (AttributeError: 'CParser' object has no attribute 'p_abstract_declarator_opt') # So, for now we live with the defaults, which make multiprocessing work on Linux, # where it uses fork and don't pickle arguments, and break on Windows. Sigh. parser = argparse.ArgumentParser( description="Randomly permute C files to better match a target binary." ) parser.add_argument( "directory", nargs="+", help= "Directory containing base.c, target.o and compile.sh. Multiple directories may be given.", ) parser.add_argument( "--show-errors", dest="show_errors", action="store_true", help= "Display compiler error/warning messages, and keep .c files for failed compiles.", ) parser.add_argument( "--show-timings", dest="show_timings", action="store_true", help="Display the time taken by permuting vs. compiling vs. scoring.", ) parser.add_argument( "--print-diffs", dest="print_diffs", action="store_true", help= "Instead of compiling generated sources, display diffs against a base version.", ) parser.add_argument( "--abort-exceptions", dest="abort_exceptions", action="store_true", help="Stop execution when an internal permuter exception occurs.", ) parser.add_argument( "--better-only", dest="better_only", action="store_true", help="Only report scores better than the base.", ) parser.add_argument( "--stop-on-zero", dest="stop_on_zero", action="store_true", help="Stop after producing an output with score 0.", ) parser.add_argument( "--stack-diffs", dest="stack_differences", action="store_true", help="Take stack differences into account when computing the score.", ) parser.add_argument( "--keep-prob", dest="keep_prob", metavar="PROB", type=float, default=DEFAULT_RAND_KEEP_PROB, help= "Continue randomizing the previous output with the given probability " f"(float in 0..1, default {DEFAULT_RAND_KEEP_PROB}).", ) parser.add_argument("--seed", dest="force_seed", type=str, help=argparse.SUPPRESS) parser.add_argument( "-j", dest="threads", type=int, default=1, help="Number of threads (default: %(default)s).", ) args = parser.parse_args() options = Options( directories=args.directory, show_errors=args.show_errors, show_timings=args.show_timings, print_diffs=args.print_diffs, abort_exceptions=args.abort_exceptions, better_only=args.better_only, stack_differences=args.stack_differences, stop_on_zero=args.stop_on_zero, keep_prob=args.keep_prob, force_seed=args.force_seed, threads=args.threads, ) run(options)
html = requests.get(pic, headers=header) mess = BeautifulSoup(html.text, "html.parser") pic_url = mess.find('img', alt=title) if 'src' not in pic_url.attrs: # 有些pic_url标签没有src属性,导致操作异常,在次进行过滤 continue print(f"{title}:{pic_url['src']}") html = requests.get(pic_url['src'], headers=header) file_name = pic_url['src'].split(r'/')[-1] f = open(file_name, 'wb') f.write(html.content) f.close() print('妹子已就绪,客官请慢用:' + title) if __name__ == '__main__': freeze_support() # 防止打包后 运行exe创建进程失败 # 线程池中线程数 count = 1 if len(sys.argv) >= 2: count = int(sys.argv[1]) pool = Pool(count) print(f'初始化下载线程个数${count}') # http请求头 path = os.getcwd() + '/mzitu_mutil/' max_page = find_MaxPage() # 获取最大页数 即生成的文件夹数量 print(max_page) print(f'捕获{max_page}页妹子,请耐心等待下载完成') same_url = 'http://www.mzitu.com'
def main(): freeze_support() pool = multiprocessing.Pool(processes=10) #use 10 processes for fast downloading, IO takes time output = pool.map(download_video,zip(video_url_list,vid_name_list,list(range(1,len(video_url_list)+1)))) print ("Done.")
def main(): # freeze_support() parser = argparse.ArgumentParser() parser.description = "FORTRAN Language Server ({0})".format(__version__) parser.add_argument( '--version', action="store_true", help="Print server version number and exit" ) parser.add_argument( '--nthreads', type=int, default=4, help="Number of threads to use during workspace initialization (default: 4)" ) parser.add_argument( '--notify_init', action="store_true", help="Send notification message when workspace initialization is complete" ) parser.add_argument( '--symbol_skip_mem', action="store_true", help="Do not include type members in document symbol results" ) parser.add_argument( '--incremental_sync', '--incrmental_sync', action="store_true", help="Use incremental document synchronization (beta)" ) parser.add_argument( '--autocomplete_no_prefix', action="store_true", help="Do not filter autocomplete results by variable prefix" ) parser.add_argument( '--lowercase_intrinsics', action="store_true", help="Use lowercase for intrinsics and keywords in autocomplete requests" ) parser.add_argument( '--use_signature_help', action="store_true", help="Use signature help instead of subroutine/function snippets" ) parser.add_argument( '--variable_hover', action="store_true", help="Show hover information for variables (default: subroutines/functions only)" ) parser.add_argument( '--preserve_keyword_order', action="store_true", help="Display variable keywords information in original order (default: sort to consistent ordering)" ) parser.add_argument( '--enable_code_actions', action="store_true", help="Enable experimental code actions (default: false)" ) parser.add_argument( '--debug_log', action="store_true", help="Generate debug log in project root folder" ) group = parser.add_argument_group("DEBUG", "Options for debugging language server") group.add_argument( '--debug_parser', action="store_true", help="Test source code parser on specified file" ) group.add_argument( '--debug_diagnostics', action="store_true", help="Test diagnostic notifications for specified file" ) group.add_argument( '--debug_symbols', action="store_true", help="Test symbol request for specified file" ) group.add_argument( '--debug_workspace_symbols', type=str, help="Test workspace/symbol request" ) group.add_argument( '--debug_completion', action="store_true", help="Test completion request for specified file and position" ) group.add_argument( '--debug_signature', action="store_true", help="Test signatureHelp request for specified file and position" ) group.add_argument( '--debug_definition', action="store_true", help="Test definition request for specified file and position" ) group.add_argument( '--debug_hover', action="store_true", help="Test hover request for specified file and position" ) group.add_argument( '--debug_implementation', action="store_true", help="Test implementation request for specified file and position" ) group.add_argument( '--debug_references', action="store_true", help="Test references request for specified file and position" ) group.add_argument( '--debug_rename', type=str, help="Test rename request for specified file and position" ) group.add_argument( '--debug_actions', action="store_true", help="Test codeAction request for specified file and position" ) group.add_argument( '--debug_filepath', type=str, help="File path for language server tests" ) group.add_argument( '--debug_rootpath', type=str, help="Root path for language server tests" ) group.add_argument( '--debug_line', type=int, help="Line position for language server tests (1-indexed)" ) group.add_argument( '--debug_char', type=int, help="Character position for language server tests (1-indexed)" ) args = parser.parse_args() if args.version: print("{0}".format(__version__)) sys.exit(0) debug_server = (args.debug_diagnostics or args.debug_symbols or args.debug_completion or args.debug_signature or args.debug_definition or args.debug_hover or args.debug_implementation or args.debug_references or (args.debug_rename is not None) or args.debug_actions or (args.debug_rootpath is not None) or (args.debug_workspace_symbols is not None)) # settings = { "nthreads": args.nthreads, "notify_init": args.notify_init, "symbol_include_mem": (not args.symbol_skip_mem), "sync_type": 2 if args.incremental_sync else 1, "autocomplete_no_prefix": args.autocomplete_no_prefix, "lowercase_intrinsics": args.lowercase_intrinsics, "use_signature_help": args.use_signature_help, "variable_hover": args.variable_hover, "sort_keywords": (not args.preserve_keyword_order), "enable_code_actions": (args.enable_code_actions or args.debug_actions) } # if args.debug_parser: if args.debug_filepath is None: error_exit("'debug_filepath' not specified for parsing test") file_exists = os.path.isfile(args.debug_filepath) if file_exists is False: error_exit("Specified 'debug_filepath' does not exist") # Get preprocessor definitions from config file pp_defs = {} if args.debug_rootpath: config_path = os.path.join(args.debug_rootpath, ".fortls") config_exists = os.path.isfile(config_path) if config_exists: try: import json with open(config_path, 'r') as fhandle: config_dict = json.load(fhandle) pp_defs = config_dict.get("pp_defs", {}) if isinstance(pp_defs, list): pp_defs = {key: "" for key in pp_defs} except: print("Error while parsing '.fortls' settings file") # print('\nTesting parser') print(' File = "{0}"'.format(args.debug_filepath)) file_obj = fortran_file(args.debug_filepath) err_str = file_obj.load_from_disk() if err_str is not None: error_exit("Reading file failed: {0}".format(err_str)) print(' Detected format: {0}'.format("fixed" if file_obj.fixed else "free")) print("\n=========\nParser Output\n=========\n") _, file_ext = os.path.splitext(os.path.basename(args.debug_filepath)) if file_ext == file_ext.upper(): file_ast = process_file(file_obj, True, debug=True, pp_defs=pp_defs) else: file_ast = process_file(file_obj, True, debug=True) print("\n=========\nObject Tree\n=========\n") for obj in file_ast.get_scopes(): print("{0}: {1}".format(obj.get_type(), obj.FQSN)) print_children(obj) print("\n=========\nExportable Objects\n=========\n") for _, obj in file_ast.global_dict.items(): print("{0}: {1}".format(obj.get_type(), obj.FQSN)) # elif debug_server: prb, pwb = os.pipe() tmpin = os.fdopen(prb, 'rb') tmpout = os.fdopen(pwb, 'wb') s = LangServer(conn=JSONRPC2Connection(ReadWriter(tmpin, tmpout)), debug_log=args.debug_log, settings=settings) # if args.debug_rootpath: dir_exists = os.path.isdir(args.debug_rootpath) if dir_exists is False: error_exit("Specified 'debug_rootpath' does not exist or is not a directory") print('\nTesting "initialize" request:') print(' Root = "{0}"'.format(args.debug_rootpath)) s.serve_initialize({ "params": {"rootPath": args.debug_rootpath} }) if len(s.post_messages) == 0: print(" Succesful!") else: print(" Succesful with errors:") for message in s.post_messages: print(" {0}".format(message[1])) # Print module directories print("\n Source directories:") for source_dir in s.source_dirs: print(" {0}".format(source_dir)) # if args.debug_diagnostics: print('\nTesting "textDocument/publishDiagnostics" notification:') check_request_params(args, loc_needed=False) s.serve_onSave({ "params": { "textDocument": {"uri": args.debug_filepath} } }) diag_results, _ = s.get_diagnostics(args.debug_filepath) if diag_results is not None: sev_map = ["ERROR", "WARNING", "INFO"] if len(diag_results) == 0: print("\nNo errors or warnings") else: print("\nReported errors or warnings:") for diag in diag_results: sline = diag["range"]["start"]["line"] message = diag["message"] sev = sev_map[diag["severity"]-1] print(' {0:5d}:{1} "{2}"'.format(sline, sev, message)) # if args.debug_symbols: print('\nTesting "textDocument/documentSymbol" request:') check_request_params(args, loc_needed=False) s.serve_onSave({ "params": { "textDocument": {"uri": args.debug_filepath} } }) symbol_results = s.serve_document_symbols({ "params": { "textDocument": {"uri": args.debug_filepath} } }) for symbol in symbol_results: sline = symbol["location"]["range"]["start"]["line"] if "containerName" in symbol: parent = symbol["containerName"] else: parent = "null" print(' line {2:5d} symbol -> {1:3d}:{0:30} parent = {3}'.format(symbol["name"], symbol["kind"], sline, parent)) # if args.debug_workspace_symbols is not None: print('\nTesting "workspace/symbol" request:') if args.debug_rootpath is None: error_exit("'debug_rootpath' not specified for debug request") symbol_results = s.serve_workspace_symbol({ "params": { "query": args.debug_workspace_symbols } }) for symbol in symbol_results: path = path_from_uri(symbol["location"]["uri"]) sline = symbol["location"]["range"]["start"]["line"] if "containerName" in symbol: parent = symbol["containerName"] else: parent = "null" print(' {2}::{3:d} symbol -> {1:3d}:{0:30} parent = {4}'.format(symbol["name"], symbol["kind"], os.path.relpath(path, args.debug_rootpath), sline, parent)) # if args.debug_completion: print('\nTesting "textDocument/completion" request:') check_request_params(args) s.serve_onSave({ "params": { "textDocument": {"uri": args.debug_filepath} } }) completion_results = s.serve_autocomplete({ "params": { "textDocument": {"uri": args.debug_filepath}, "position": {"line": args.debug_line-1, "character": args.debug_char-1} } }) print(' Results:') for obj in completion_results['items']: print(' {0}: {1} -> {2}'.format(obj['kind'], obj['label'], obj['detail'])) # if args.debug_signature: print('\nTesting "textDocument/signatureHelp" request:') check_request_params(args) s.serve_onSave({ "params": { "textDocument": {"uri": args.debug_filepath} } }) signature_results = s.serve_signature({ "params": { "textDocument": {"uri": args.debug_filepath}, "position": {"line": args.debug_line-1, "character": args.debug_char-1} } }) if len(signature_results['signatures']) == 0: print(' No Results') else: print(' Results:') active_param = signature_results.get('activeParameter', 0) print(' Active param = {0}'.format(active_param)) active_signature = signature_results.get('activeSignature', 0) print(' Active sig = {0}'.format(active_signature)) for i, signature in enumerate(signature_results['signatures']): print(' {0}'.format(signature['label'])) for j, obj in enumerate(signature['parameters']): if (i == active_signature) and (j == active_param): active_mark = '*' else: active_mark = ' ' arg_desc = obj.get('documentation') if arg_desc is not None: print('{2} {0} :: {1}'.format(arg_desc, obj['label'], active_mark)) else: print('{1} {0}'.format(obj['label'], active_mark)) # if args.debug_definition or args.debug_implementation: if args.debug_definition: print('\nTesting "textDocument/definition" request:') elif args.debug_implementation: print('\nTesting "textDocument/implementation" request:') check_request_params(args) s.serve_onSave({ "params": { "textDocument": {"uri": args.debug_filepath} } }) if args.debug_definition: definition_results = s.serve_definition({ "params": { "textDocument": {"uri": args.debug_filepath}, "position": {"line": args.debug_line-1, "character": args.debug_char-1} } }) elif args.debug_implementation: definition_results = s.serve_implementation({ "params": { "textDocument": {"uri": args.debug_filepath}, "position": {"line": args.debug_line-1, "character": args.debug_char-1} } }) print(' Result:') if definition_results is None: print(' No result found!') else: print(' URI = "{0}"'.format(definition_results['uri'])) print(' Line = {0}'.format(definition_results['range']['start']['line']+1)) print(' Char = {0}'.format(definition_results['range']['start']['character']+1)) # if args.debug_hover: print('\nTesting "textDocument/hover" request:') check_request_params(args) s.serve_onSave({ "params": { "textDocument": {"uri": args.debug_filepath} } }) hover_results = s.serve_hover({ "params": { "textDocument": {"uri": args.debug_filepath}, "position": {"line": args.debug_line-1, "character": args.debug_char-1} } }) print(' Result:') if hover_results is None: print(' No result found!') else: contents = hover_results['contents'] print('=======') if isinstance(contents, dict): print(contents['value']) else: print(contents) print('=======') # if args.debug_references: print('\nTesting "textDocument/references" request:') check_request_params(args) s.serve_onSave({ "params": { "textDocument": {"uri": args.debug_filepath} } }) ref_results = s.serve_references({ "params": { "textDocument": {"uri": args.debug_filepath}, "position": {"line": args.debug_line-1, "character": args.debug_char-1} } }) print(' Result:') if ref_results is None: print(' No result found!') else: print('=======') for result in ref_results: print(' {0} ({1}, {2})'.format(result['uri'], result['range']['start']['line']+1, result['range']['start']['character']+1)) print('=======') # if (args.debug_rename is not None): print('\nTesting "textDocument/rename" request:') check_request_params(args) s.serve_onSave({ "params": { "textDocument": {"uri": args.debug_filepath} } }) ref_results = s.serve_rename({ "params": { "textDocument": {"uri": args.debug_filepath}, "position": {"line": args.debug_line-1, "character": args.debug_char-1}, "newName": args.debug_rename } }) print(' Result:') if ref_results is None: print(' No changes found!') else: print('=======') for uri, result in ref_results["changes"].items(): path = path_from_uri(uri) print('File: "{0}"'.format(path)) file_obj = s.workspace.get(path) if file_obj is not None: file_contents = file_obj.contents_split for change in result: start_line = change['range']['start']['line'] end_line = change['range']['end']['line'] start_col = change['range']['start']['character'] end_col = change['range']['end']['character'] print(' {0}, {1}'.format(start_line+1, end_line+1)) new_contents = [] for i in range(start_line, end_line+1): line = file_contents[i] print(' - {0}'.format(line)) if i == start_line: new_contents.append(line[:start_col] + change['newText']) if i == end_line: new_contents[-1] += line[end_col:] for line in new_contents: print(' + {0}'.format(line)) print() else: print('Unknown file: "{0}"'.format(path)) print('=======') # if args.debug_actions: import pprint pp = pprint.PrettyPrinter(indent=2, width=120) print('\nTesting "textDocument/getActions" request:') check_request_params(args) s.serve_onSave({ "params": { "textDocument": {"uri": args.debug_filepath} } }) action_results = s.serve_codeActions({ "params": { "textDocument": {"uri": args.debug_filepath}, "range": { "start": {"line": args.debug_line-1, "character": args.debug_char-1}, "end": {"line": args.debug_line-1, "character": args.debug_char-1} } } }) for result in action_results: print("Kind = '{0}', Title = '{1}'".format(result['kind'], result['title'])) for editUri, editChange in result['edit']['changes'].items(): print("\nChange: URI = '{0}'".format(editUri)) pp.pprint(editChange) print() tmpout.close() tmpin.close() # else: stdin, stdout = _binary_stdio() s = LangServer(conn=JSONRPC2Connection(ReadWriter(stdin, stdout)), debug_log=args.debug_log, settings=settings) s.run()
def main(): try: opts, args = getopt.getopt(sys.argv[1:], "i:n:s:m:f:h:rq", [ "ident=", "num_tasks=", "num_sets=", "max_fault_rate=", "fault_rate_step_size=", "hard_task_factor=", "rounded", "quick" ]) except getopt.GetoptError as err: print str(err) sys.exit(2) num_tasks, num_sets, max_fault_rate, step_size_fault_rate, hard_task_factor = 0, 0, 0, 0, 0 ident = None rounded = False quick = False for opt, arg in opts: if opt in ('-i', '--ident'): ident = str(arg) if opt in ('-n', '--num_tasks'): num_tasks = int(arg) if opt in ('-s', '--num_sets'): num_sets = int(arg) if opt in ('-m', '--max_fault_rate'): max_fault_rate = min(1.0, float(arg)) if opt in ('-f', '--fault_rate_step_size'): step_size_fault_rate = min(1.0, float(arg)) if opt in ('-h', '--hard_task_factor'): hard_task_factor = float(arg) if opt in ('-r', '--rounded'): rounded = True if opt in ('-q', '--quick'): quick = True if quick is False: for fault_rate in np.arange(step_size_fault_rate, max_fault_rate + step_size_fault_rate, step_size_fault_rate): print 'Evaluating: %d tasksets, %d tasks, fault probability: %f, rounded: %r' % ( num_sets, num_tasks, fault_rate, rounded) for utilization in np.arange(5, 100, 5): try: if ident is not None: filename = 'tasksets_' + ident + '_n_' + str( num_tasks) + 'u_' + str(utilization) + '_m' + str( num_sets) + 's_' + str( max_fault_rate) + 'f_' + str( step_size_fault_rate) + str( 'r' if rounded else '') try: tasksets = np.load('../tasksets/' + filename + '.npy') except: raise Exception, "Could not read" results_chernoff = [] results_george = [] for taskset in tasksets: results_chernoff.append( chernoff.optimal_chernoff_taskset_all(taskset)) results_george.append( george_inlined_all(taskset, max_fault_rate)) np.save('../results/res_chernoff_' + filename + '.npy', results_chernoff) np.save('../results/res_george_' + filename + '.npy', results_george) else: raise Exception, "Please specify an identifier!" except IOError: print 'Could not write filename %s' % filename else: for fault_rate in np.arange(step_size_fault_rate, max_fault_rate + step_size_fault_rate, step_size_fault_rate): print 'Evaluating: %d tasksets, %d tasks, fault probability: %f, rounded: %r' % ( num_sets, num_tasks, fault_rate, rounded) #for utilization in np.arange(5, 100, 5): #for utilization in np.arange(50, 55, 20): for utilization in np.arange(70, 75, 20): try: if ident is not None: filename = 'tasksets_' + ident + '_n_' + str( num_tasks) + 'u_' + str(utilization) + '_m' + str( num_sets) + 's_' + str( max_fault_rate) + 'f_' + str( step_size_fault_rate) + str( 'r' if rounded else '') try: tasksets = np.load('../tasksets_short/' + filename + '.npy') except: raise Exception, "Could not read" results_chernoff = [] results_george = [] rel = [] if __name__ == '__main__': # for taskset in tasksets: freeze_support() p = Pool(5) rel = (p.map( func_star, itertools.izip( tasksets, itertools.repeat(max_fault_rate)))) print rel for i in rel: results_chernoff.append(i[0]) results_george.append(i[1]) np.save( '../results_short/mp_res_chernoff_' + filename + '.npy', results_chernoff) np.save( '../results_short/mp_res_george_' + filename + '.npy', results_george) else: raise Exception, "Please specify an identifier!" except IOError: print 'Could not write filename %s' % filename