def run_optimized(): if __debug__: # start subprocess subp_args = [str(sys.executable), "-O", str(__file__)] for arg in sys.argv[1:]: subp_args.append(arg) #subprocess.Popen(subp_args) subprocess.call(subp_args) else: # running optimized # import the game from lib import main main()
def run_debug(): # running in debug mode if u"-profile" in sys.argv: import cProfile import tempfile import os profile_data_fname = "t.profile" #tempfile.mktemp("prf") try: cProfile.run('main.main()', profile_data_fname) finally: pass else: main()
def call_main(keys): for key in keys: return lib.main({ 'bucket': cos_bucket_name(), 'cosApiKey': cos_api_key(), 'cosInstanceId': cos_instance_id(), 'logdnaKey': logdna_key(), 'logdnaIngestionEndpoint': logdna_ingestion_endpoint(), 'endpoint': cos_endpoint(), 'key': key, })
from lib import main main()
def main(params): lib.main(params) return lib.main(params)
reading("tx_packets", parts[10]) reading("rx_errors", parts[3]) reading("tx_errors", parts[11]) break if not found: alert("iface_missing", { "interface": interface }) elif os.path.exists("/sys/class/net/"): alert("iface_missing", { "interface": interface }) else: alert("check_failed", { "message": "No known method of retrieving interface statistics available on this host.", }) def check(): if "USE_SNMP" in os.environ and os.environ["USE_SNMP"] == "1": snmp_main() else: local_main() if __name__ == "__main__": main(check)
#!/usr/bin/env python3 import lib def process_genesis(genesis, parsed_args): genesis['app_state']['bank']['send_enabled'] = False return genesis if __name__ == '__main__': parser = lib.init_default_argument_parser( prog_desc='Migrate genesis.json to disable send txs', default_chain_id='betanet-1', default_start_time='2019-02-11T12:00:00Z', ) lib.main(parser, process_genesis)
import sys import lib if __name__ == "__main__": print('Launcher') lib.main()
import lib import sys if __name__ == "__main__": lib.main(*sys.argv[1:])
elif symbol == key.M: vector = self.get_sight_vector() block = self.model.hit_test(self.position, vector)[0] if block: self.model.move_block(block) def on_key_release(self, symbol, modifiers): """ Called when the player releases a key. See pyglet docs for key mappings. Parameters ---------- symbol : int Number representing the key that was pressed. modifiers : int Number representing any modifying keys that were pressed. """ if symbol == key.W: self.strafe[0] += 1 elif symbol == key.S: self.strafe[0] -= 1 elif symbol == key.A: self.strafe[1] += 1 elif symbol == key.D: self.strafe[1] -= 1 if __name__ == "__main__": lib3d.main(Window())
parser = OptionParser(usage, version='%prog ' + __version__) parser.add_option("-p", dest="publishing_target", type="choice", choices=["mode", "ditaot"], default="mode", help="Publishing Target: mode|ditaot, [default: %default]") parser.add_option("-l", "--loglevel", type="int", default=30, help="Log Level (debug=10, info=20, warning=30, [error=40], critical=50)") (options, args) = parser.parse_args() if len(args) < 1: parser.print_help() parser.error("Please supply the path to the XML content") if options.loglevel: logger.basicConfig(level=options.loglevel) rename(args[0],options.publishing_target) if __name__ == '__main__': sys.exit(main()) ###################################### # Test code ###################################### class TestFileRenamer(unittest.TestCase): def test_i_can_return_a_files_new_mode_name(self): fr = FileRenamer(xmlparser=StubXmlParser(),publishing_target="mode") newfile = fr.rename("hello.xml") self.assertTrue(newfile == "hello=GUID-BED8A733-2ED7-31AD-A911-C1F4707C67F=1=en=.reference") def test_i_can_return_a_ditamaps_new_mode_name(self,publishing_target="mode"): fr = FileRenamer(xmlparser=StubXmlParser()) newfile = fr.rename("hello.ditamap") self.assertTrue(newfile == "hello=GUID-BED8A733-2ED7-31AD-A911-C1F4707C67F=1=en=.ditamap")
from pathlib import Path from lib import main # Google Spreadsheet main ID SPREADSHEET_ID = '1VZ96Jn-JBhZ0C6ew89t3MPjiSMi6mcivlkz25AhDIDY' # Intrernal sheet ID SHEET_ID = '634064076' IN_URL = f'https://docs.google.com/spreadsheets/d/{SPREADSHEET_ID}/export?format=csv&id={SPREADSHEET_ID}&gid={SHEET_ID}' THIS_YEAR = 2022 JSON_OUT_FILE = Path(__file__).absolute( ).parent.parent / 'databags' / f'events-{str(THIS_YEAR)}.json' CSV_OUT_FILE = Path(__file__).absolute( ).parent.parent / 'Datasets' / f'Events {str(THIS_YEAR)}.csv' REPORTS_DIR = Path(__file__).absolute( ).parent.parent / 'content' / 'events' / str(THIS_YEAR) / 'reports' IMAGES_DIR = Path( __file__).absolute().parent.parent / 'assets' / 'images' / str(THIS_YEAR) if __name__ == '__main__': try: main(IN_URL, THIS_YEAR, JSON_OUT_FILE, CSV_OUT_FILE, REPORTS_DIR, IMAGES_DIR) except Exception as e: print('❌') print(str(e)) raise e
import lib def control(init, updates): """Control the robot.""" lib.send_command(None, "set-speed 200 set-rotation-speed 30") for update in updates: if random.random() < 0.01: lib.send_command(update, "set-speed %d set-rotation-speed %d" % (random.randrange(-150, 150), random.randrange(-100, 100))) my_robot = update["robots"]["me"] other_robots = update["robots"]["others"] if not other_robots: break if my_robot["time_to_fire"] or my_robot["turret_rotation"]: lib.send_command(update) continue other_robot = other_robots[0] # Fire a bullet to the other robot diff_x = other_robot["x"] - my_robot["x"] diff_y = other_robot["y"] - my_robot["y"] angle = (-math.atan(diff_y / diff_x) if abs(diff_x) > 0.0001 else math.pi / 2.0) angle2 = (angle * 180.0 / math.pi) + \ (180.0 if other_robot["x"] < my_robot["x"] else 0.0) #angle3 = angle2 + random.randrange(-10, 10) lib.send_command(update, "rotate-turret-to-angle-and-fire %d" % angle2) if __name__ == '__main__': sys.exit(lib.main(sys.argv[1:], control))
self.addTrigger(lirc, 'Hauppauge6400.VDR' + vdrKey, lgtv.send, 'mutescreen:off') self.addTrigger(lirc, 'Receiver12V.0', lgtv.standby) self.addTrigger(lirc, 'Receiver12V.1', lgtv.poweron) self.addTrigger(lirc, 'Hauppauge6400.Power2', lgtv.mutescreen, 'Power2', yamaha) self.addTrigger(lirc, 'Receiver12V.2', lgtv.send, 'input:HDMI2') self.addTrigger(lirc, 'Receiver12V.3', lgtv.send, 'input:HDMI2') self.addTrigger(lirc, 'Receiver12V.4', lgtv.send, 'input:Component') self.addTrigger(lirc, 'Receiver12V.5', lgtv.send, 'input:DTV') self.addTrigger(lirc, 'Receiver12V.6', pioneer.poweron, yamaha) self.addTrigger(lirc, 'Receiver12V.7', pioneer.standby) self.addTrigger(lirc, 'XoroDVD.PlayPause', pioneer.play) self.addTrigger(lirc, 'XoroDVD.Angle', pioneer.send, 'ST') self.addTrigger(lirc, 'XoroDVD.Left', pioneer.send, '/A187FFFF/RU') self.addTrigger(lirc, 'XoroDVD.Right', pioneer.send, '/A186FFFF/RU') self.addTrigger(lirc, 'XoroDVD.Up', pioneer.send, '/A184FFFF/RU') self.addTrigger(lirc, 'XoroDVD.Down', pioneer.send, '/A185FFFF/RU') self.addTrigger(lirc, 'XoroDVD.Enter', pioneer.send, '/A181AFEF/RU') self.addTrigger(lirc, 'XoroDVD.Forward', pioneer.send, 'NF') self.addTrigger(lirc, 'XoroDVD.Rewind', pioneer.send, 'NR') self.addTrigger(lirc, 'XoroDVD.FastForward', pioneer.send, '/A181AF3D/RU') self.addTrigger(lirc, 'XoroDVD.FastRew', pioneer.send, '/A181AF3E/RU') self.addTrigger(lirc, 'XoroDVD.Eject', pioneer.send, 'OP') self.addRepeatableTrigger(lirc, 'AcerP1165.Zoom', self.kodi, vdr) self.addRepeatableTrigger(lirc, 'AcerP1165.Source', lgtv.aspect, ('scan', '4:3', '14:9')) MorningAction(self, vdr, yamaha) # do not change this: main(MyHal)
hyperparam("scheduler.params.num_warmup_steps", 2000), hyperparam("scheduler.params.num_training_steps", max_update), hyperparam("optimizer.type", "adam_w", save_dir_key=lambda val: val), hyperparam("optimizer.params.lr", [5e-5, 1e-5], save_dir_key=lambda val: f"lr{val}"), hyperparam("optimizer.params.eps", 1e-8), hyperparam("training.max_updates", max_update, save_dir_key=lambda val: f"mu{val}"), hyperparam("training.log_format", "json"), hyperparam("training.pin_memory", True), hyperparam("training.log_interval", 1000), hyperparam("training.checkpoint_interval", 1000), hyperparam("training.evaluation_interval", 4000), hyperparam("training.find_unused_parameters", True), hyperparam( "model_config.visual_bert.freeze_base", [False], save_dir_key=lambda val: f"fb{val}", ), ] def postprocess_hyperparams(args, config): """Postprocess a given hyperparameter configuration.""" pass if __name__ == "__main__": sweep.main(get_grid, postprocess_hyperparams)
nhid = 200 # the dimension of the feedforward network model in nn.TransformerEncoder nlayers = 2 # the number of nn.TransformerEncoderLayer in nn.TransformerEncoder nhead = 2 # the number of heads in the multiheadattention models dropout = 0.2 # the dropout value model = TransformerModel(ntokens, emsize, nhead, nhid, nlayers, device, fasttext_model_path="/home/ubuntu/fil9.bin", itos=TEXT.vocab.itos, dropout=dropout).to(device) NO_TRAIN = False #MODEL_PATH='./data/transformer-fasttext-subword-attention.ckpt' # test loss 5.56 | test ppl 260.43 #MODEL_PATH='./data/transformer-fasttext-subword-attention-canonical.ckpt' MODEL_PATH = './data/transformer-fasttext-subword-attention-wikitext103.ckpt' #MODEL_PATH='./data/transformer-fasttext-dropout-big-subword-attention.ckpt' lib.main(device, model, TEXT, train_iter, val_iter, test_iter, MODEL_PATH, NO_TRAIN, epochs=15, no_text_transfer=True)
+ " The slow tests involve e.g. disk access and shell commands.") ( options, args ) = parser.parse_args() if options.test_slow: return test.test_all.test_slow() elif options.test_quick: return test.test_all.test_quick() elif options.test: return test.test_all.test_medium() if len( args ) != 2: parser.error( "You must supply 2 files to compare." ) if options.view == "list": return lib.main.emulate_diff_minus_y( args[0], args[1] ) elif options.view == "term": return lib.main.interactive_diff_ncurses( args[0], args[1], options.sendkeys ) elif options.view == "gtk": sys.stderr.write( "GTK UI not yet supported!\n" ) sys.exit( 1 ) else: sys.stderr.write( "Unknown view '%s'.\n" % options.view ) sys.exit( 2 ) if __name__ == "__main__": main()
from pathlib import Path from lib import main IN_URL = 'https://docs.google.com/spreadsheets/d/17MemnXoshf1cd6_S4l23uyOQxfEI6m-sXZNrDnNhFc8/export?format=csv&id=17MemnXoshf1cd6_S4l23uyOQxfEI6m-sXZNrDnNhFc8&gid=1679616011' JSON_OUT_FILE = Path( __file__).absolute().parent.parent / 'databags' / 'events-2021.json' CSV_OUT_FILE = Path( __file__).absolute().parent.parent / 'Datasets' / 'Events 2021.csv' THIS_YEAR = 2021 if __name__ == '__main__': try: main(IN_URL, JSON_OUT_FILE, CSV_OUT_FILE, THIS_YEAR) except Exception as e: print('❌') print(str(e)) raise e