def run_desugar_task(self): self.debug('========= desugar task ========') javaargs = [Builder.get_java(self._config)] arguments = ['-jar', Builder.get_desugar()] patch_classes_cache_dir = self._finder.get_patch_classes_cache_dir() arguments.append('--input') arguments.append(patch_classes_cache_dir) arguments.append('--output') arguments.append(patch_classes_cache_dir) # bootclasspath arguments.append('--bootclasspath_entry') arguments.append(os.path.join(self._config['compile_sdk_directory'], 'android.jar')) # classpath for path in self._classpaths: arguments.append('--classpath_entry') arguments.append(path) javaargs.extend(arguments) self.debug('java exec: ' + ' '.join(javaargs)) output, err, code = cexec(javaargs, callback=None) if code != 0: raise FreelineException('desugar failed.', '{}\n{}'.format(output, err))
def setUp(self): unittest.TestCase.setUp(self) agentFactory = PoleAgentFactory() environmentFactory = PoleEnvironmentFactory() trainerFactory = PoleTrainerFactory() buildParameterFactory = PoleBuildParameterFactory() store = Store(self.dbPath) logger = MyLogger(console_print=True) self.builder = Builder(trainerFactory, agentFactory, environmentFactory, store, logger) self.buildParameters = [] for k1 in range(2): nIntervalSave = 3 nEpoch = 5 self.buildParameters.append( PoleBuildParameter(int(nIntervalSave), int(nEpoch), label="test" + str(k1))) for agentClass in ("agent002", "agent003", "agent004"): self.buildParameters.append( PoleBuildParameter(int(nIntervalSave), int(nEpoch), agentClass=agentClass, label="test " + agentClass)) self.loader = Loader(agentFactory, buildParameterFactory, environmentFactory, store)
def __init__(self, _parent=None): self.parent = _parent # Containers self.game_objects = {} self.game_doors = {} self.game_objects_np = render.attachNewNode("Game_Objects") self.game_doors_np = render.attachNewNode("Player_Doors") self.game_doors_np.setPos(0, 0, 0) self.game_counter_node = None self.game_collector_nodes = [] self.redDudesCount = 0 self.blueDudesCount = 0 # Physics world self.physics_world = None self.builder = Builder(self) # level lights self.directLight = None # Dude class self.dude = None self.spawnPoints = self.builder.spawnPoints # HUD self.hud = Hud() # Lightshow self.elapsed = 0.0
def add_module(self, ast, parent): """ Adds parsed AST to the model, without doing any optimizations. May be called more than once, with different parsed files. :param ast: AST of the input file, as returned by :func:`bkl.parser.parse_file`. """ logger.info("processing %s", ast.filename) submodules = [] b = Builder(on_submodule=lambda fn, pos: submodules.append((fn,pos))) module = b.create_model(ast, parent) while submodules: sub_filename, sub_pos = submodules[0] submodules.pop(0) try: sub_ast = parse_file(sub_filename) except IOError as e: if e.filename: msg = "%s: %s" % (e.strerror, e.filename) else: msg = e.strerror raise Error(msg, pos=sub_pos) self.add_module(sub_ast, module)
def setUp(self): unittest.TestCase.setUp(self) agentFactory = WaeAgentFactory() environmentFactory = WaeEnvironmentFactory() trainerFactory = WaeTrainerFactory() buildParameterFactory = WaeBuildParameterFactory() store = Store(self.dbPath, self.trainLogFolderPath) logger = MyLogger(console_print=True) self.builder = Builder(trainerFactory, agentFactory, environmentFactory, store, logger) self.buildParameters = [] for k1 in range(2): nIntervalSave = 10 nEpoch = 20 nLayer = int(np.random.choice((1, 2))) self.buildParameters.append( WaeBuildParameter(int(nIntervalSave), int(nEpoch), label="test" + str(k1), nLayer=nLayer, eps_given_sinkhorn=0.1, tol_sinkhorn=0.1)) self.loader = Loader(agentFactory, buildParameterFactory, environmentFactory, store)
def _clean(self): # Cleaning in Tools is done explicitly in rbuild script # and do not want it run a second time and complaining. if not utils.in_tools_tree(): if os.path.exists("setup.py"): utils.run("%s setup.py clean" % self._pycmd) Builder._clean(self)
def _clean(self): # Cleaning in Tools is done explicitly in rbuild script # and do not want it run a second time and complaining. if not 'Tools' in os.getcwd(): # i.e. in 3rdParty and Code if os.path.exists("setup.py"): utils.run("%s setup.py clean" % self._pycmd) Builder._clean(self)
def main(): b = Builder(6, 6, 1) goal = States(0, 0, 0, []) root = b.build_tree() #print(RenderTree(root)) path, path_weight = a_star(root, goal) print("Shortest path: ", path, "\nPath Weight: ", path_weight)
def __init__(self): Builder.__init__( self, { 'Id': SetAttrBuilder('id'), 'Lap': LapBuilder(), 'Creator': CreatorBuilder() })
def _install(self): # Install iocboot directories from table Builder._install(self) for ioctemplatedir, appname in self._iocbootdirsdict.iteritems(): self._install_iocboot(appname, ioctemplatedir) self._create_ioc_config() self._create_monica_config()
def __init__(self, pkgname=None): Builder.__init__(self, pkgname=pkgname, archivename=None, buildsubdir=None, buildcommand='slice2html', buildtargets=[]) ''' The constructor sets up a package build 'environment' :param pkgname: The (optional) name of the package directory. By default the current directory name is used. :param archivename: The (optional) archive name minus suffix. The default is None. :param buildsubdir: The (optional) directory in which to start the build. :param buildtargets: The (optional) additional build targets. :param buildcommand: The (optional) build command. The default is 'slice2html'. ''' self._docdir = 'doc' self.add_extra_clean_targets(self._docdir) self.parallel = False self.header = None self.footer = None # get the environment to pick up ice pth = os.path.pathsep.join( [os.environ.get('PATH'), self.dep.get_path()]) self.add_ld_library_paths(self.dep.get_ld_library_path()) self.append_env('PATH', pth)
def __init__(self,player,conf): Builder.__init__(self,player) #set the main tiles to pass by first=self.find_first_target_tile(conf['x'],conf['y']) self.add_to_path(first) last=self.find_last_target_tile(conf['x'],conf['y']) self.add_to_path(last)
def __init__(self, pkgname=None, archivename=None, buildsubdir=None, buildtargets=[], confcommand=CONFIG, buildcommand=MAKE, installcommand=INSTALL): ''' The constructor sets up a package build "environment" :param pkgname: The name of the package directory. By default the current directory name is used :param archivename: The (optional) archive name minus suffix. The default is based on package name. :param buildsubdir: The (optional) directory in which to start the build. :param buildtargets: The (optional) additional build targets. :param confcommand: The (optional) configure command. The default is 'configure'. :param buildcommand: The (optional) build command. The default is 'make'. :param installcommand: The (optional) install command. The default is 'make install'. ''' Builder.__init__(self, pkgname=pkgname, archivename=archivename, buildsubdir=buildsubdir, buildtargets=[""]+buildtargets, buildcommand=buildcommand, confcommand=confcommand, installcommand=installcommand)
def __init__(self, root): version = subprocess.check_output('git rev-list --count HEAD').decode( 'utf-8') root.title(f'Auto Disenchanter v{version}') root.protocol("WM_DELETE_WINDOW", self.on_closing) self.builder = builder = pygubu.Builder() builder.add_from_file('main_frame.ui') builder.get_object('main_frame', root) builder.connect_callbacks(self) self.builder_wrapper = Builder(builder) self.root = root self.logger = TkinterLogger(self.builder, '%H:%M:%S') self.settings = get_settings(self.logger, debug=True) self.logger.log_format = self.settings.log_time_format self.macro = Macro(self.logger, self.settings) self.incidents = Incidents(self.logger, self.settings) self.incidents.start_thread() root.resizable(False, False) root.wm_attributes("-topmost", 1) state = load_state() if state is not None and 'options' in state: self.builder_wrapper.init_checkboxes(state['options']) else: self.builder_wrapper.init_checkboxes(dict.fromkeys(OPTIONS, False)) if state is not None and 'accounts' in state: self.accounts = state['accounts'] self.builder_wrapper.set_treeview('accounts', self.accounts) else: self.accounts = []
def __init__(self, name, path, config, changed_files, module_info, is_art=False, is_other_modules_has_src_changed=False): self._name = name self._module_path = path self._config = config self._changed_files = changed_files self._module_info = module_info self._is_art = is_art self._is_other_modules_has_src_changed = is_other_modules_has_src_changed self._aapt = Builder.get_aapt() self._javac = Builder.get_javac(config=config) if self._javac is None: raise FreelineException('Please declares your JAVA_HOME to system env!', 'JAVA_HOME not found in env.') self._dx = Builder.get_dx(self._config) self._cache_dir = self._config['build_cache_dir'] self._finder = None self._res_dependencies = [] self._is_ids_changed = False self._public_xml_path = None self._ids_xml_path = None self._new_res_list = [] self._merged_xml_cache = {} self._origin_res_list = list(self._changed_files['res']) self._classpaths = [] self._is_r_file_changed = False self._is_need_javac = True self._extra_javac_args = [] self.before_execute()
def run_game(): pygame.init() pygame.mixer.init() ai_settings = Settings() screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height)) pygame.mixer.music.load('sounds/bg_music2.mp3') pygame.mixer.music.play() pygame.mixer.music.set_volume(0.5) pygame.display.set_caption("Perestroika") bracing = Bracing(screen) GlobalState() blocks = Group() tower = Tower() trucks = Group() record = None for r in Record.filter(user="******"): record = r if record is None: record = Record(user="******", score=0) record.save() GlobalState().record = record builder = Builder(screen) block = Block(bracing) block.make_static() button = Button(screen) while True: gf.check_events(bracing, blocks, tower, builder, block, trucks, button) builder.update() bracing.update() blocks.update(bracing) block.update(bracing) trucks.update() gf.update_screen(screen, bracing, blocks, builder, block, trucks, button) GlobalState().ticks += 1
def __init__(self, pkgname=None, archivename=None, buildsubdir=None, buildtargets=[], buildcommand=MAKE, confcommand="cmake", installcommand=" ".join([MAKE, "install"])): ''' The constructor sets up a package build "environment" :param pkgname: The (optional) name of the package directory. By default the current directory name is used. :param archivename: The (optional) archive name minus suffix. The default is based on package name. :param extractdir: The (optional) directory into which the archive is extracted. It is created if it does not exist. :param buildsubdir: The (optional) directory in which to start the build. :param buildtargets: The (optional) additional build targets. :param confcommand: The (optional) command to configure the package. The default is 'cmake'. :param buildcommand: The (optional) build command. The default is 'make'. :param installcommand: The (optional) install command. The default is 'make install'. ''' Builder.__init__(self, pkgname=pkgname, archivename=archivename, buildsubdir=buildsubdir, buildcommand=buildcommand, buildtargets=['']+buildtargets, confcommand=confcommand, installcommand=installcommand) self._cmakedir = 'build'
def __init__(self, pkgname, pkgversion=None, exename=None): Builder.__init__(self, pkgname=pkgname) # Needed for os.chdir in _build self._pkgversion = pkgversion self._exename = exename self._builddir = "." self.parallel = False
def __init__(self, arg): # setting self.name_map = arg.name_map self.opt = Setting() # pygame pygame.init() self.screen = pygame.display.set_mode(self.opt.WINDOW_SIZE) pygame.display.set_caption(self.opt.TITLE % self.name_map) self.clock = pygame.time.Clock() self.set_grill_surface() # data self.path = os.path.dirname(__file__) self.path_img = os.path.join(self.path, "..", "src", "img") file = self.name_map + self.opt.LUA_FORMAT self.path_maps = os.path.join(self.path, "..", "src", "maps", file) self.create = not os.path.exists(self.path_maps) # objects self.builder = Builder(self) self.converter = Converter(self) self.images = Images(self) self.map = Map(self) self.selector = Selector(self) self.toolbar = Toolbar(self) # loop self.saved = True self.loop() pygame.quit()
def load_data(storage, path, encoding="utf-8"): """ Load the csv file with main data. Parameters ---------- storage : information.Information Storage in which data from csv file will be added. path : str Path to file. encoding : str File encoding. Default utf-8. Raises ------ ValueError Incorrect data """ with open(path, "r", encoding=encoding) as data_file: builder = Builder() builder.load(storage, data_file)
def _functest(self): if os.path.exists("functests"): self._testtgt("functest") Builder._functest(self) else: print "error: missing functests subdirectory in %s" % \ os.path.relpath(self._bdir, self._askaproot)
def run(self): self.stopped = False self.status_sig.emit('Initializing...', True) from builder import Builder from config import load_config from savegbx import save_gbx from keras.models import load_model data_path = get_resource_path('data') config = load_config(os.path.join(data_path, 'config.json')) if not self.scaler: self.status_sig.emit('Loading data...', True) with open(os.path.join(data_path, config['position_scaler']), 'rb') as scaler_file: self.scaler = pickle.load(scaler_file) if self.stopped: return if not self.pattern_data: with open(os.path.join(data_path, config['pattern_data']), 'rb') as pattern_file: self.pattern_data = pickle.load(pattern_file) if self.stopped: return models_path = get_resource_path('models') if not self.builder: self.status_sig.emit('Loading models...', True) block_model = load_model( os.path.join(models_path, 'block_model_300_300.h5')) pos_model = load_model( os.path.join(models_path, 'position_model_512_512_256.h5')) self.builder = Builder(block_model, pos_model, config['lookback'], None, self.pattern_data, self.scaler, temperature=self.variety) if self.stopped: return self.status_sig.emit('Building...', False) track = self.builder.build(self.length, verbose=False, progress_callback=self.progress_callback) if track and self.save_fname: save_gbx({ 'track_data': track, 'map_name': self.map_name }, os.path.join(data_path, 'Template.Challenge.Gbx'), self.save_fname) self.status_sig.emit('Done.', False)
class BRTest(unittest.TestCase): def showMsg(self, msg): print "[%s/%s/%s] %s" % (self.testname, self.testinstance, datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), msg) def setUp(self): if os.getenv("REUSE_BUILD"): self.builddir = os.getenv("REUSE_BUILD").rstrip("/") skip_build = True else: skip_build = False b = subprocess.check_output(["mktemp", "-d", "buildroot.XXXXX"], cwd=configtest.builddir) b = b.strip() self.builddir = os.path.join(configtest.builddir, b) self.testname = self.__class__.__name__ self.testinstance = os.path.basename(self.builddir) self.buildlog = self.builddir + "-build.log" self.runlog = self.builddir + "-run.log" self.s = None self.showMsg("Starting") self.b = Builder(self.__class__.config, self.builddir, self.buildlog) if not skip_build: self.showMsg("Building") self.b.build() self.showMsg("Building done") self.s = System(self.runlog) def tearDown(self): self.showMsg("Cleaning up") if self.s: self.s.stop() if self.b and os.getenv("KEEP_BUILD"): self.b.delete()
def add_module(self, ast, parent): """ Adds parsed AST to the model, without doing any optimizations. May be called more than once, with different parsed files. :param ast: AST of the input file, as returned by :func:`bkl.parser.parse_file`. """ logger.info("processing %s", ast.filename) submodules = [] b = Builder(on_submodule=lambda fn, pos: submodules.append((fn, pos))) module = b.create_model(ast, parent) while submodules: sub_filename, sub_pos = submodules[0] submodules.pop(0) try: sub_ast = parse_file(sub_filename) except IOError as e: if e.filename: msg = "%s: %s" % (e.strerror, e.filename) else: msg = e.strerror raise Error(msg, pos=sub_pos) self.add_module(sub_ast, module)
def __init__(self, pkgname=None, archivename=None, extractdir=None, epicsbase=None, releasefile=None, srcdir=None, fileprefix=None, dbprefix=None, *args, **kwargs): Builder.__init__(self, pkgname=pkgname, archivename=archivename, extractdir=extractdir, buildcommand="", buildtargets=[""]) self.parallel = False self._appname = os.getcwd().split(os.sep)[-2] if epicsbase is None: self._epicsBuild = False self._srcdir = srcdir srcOutDir = srcdir dbOutDir = None xmlOutDir = None else: self._epicsBuild = True self._epicsbase = self.dep.get_install_path(epicsbase) self._epicsbase = self._epicsbase.rstrip(os.sep) self._srcdir = os.path.join(srcdir, 'src') comm = os.path.join(os.path.dirname(self._epicsbase), "EpicsHostArch") #self._epicsarch = utils.runcmd(comm)[0].strip() + '-debug' self._epicsarch = utils.runcmd(comm)[0].strip() srcOutDir = os.path.join(srcdir, 'src', 'O.' + self._epicsarch) dbOutDir = os.path.join(srcdir, 'Db', 'O.Common') xmlOutDir = os.path.join('install', 'epicsxml') self._adePoints = [] self._adeParser = AdbeParser(self._appname, dbprefix, fileprefix, srcOutDir, dbOutDir, xmlOutDir, *args, **kwargs)
def __init__(self, pkgname=None, archivename=None, extractdir=None, buildsubdir=None, buildtargets=[], buildcommand="ant", installcommand="ant", installsubdir=""): ''' The constructor sets up a package build "environment". :param pkgname: The (optional) name of the package directory. By default the directory name is used. :param archivename: The (optional) archive name minus suffix. The default is based on package name. :param extractdir: The (optional) directory into which the archive is extracted. It is created if it does not exist. :param buildsubdir: The (optional) directory in which to start the build. :param buildtargets: The (optional) additional build targets. :param buildcommand: The (optional) build command (default is 'ant'). :param installcommand: The (optional) install command (default is 'ant'). ''' Builder.__init__(self, pkgname=pkgname, archivename=archivename, extractdir=extractdir, buildsubdir=buildsubdir, buildcommand=buildcommand, buildtargets=[""] + buildtargets, installcommand=installcommand) self.parallel = False if installsubdir: self.installdir = os.path.join(self._prefix, installsubdir) else: self.installdir = self._prefix self._run_script = []
def main(self): # Get command line parameters self.ParseParameters() # Go load configuration information config = Configuration(self.options, self.args) config.LoadConfigurationFile() # Support for the --list qualifier if self.options.list: print "Logfile Directory:", config.GetLogfilePrefix() print "Select: ", config.GetSelectSpecification() print "Settings: ", config.currentSettings print "\n" print "%-20s %-10s %s" % ("Machine Tag", "Project", "Host Address") print "%-20s %-10s %s\n" % ("-----------", "-------", "------------") # We really prefer to list sorted by tags, so do so machines_byTag = {} for key in config.machines.keys(): machines_byTag[ config.machines[key].GetTag()] = config.machines[key] for key in sorted(machines_byTag.keys()): print "%-20s %-10s %s" % (machines_byTag[key].GetTag() + ':', machines_byTag[key].GetProject(), machines_byTag[key].GetHost()) return 0 # Go start the build process (and return resulting status) build = Builder(config) return build.StartBuild()
def main(): args = parse_options() print(args) device_type = args.type.lower() device_udid = args.udid execution_mode = args.mode.lower() config_file = args.config if device_type is None or device_type not in ["android", "ios"]: print("device type 参数指定错误; 使用 --help 命令查看详情") sys.exit(1) if device_udid is None: print("device udid 参数指定错误; 使用 --help 命令查看详情") sys.exit(1) if execution_mode is None or execution_mode not in EXECUTION_MODE: print("execution mode 参数指定错误; 使用 --help 命令查看详情") sys.exit(1) if config_file is None or FileUtils.file_available(config_file) is False: print("config file 参数指定错误; 使用 --help 命令查看详情") sys.exit(1) logger.info("config: device type is {0}".format(device_type)) logger.info("config: device udid is {0}".format(device_udid)) logger.info("config: execution mode is {0}".format(execution_mode)) logger.info("config: yaml config file is {0}".format(config_file)) builder = Builder(config_file=config_file, udid=device_udid, mode=execution_mode, device_type=device_type) builder.exe()
def __init__(self): ObjectBuilder.__init__( self, Trackpoint, { 'Time': SetAttrBuilder( 'time', lambda s: datetime.strptime(s, '%Y-%m-%dT%H:%M:%SZ')), 'Position': Builder({ 'LatitudeDegrees': SetAttrBuilder('latitude_degrees', float), 'LongitudeDegrees': SetAttrBuilder('longitude_degrees', float) }), 'AltitudeMeters': SetAttrBuilder('altitude_meters', float), 'DistanceMeters': SetAttrBuilder('distance_meters', float), 'HeartRateBpm': Builder({'Value': SetAttrBuilder('heart_rate_bpm', int)}), 'Cadence': SetAttrBuilder('cadence', int), 'SensorState': SetAttrBuilder('sensor_state', lambda s: s == 'Present') })
def handle_planet(self, planet): builder = Builder() farmer = Farmer() build_time = 0 farmer_wait_time = 0 self.api.update_planet(planet=planet) # If the mines are below a certain level, build mines. After, begin farming operations if planet.resource_buildings['metal_mine']['level'] < 9: build_time = builder.build_next_resource_or_storage_building( api=self.api, planet=planet) else: # Conduct farming operations first in case building tech is necessary. farmer_wait_time = farmer.conduct_farming_operations(api=self.api, planet=planet) self.api.update_planet(planet=planet) build_time = builder.build_next_resource_or_storage_building( api=self.api, planet=planet) if build_time == 0: build_time = builder.get_minimum_time_to_build_next_preferred_resources_building( api=self.api, planet=planet) return min(build_time, farmer_wait_time)
def __init__(self, pkgname=None): Builder.__init__(self, pkgname=pkgname, archivename=None, buildsubdir=None, buildcommand='slice2html', buildtargets=[]) ''' The constructor sets up a package build 'environment' :param pkgname: The (optional) name of the package directory. By default the current directory name is used. :param archivename: The (optional) archive name minus suffix. The default is None. :param buildsubdir: The (optional) directory in which to start the build. :param buildtargets: The (optional) additional build targets. :param buildcommand: The (optional) build command. The default is 'slice2html'. ''' self._docdir = 'doc' self.add_extra_clean_targets(self._docdir) self.parallel = False self.header = None self.footer = None # get the environment to pick up ice pth = os.path.pathsep.join([os.environ.get('PATH'), self.dep.get_path()]) self.add_ld_library_paths(self.dep.get_ld_library_path()) self.append_env('PATH', pth)
class BRTest(unittest.TestCase): def showMsg(self, msg): print "[%s/%s/%s] %s" % ( self.testname, self.testinstance, datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), msg) def setUp(self): if os.getenv("REUSE_BUILD"): self.builddir = os.getenv("REUSE_BUILD").rstrip("/") skip_build = True else: skip_build = False b = subprocess.check_output(["mktemp", "-d", "buildroot.XXXXX"], cwd=configtest.builddir) b = b.strip() self.builddir = os.path.join(configtest.builddir, b) self.testname = self.__class__.__name__ self.testinstance = os.path.basename(self.builddir) self.buildlog = self.builddir + "-build.log" self.runlog = self.builddir + "-run.log" self.s = None self.showMsg("Starting") self.b = Builder(self.__class__.config, self.builddir, self.buildlog) if not skip_build: self.showMsg("Building") self.b.build() self.showMsg("Building done") self.s = System(self.runlog) def tearDown(self): self.showMsg("Cleaning up") if self.s: self.s.stop() if self.b and os.getenv("KEEP_BUILD"): self.b.delete()
def main(): b = Builder(4, 4, 1) goal = States(0, 0, 0, []) root = b.build_tree() # print(RenderTree(root)) print("Number of shortest path from ", root.name, " to ", goal.get_situation(), " is: ", search(root, goal))
def makePopulationlist(): popobj = Builder('population.csv', 4, 'NAME') populationlist = popobj.build() for item in populationlist: popobj.skiplist.insert(item) return popobj.skiplist
def makeGrantlist(): grantobj = Builder('researchgrants.csv', 0, 'Awardee') grantlist = grantobj.build() for item in grantlist: grantobj.skiplist.insert(item) return grantobj.skiplist
def makePresidentialOrderlist(): ordersobj = Builder('presidentialdocuments.csv', 1, 'title') orderslist = ordersobj.build() for item in orderslist: ordersobj.skiplist.insert(item) return ordersobj.skiplist
class Program: def __init__(self, arg): pygame.init() self.opt = Setting() self.name_map = arg.name_map self.screen = pygame.display.set_mode((self.opt.WIDTH + self.opt.TILE_SIZE*15,self.opt.HEIGHT + self.opt.TILE_SIZE*3)) self.set_grill_surface() pygame.display.set_caption(self.opt.TITLE) self.path = os.path.dirname(__file__) self.path_img = os.path.join(self.path, ".." , "src", "img") self.images = Spritesheet(self) self.path_maps = os.path.join(self.path, ".." , "src", "maps", self.name_map + self.opt.LUA_FORMAT) self.create = not os.path.exists(self.path_maps) self.builder = Builder(self) self.clock = pygame.time.Clock() self.converter = Converter(self) self.map = Map(self) self.selector = Selector(self) self.toolbar = Toolbar(self) self.loop() pygame.quit() def set_grill_surface(self): self.grill = self.screen.copy() for y in range(0, self.opt.HEIGHT+1, self.opt.TILE_SIZE): pygame.draw.line(self.grill, (255,255,255), (0, y), (self.opt.WIDTH, y)) for x in range(0, self.opt.WIDTH+1, self.opt.TILE_SIZE): pygame.draw.line(self.grill, (255,255,255), (x, 0), (x, self.opt.HEIGHT)) self.grill.set_colorkey((0,0,0)) def draw(self): self.screen.fill((0,0,0)) self.screen.blit(self.map.screen,(0,0)) self.screen.blit(self.grill,(0,0)) self.toolbar.draw(self.screen) self.selector.draw(self.screen) pygame.display.flip() def event(self): for event in pygame.event.get(): if event.type == pygame.QUIT: self.running = False elif event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: self.pause = not self.pause elif event.key == pygame.K_s: self.builder.save() elif event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: self.selector.click() if event.button == 3: self.selector.remove() elif event.type == pygame.MOUSEMOTION: if event.buttons[0] == 1: self.selector.click() if event.buttons[2] == 1: self.selector.remove() def loop(self): self.running = True self.pause = False while self.running: self.clock.tick(50) self.converter.update() self.selector.update() self.event() self.draw()
def __init__(self, pkgname=None, archivename=None, buildsubdir=None): Builder.__init__(self, pkgname=pkgname, buildsubdir=buildsubdir, archivename=archivename) self.parallel = False self.has_extension = False self._pycmd = os.path.abspath( os.path.join(self._askaproot, 'bin', 'python'))
def question(host, args, old_graph, graph, started_time): """check to see if the build is up to date""" builder = Builder(host, args, expand_vars, started_time) nodes_to_build = builder.find_nodes_to_build(old_graph, graph) if nodes_to_build: host.print_out('pyn: build is not up to date.') return 1 else: host.print_out('pyn: no work to do.') return 0
def _install(self): Builder._install(self) # Create the install directory utils.run("mkdir -p %s" % self._installdir) self._run_copy_trees() # msi has to be first in the case we need to create jar files after # post-executing msi tool self._run_msi() self._run_jar() self._create_release_info(self._installdir)
def _clean(self): if os.path.exists(self._package): curdir = os.path.abspath(os.curdir) # Enter the untarred package directory os.chdir(self._package) if os.path.exists('Makefile'): utils.run("make clean") os.chdir(curdir) # Delete the reminder of the directories Builder._clean(self)
def _precommand(self): Builder._precommand(self) if not self._is_epics_base: self._create_releasefile() self._create_askapdefs() shutil.copy(self._releasefile, os.path.join(self._package, "configure")) if self._oldreleasefile is not None: shutil.copy(self._releasefile, os.path.join(self._package, "configure", self._oldreleasefile)) self._update_version_file()
def submit_tgts(tgts=[6, 8, 18, 26, 29, 30, 82]): builder = Builder() submittor = SubmitGenerator() for tgt in tgts: builder.tgt = ELEMENTS[tgt] builder.category = ['targets', builder.tgt.symbol] for run in range(100): builder.runnum = run add_gen_jobs(builder, submittor) submittor.run()
def __init__(self): Builder.__init__(self, { 'TotalTimeSeconds': SetAttrBuilder('total_time_seconds', float), 'DistanceMeters': SetAttrBuilder('distance_meters', float), 'MaximumSpeed': SetAttrBuilder('maximum_speed', float), 'Calories': SetAttrBuilder('calories', int), 'AverageHeartRateBpm': Builder({ 'Value': SetAttrBuilder('average_heart_rate_bpm', int)}), 'MaximumHeartRateBpm': Builder({ 'Value': SetAttrBuilder('maximum_heart_rate_bpm', int)}), 'Intensity': SetAttrBuilder('intensity'), 'TriggerMethod': SetAttrBuilder('trigger_method'), 'Track': TrackBuilder()})
def make(self): builder = Builder(self.fileName, self.type) filePath = builder.getFilePath() if ('Error' in filePath): return filePath for type,path in builder.getFilePath().iteritems(): file = open(path, 'w') file.write(builder.getTemplate(type)) file.close() return 'SUCCESS!'
def process(self): modified = 0 if not self.script: return modified builder = Builder(self.configuration) for source in builder.source_files: page = builder.get_page(source) mod_page = self.script.process(source, page) if mod_page and not self.configuration.dry_run: f = open(source, 'w') f.write(page.get_text()) f.close() modified += 1 return modified
def __init__(self, pkgname=None, archivename=None, buildsubdir=None, buildtargets=[], buildcommand='make', confcommand=None, installcommand='make install', qtdep='qt4'): Builder.__init__(self, pkgname=pkgname, archivename=archivename, buildsubdir=buildsubdir, buildcommand=buildcommand, buildtargets=[""]+buildtargets, confcommand=confcommand, installcommand=installcommand) # Set path to Qt binaries (where qmake is located) self.qtpath = self.dep.get_install_path(qtdep) self._ccom = os.path.join(self.qtpath, 'bin', 'qmake') # Add auto-generated Makefile to clean targets (prevent adding Makefile to repository) self.add_extra_clean_targets('Makefile')
def run_retrolambda(self): if self._is_retrolambda_enabled: lambda_config = self._config['retrolambda'][self._name] target_dir = self._finder.get_patch_classes_cache_dir() jar_args = [Builder.get_java(self._config), '-Dretrolambda.inputDir={}'.format(target_dir), '-Dretrolambda.outputDir={}'.format(target_dir)] if lambda_config['supportIncludeFiles']: include_files = [] classes = [] for dirpath, dirnames, files in os.walk(target_dir): for fn in files: if fn.endswith('.class'): classes.append(os.path.relpath(os.path.join(dirpath, fn), target_dir)) src_dirs = self._config['project_source_sets'][self._name]['main_src_directory'] for fpath in self._changed_files['src']: short_path = fpath.replace('.java', '.class') for src_dir in src_dirs: if src_dir in short_path: short_path = os.path.relpath(fpath, src_dir).replace('.java', '') break for clazz in classes: if short_path + '.class' in clazz or short_path + '$' in clazz or 'R.class' in clazz \ or 'R$' in clazz or short_path + '_' in clazz: include_file = os.path.join(target_dir, clazz) if os.path.exists(include_file): self.debug('incremental build lambda file: {}'.format(include_file)) include_files.append(include_file) include_files_param = os.pathsep.join(include_files) if len(include_files_param) > 3496: include_files_path = os.path.join(self._cache_dir, self._name, 'retrolambda_inc.list') self.__save_parms_to_file(include_files_path, include_files) jar_args.append('-Dretrolambda.includedFile={}'.format(include_files_path)) else: jar_args.append('-Dretrolambda.includedFiles={}'.format(include_files_param)) lambda_classpaths = [target_dir, lambda_config['rtJar']] lambda_classpaths.extend(self._classpaths) param = os.pathsep.join(lambda_classpaths) if lambda_config['supportIncludeFiles'] and len(param) > 3496: classpath_file = os.path.join(self._cache_dir, self._name, 'retrolambda_classpaths.path') self.__save_parms_to_file(classpath_file, lambda_classpaths) jar_args.append('-Dretrolambda.classpathFile={}'.format(classpath_file)) else: jar_args.append('-Dretrolambda.classpath={}'.format(param)) jar_args.append('-cp') jar_args.append(lambda_config['targetJar']) jar_args.append(lambda_config['mainClass']) self.debug('retrolambda exec: ' + ' '.join(jar_args)) output, err, code = cexec(jar_args, callback=None) if code != 0: raise FreelineException('retrolambda compile failed.', '{}\n{}'.format(output, err))
def __make_new_builder(self, building_id, x, y, needs_collector, orientation): """Return a Builder object if it is allowed to be built at the location, otherwise return None (not cached).""" coords = (x, y) if building_id == BUILDINGS.CLAY_PIT_CLASS or building_id == BUILDINGS.IRON_MINE_CLASS: # clay deposits and mountains are outside the production plan until they are constructed if coords in self.plan or coords not in self.settlement.ground_map: return None else: if coords not in self.plan or self.plan[coords][0] != BUILDING_PURPOSE.NONE or coords not in self.settlement.ground_map: return None builder = Builder.create(building_id, self.land_manager, Point(x, y), orientation=orientation) if not builder or not self.land_manager.legal_for_production(builder.position): return None if building_id == BUILDINGS.FISHERMAN_CLASS or building_id == BUILDINGS.BOATBUILDER_CLASS: for coords in builder.position.tuple_iter(): if coords in self.plan and self.plan[coords][0] != BUILDING_PURPOSE.NONE: return None elif building_id != BUILDINGS.CLAY_PIT_CLASS and building_id != BUILDINGS.IRON_MINE_CLASS: # clay deposits and mountains are outside the production plan until they are constructed for coords in builder.position.tuple_iter(): if coords not in self.plan or self.plan[coords][0] != BUILDING_PURPOSE.NONE: return None if needs_collector and not any(True for building in self.collector_buildings if building.position.distance(builder.position) <= building.radius): return None return builder
def __init__(self, metapkgname=None, datadir=None, msibasedir=None, jarbasedir=None): ## The constructor sets up a package build "environment" # @param self The current object. # @param metapkgname The name of the meta-package directory. By default the # current directory name is used (basename of current directory). # @param datadir The base directory name to be copied recursively in install dir, i.e. every file and # subdirectory will be copied recursively into install directory. Defaults to "files/data". # @param msibasedir The base directory name of the msi template/substitutions files and subdirectories. # It is pre-pended to every input directory entered in add_msi_template() and add_msi_template_dir() calls. # Defaults to "files/msi". # @param jarbasedir The base directory name of the jar configuration directories. It is pre-pended to # input directories entered in the add_config_jar_dir() method. Builder.__init__(self, pkgname='.') self._quiet = False if '-q' in self._comopts or '--quiet' in self._comopts: self._quiet = True self._versionstr = str(utils.get_svn_branch_info()) self._metapkgname = metapkgname or os.path.basename(os.path.abspath(os.curdir)) self._datadir = datadir or os.path.join('files', 'data') # List of directories that needs to be copied to installdir self._datatrees = [] if os.path.exists(self._datadir): self._datatrees.append(self._datadir) # List of jar command and outputdir that needs to be executed self._jar_cmdlist = [] self._jarcmd = 'jar cvf' self._jarbasedir = jarbasedir or os.path.join('files', 'jar') # List of msi commands and outputdir that needs to be executed self._msibasedir = msibasedir or os.path.join('files', 'msi') self._msi_cmdlist = [] # Check that msi tool is in the dependencies try: msipath = self.dep.get_install_path('msi') self._msi_in_dep = True except: msipath = '' self._msi_in_dep = False ea = self.dep.get_env().get('EPICS_HOST_ARCH', None) if ea is None: print "Couldn't determine EPICS architecture" sys.exit(1) os.environ['EPICS_HOST_ARCH'] = ea self.epics_host_arch = ea self._msicmd = '' if self._msi_in_dep: self._msicmd = os.path.join(msipath, 'bin', ea, 'msi')
def __init__(self, manager=FileManager, context={}, config={}, compress=False, debug=False, optimize=False): self.context = Context(true=True, false=False) self.context.update(context) self.config = config self.manager = manager() if callable(manager) else manager self.compress = compress self.builder = Builder(debug, optimize)
def __init__(self, src_dir, dest_dir): # Init super super(ObserverHandler, self).__init__() # Cache values self.src_dir = src_dir self.dest_dir = dest_dir # New builder & local syncer self.builder = Builder(self.src_dir, self.dest_dir, LocalSyncer()) self.builder.build()