def event(self, event): if event.type == PY.KEYDOWN: if event.key == PY.K_ESCAPE and self.sequence != 11: if (self.sequence != 0 and self.sequence != (len(Joystick.PROMPTS) - 1)): self.sequence = -1 G.Globals.CONTROLLER = False elif self.sequence == (len(Joystick.PROMPTS) - 1): self.sequence = -1 G.Globals.STATE = options.Options(True, 1) if ((event.key == PY.K_RETURN or event.key == PY.K_SPACE) and (self.sequence < 0 or self.sequence > 11)): G.Globals.CONTROLLER = not G.Globals.CONTROLLER if G.Globals.CONTROLLER: PY.joystick.init() G.Globals.JOYSTICK = PY.joystick.Joystick(0) G.Globals.JOYSTICK.init() self.event_maps_init() if (self.sequence < 12 and self.event_validator(event)): G.Globals.EVENTS[self.sequence] = event self.sequence += 1 if (self.sequence >= 12 and self.new_event_validator(event)): G.Globals.EVENT_MAP[self.sequence % 12] = event self.sequence += 1 if self.sequence >= 24: self.sequence = -1 G.Globals.STATE = options.Options(True, 1)
def event(self, event): if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: globes.Globals.RUNNING = False if event.type == pygame.KEYDOWN and event.key == pygame.K_UP: self.option = (self.option - 1) % self.num_options if event.type == pygame.KEYDOWN and event.key == pygame.K_DOWN: self.option = (self.option + 1) % self.num_options if event.type == pygame.KEYDOWN and \ (event.key == pygame.K_SPACE or event.key == pygame.K_RETURN): if self.option == 0: globes.stop_music() globes.play_music("angryTwain.ogg") globes.Globals.GAME = game.Game() globes.Globals.LVLS_UNLOCKED = 1 globes.Globals.STATE = cutscene1.Hack() elif self.option == 1: globes.stop_music() globes.Globals.STATE = score.Score() elif self.option == 2: globes.Globals.STATE = options.Options(True) elif self.option == 3: globes.Globals.RUNNING = False elif self.option == 4: globes.stop_music() globes.play_music("game.ogg") if globes.Globals.MINIGAME is not None: globes.Globals.STATE = globes.Globals.MINIGAME else: globes.Globals.STATE = globes.Globals.GAME
def main(_): opt=options.Options() print('num_paths: ',opt.num_paths) print('path_length: ',opt.path_length) print('embedding_size: ',opt.embedding_size) print('learning_rate: ',opt.learning_rate) print('decay_rate: ',opt.decay_rate) print('epochs_to_train: ',opt.epochs_to_train) print('num_sequences: ',opt.num_sequences) print('num_skips: ',opt.num_skips) print('------------------------') # Build network, Train model, Obtain embeddings with tf.Graph().as_default(), tf.Session() as session: with tf.device('/cpu:0'): model=DeepWalk(session,opt) print("Build dataset...") model.build_dataset() print("Build model...") train_inputs,train_labels=model.build_model() model.train_model(train_inputs,train_labels) model.saver.save(session,os.path.join(opt.save_path,'model.ckpt')) # Get the embeddings at certain time for i in range(model.num_time): single_embeddings=model.single_time_embeddings(i) # Task for embeddings tasks.run_task(opt.task_name,single_embeddings,model.graph_filename,model.dict_filename)
def main(): o = options.Options(optspec) _, _, extra = o.parse(sys.argv[1:]) interval = int(extra[0]) if len(extra) else -1 platform = open(PLATFORM).read() tvbox = True if 'GFHD' in platform else False wan_if = 'wan0' if 'GFRG2' in platform else 'eth0' new = dict() old = dict() if tvbox: print '--------decoder---------- ------------------display---------------------' print 'verror vover vdrop aerror verr vdrop vundr aover aundr a2vpts vwch awch' else: print '---------sagesrv------------------ --------%s-------- --------br0---------' % wan_if print ' discon dropb dropp pkterr udpdrop err drop fifo frame err drop fifo frame' while True: if tvbox: new = TvBoxStats(old) else: new = StorageBoxStats(old, wan_if) if interval <= 0: return 0 time.sleep(interval) old = new return 0
def main(): o = options.Options(optspec) (opt, unused_flags, unused_extra) = o.parse(sys.argv[1:]) if opt.startup_delay: time.sleep(opt.startup_delay) prestera = PresteraPeriodic(opt.interval) prestera.RunForever()
def main(): global quiet # gpylint: disable-msg=global-statement LogCallerInfo() o = options.Options(optspec) opt, unused_flags, unused_extra = o.parse(sys.argv[1:]) if not (opt.drm or opt.tar or opt.partition): o.fatal('Expected at least one of --partition, --tar, or --drm') # handle 'ginstall -p <partition>' separately if not opt.drm and not opt.tar: partition = GetPartition(opt.partition, GetOs()) if SetBootPartition(GetOs(), partition) != 0: VerbosePrint('Unable to set boot partition\n') return HNVRAM_ERR return 0 # from here: ginstall [-t <tarfile>] [--drm <blob>] [options...] quiet = opt.quiet if opt.basepath: # Standalone test harness can pass in a fake root path. AddBasePath(opt.basepath) if opt.drm: WriteDrm(opt) ret = 0 if opt.tar: ret = InstallImage(opt) return ret
def main(): # Parse and validate arguments. o = options.Options(_OPTSPEC) (opt, _, clients) = o.parse(sys.argv[1:]) opt.duration = float(opt.duration) opt.fraction = int(opt.fraction) opt.size = int(opt.size) if not opt.interface: o.fatal('must specify --interface') if opt.duration <= 0: o.fatal('--duration must be positive') if opt.fraction <= 0: o.fatal('--fraction must be a positive integer') if opt.size <= 0: o.fatal('--size must be a positive integer') # Initialize iw, mac80211stats, and pktgen. iw = Iw(opt.interface) mac80211stats = Mac80211Stats(iw.GetPhy()) pktgen = Pktgen(opt.interface) # If no clients are specified, test all associated clients. if not clients: clients = sorted(iw.GetClients()) # Normalize clients. clients = [client.lower() for client in clients] # Blast packets at each client. for client in clients: _PacketBlast(iw, mac80211stats, pktgen, client, opt.duration, opt.fraction, opt.size)
def defaults_exception_test(self, file, error): try: options.Options(file) self.fail('No exception thrown') except error: pass # This exception should be thrown except not error: self.fail('Wrong type of exception')
def testParent(self): opts = options.Options() parser = argparse.ArgumentParser(parents=[opts.GetParentParser()]) parser.add_argument('--foo', type=int) parsed_args = parser.parse_args(['--foo=4', '--devtools_port', '2000']) self.assertEqual(4, parsed_args.foo) opts.SetParsedArgs(parsed_args) self.assertEqual(2000, opts.devtools_port)
def main(): o = options.Options(optspec) opt, _, _ = o.parse(sys.argv[1:]) if opt.serialno: GenSnSigs(opt.hostdir, opt.bindir, opt.serialno) elif opt.filename: with open(opt.filename, 'r') as snfile: GenSnSigs(opt.hostdir, opt.bindir, snfile.read())
def __init__(self): wxPyGridTableBase.__init__(self) loc = os.path.expanduser('~/.abeni/bugz') if not os.path.exists("%s/EBUILDS.grl" % loc): self.createDB() else: self.ConnectDB() self.colLabels = [ 'Package', 'Bugz Nbr', 'Bugzilla Status', 'Bugzilla Rsltn', 'Mine', 'In Portage', ' Abeni Status ' ] self.dataTypes = [ wxGRID_VALUE_STRING, wxGRID_VALUE_STRING, wxGRID_VALUE_CHOICE + ':,UNCONFIRMED,NEW,ASSIGNED,REOPENED,RESOLVED,VERIFIED,CLOSED', wxGRID_VALUE_CHOICE + ':,FIXED,INVALID,WONTFIX,LATER,REMIND,DUPLICATE,WORKSFORME', wxGRID_VALUE_BOOL, wxGRID_VALUE_BOOL, wxGRID_VALUE_CHOICE + ':,' + options.Options().Prefs()['statuslist'], ] #self.data = [ # [ "app-admin/abeni-0.0.6", 11010,'ASSIGNED', '', 1, 0,'SUBMITTED'], # [ "app-games/flowbie-0.1", 31011, "NEW", '', 0, 0, 0], # [ "media-sound/boobs-1.0", 21012, "RESOLVED", "FIXED", 'all', 0, 1, 'SUBMITTED'] # ] self.data = [] #Grab list of ebuilds in PORTDIR_OVERLAY ebuilds = self.GetEbuilds() ebuilds.sort() #Grab all records in Gadfly SQL database recs = self.FetchDB() nbrRecs = len(recs) for e in ebuilds: portage = self.checkOverlay(e) bzstatus = "" bzresolution = "" mine = 0 abenistatus = '' e = e.replace(portdir_overlay, "") e = e[1:-8] catpack = e.split("/") cat = catpack[0] p = catpack[2] e = "%s/%s" % (cat, p) bug = '' if recs: for i in range(nbrRecs): if recs[i][0] == p: p, package, cat, bug, bzstatus, bzresolution, notes, mine, abenistatus = recs[ i] my = [e, bug, bzstatus, bzresolution, mine, portage, abenistatus] self.data.append(my)
def testExtract(self): args = [ '--A', 'foo', '--devtools_port', '2000', '--B=20', '--no_sandbox', '--C', '30', 'baz' ] opts = options.Options() opts.ExtractArgs(args) self.assertEqual(['--A', 'foo', '--B=20', '--C', '30', 'baz'], args) self.assertEqual(2000, opts.devtools_port) self.assertTrue(opts.no_sandbox)
def load_canvas(canvas, text): for item in canvas.get_all_items(): canvas.remove(item) ascii = preprocess.preprocess(options.Options(), text) figures = aparser.parse(ascii) for f in figures: if isinstance(f, figure.Box): gaphs.Box(f, canvas) elif isinstance(f, figure.Line): gaphs.Line(f, canvas)
def get_options(): global verbose, port, host optdict = dict(getopt.getopt(sys.argv[1:], 'vp:')[0]) if "-p" in optdict: port = int(optdict["-p"]) verbose = ("-v" in optdict) return options.Options(verbose=verbose, port=port, host=host)
def OnBugzFetchButton(self, evt): import urllib, options myOptions = options.Options() pref = myOptions.Prefs() wxSafeYield() bugNbrs = self.grid.GetBugNbrs() bugs = '%2C'.join(bugNbrs) addr = "http://bugs.gentoo.org/buglist.cgi?query_format=&short_desc_type=allwordssubstr&short_desc=&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&bugidtype=include&bug_id=%s&ctype=csv" % bugs f = urllib.urlopen(addr) lines = f.readlines() self.grid.OnBugzFetchButton(lines)
def __init__(self): self.players = [] self.whose_action = None self.colorbank = [ "coral", "darkolivegreen", "dodgerblue", "darkviolet", "orangered", "darkslategray", "dimgray", "salmon", "sienna", "goldenrod", "yellow", "black" ] self.gui = g.Gui(self) self.opt = options.Options(self) self.temple = dimensions.Temple() self.all_dimensions = {self.temple, dimensions.Guardian_Dimension()}
def __init__(self): # log start initTs = time.clock() self.startupTimeStamp = time.time() # parse startup arguments start = startup.Startup() args = start.args self.args = args # restore the persistent options dictionary self.d = {} self.options = options.Options(self) # options value watching self.maxWatchId = 0 self.watches = {} initialSize = (854, 480) # get the platform module self.platform = None # get the platform ID string platformId = "harmattan" # safe fallback if args.p is None: import platform_detection # platform detection result = platform_detection.getBestPlatformModuleId() if result: platformId = result else: # use the CLI provided value platformId = args.p if platformId == "harmattan": import harmattan self.platform = harmattan.Harmattan(self) else: print("can't start: current platform unknown") sys.exit(1) # create the GUI startTs1 = timer.start() # Panora currently has only a single QML based GUI module self.gui = gui.getGui(self, 'QML', accel=True, size=initialSize) timer.elapsed(startTs1, "GUI module import") timer.elapsed(initTs, "Init") timer.elapsed(startTs, "Complete startup") # start the main loop self.gui.startMainLoop()
def main(): o = options.Options(optspec) opt, unused_flags, extra = o.parse(sys.argv[1:]) if extra: o.fatal('no non-flag arguments expected') try: stderr_log = _CursesMain(curses.initscr(), ifc=opt.ifc, tcpdump=opt.tcpdump) finally: curses.endwin() sys.stderr.write(''.join(stderr_log)) if aliases: aliases.Save()
def get_file_opt(self): opt = options.Options(None) opt.define('-c', '--config', default='./conf/setting_dev.conf', help="config path (default %(default)r)", metavar="FILE") o = opt.parse_args(sys.argv) if os.path.exists(o.config): config = ConfigFactory.parseFile(o.config, pystyle=True) return config else: return ConfigFactory.empty(pystyle=True)
def _set_defaults(self): c = self.get_file_opt() opt = options.Options(None) BootOptions(opt) opt = opt.parse_args() d = {} config = vars(opt) for k in config: v = c.get(k, _Null) if v != _Null: d[k] = v self.options.set_defaults(**d) return c
def main(): o = options.Options(optspec) (opt, unused_flags, unused_extra) = o.parse(sys.argv[1:]) prestera = PresteraStats(opt.ports, opt.timeout) results = prestera.GetMibStats() if results: print json.dumps(results, sort_keys=True, indent=2, separators=(',', ': ')) sys.exit(0) sys.exit(1)
def OnButton3Button(self, event): """ Edit file """ app = options.Options().Prefs()['editor'] file = "%s/%s" % (self.fdir_olay, self.GetOverlaySelection()) #TODO: # This fails if app has switches: "/usr/bin/gvim -f" # Also, if they don't put the full path, it'll fail. #if not os.path.exists(f): # print "!!! Editor app not found." # return if os.path.isdir(file): return if app: os.system("%s %s &" % (app, file))
def OnInit(self): try: progPath = os.path.dirname(sys.argv[0]) os.chdir(progPath) except: pass wx.SetDefaultPyEncoding('utf-8') opts = options.Options() mtexts.setLang(opts.langid) frame = morin.MFrame(None, -1, mtexts.txts['Morinus'], opts) frame.Show(True) return True
def initMenus(self, menuEnable): self.menuOn = menuEnable self.optionsMenu = options.Options(self, self.game) self.mainMenu = main_menu.MainMenu(self, self.game) self.levelsMenu = main_menu.LevelsMenu(self, self.game) self.optionsMenu.disable() self.optionsMenuEnabled = False self.levelsMenu.disable() self.levelsMenuEnabled = False if not self.menuOn: self.mainMenuEnabled = False self.mainMenu.disable() else: self.mainMenuEnabled = True self.mainMenu.enable()
def event(self, event): if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: G.Globals.STATE = options.Options(True) elif event.key == pygame.K_UP or event.key == pygame.K_DOWN: self.option = not self.option elif event.key == pygame.K_LEFT: if self.option: self.change_volume(-Volume.STEP) else: self.change_brightness(-Volume.STEP) elif event.key == pygame.K_RIGHT: if self.option: self.change_volume(Volume.STEP) else: self.change_brightness(Volume.STEP)
def reconstruction_main(): n = 10 result = np.zeros(4) opt = options.Options() for i in range(n): save_path = os.path.join('tmpdata/deepwalk/reconstruction', str(i)) if not os.path.exists(save_path): os.makedirs(save_path) tmp = link_reconstruction_run(opt, save_path) for m in range(4): result[m] = result[m] + tmp[m] result = result / n print('-----------------------') print('average\t\taccuracy\t\tprecision\t\trecall\t\tF1') print('reconstruction', result[0], result[1], result[2], result[3]) print('-----------------------')
def normal_main(basic_path='tmpdata/deepwalk/normal'): n = 5 result = [] opt = options.Options() for i in range(n): save_path = os.path.join(basic_path, str(opt.begin_time), str(i)) if not os.path.exists(save_path): os.makedirs(save_path) tmp = normal_run(opt, save_path) result.append(tmp) result = np.array(result) result = np.mean(result, 0) print('-----------------------') print('average\t\taccuracy\t\tprecision\t\trecall\t\tF1') print('inferring', result[0], result[1], result[2], result[3]) print('-----------------------')
def main(args): if not os.path.exists(args.weights) or not os.path.isfile(args.weights): raise ValueError("Invalid model path: {}".format(args.weights)) opts = options.Options() model = CNN_5(opts) model.load_state_dict(torch.load(args.weights)) # Load input data os.makedirs(opts.output_dir(), exist_ok=True) train_path = opts.data_path("sign_mnist_train.csv") train_set = SignMNISTDataset(opts, train_path) visualizer = GradCamVisualizer(opts) for n_layer in range(6): visualizer.visualize(model, n_layer, train_set[0]["image"], train_set[0]["label"])
def setUp(self): self.options = options.Options() self.options.add_option('x', 'bool', None, name='x variable', help='Help Varaible', opt_short='-x', opt_long='--xx', ini_group='options', ini_name='x') self.options.add_option('tr', 'bool', True, name='def true', help='Defaults to true', opt_short='-t', opt_long='--true', ini_group='options', ini_name='true') self.options.add_option('fa', 'bool', False, name='false variable', help='Defaults to false', opt_short='-f', opt_long='--false', ini_group='options', ini_name='false') self.options.add_option('num', 'int', None, name='num none', help='Number that returns None by default', opt_short='-n', opt_long='--num', ini_group='ints', ini_name='num') self.options.add_option('num99', 'int', 99, name='num 99', help='Number that defaults to 99', opt_short=None, opt_long='--num99', ini_group='ints', ini_name='num99')
def __init__(self, domainData, master=None): # data items to display self.options = options.Options() self.data = domainData self.records = self.data.domainRecords # get default tkfont and will be used it to measure line lengths self.font = tkinter.font.Font() self.metrics = uiMetrics.UiMetrics(self.records, self.font) self.current_x = self.corner_x self.current_y = self.corner_y self.gutter = self.font.measure(" | ") self.setSize() self.createWidgets(master)