def register(self, name, *args, **kwargs): """Register a bundle with the given name. There are two possible ways to call this: - With a single ``Bundle`` instance argument: register('jquery', jquery_bundle) - With one or multiple arguments, automatically creating a new bundle inline: register('all.js', jquery_bundle, 'common.js', output='packed.js') """ if len(args) == 0: raise TypeError('at least two arguments are required') else: if len(args) == 1 and not kwargs and isinstance(args[0], Bundle): bundle = args[0] else: bundle = Bundle(*args, **kwargs) if name in self._named_bundles: if self._named_bundles[name] == bundle: pass # ignore else: raise RegisterError( 'Another bundle is already registered ' + 'as "%s": %s' % (name, self._named_bundles[name])) else: self._named_bundles[name] = bundle bundle.env = self # take ownership return bundle
def dumps(self): out = str(self) for tid in self.global_history.buckets: hit_list = self.global_history.buckets[tid].head bundle = Bundle() prev = None while hit_list != None: print("[", hit_list.value.ns, "] [", hit_list.value.tid, "]", hit_list.value.name) if prev != None: # for testing purposes, ensure this is true assert prev.ns < hit_list.value.ns prev = hit_list.value bundle.push(hit_list.value) hit_list = hit_list.next out += str(bundle) if self.file: try: with open(self.file, "w") as fd: fd.write(out) except IOError as e: print(e) print(out) else: print(out)
def test_bundle_serie_of_should_build_max_bundles(): bundler = bundle_series_of(references=['A', 'B']) result_bundles = list( bundler( cart(item(reference='A', quantity=3), item(reference='B', quantity=2)))) assert result_bundles == [Bundle(size=2)] * 2 + [Bundle(size=1)]
def register(self, name, *args, **kwargs): """Register a bundle with the given name. There are two possible ways to call this: - With a single ``Bundle`` instance argument: register('jquery', jquery_bundle) - With one or multiple arguments, automatically creating a new bundle inline: register('all.js', jquery_bundle, 'common.js', output='packed.js') """ if len(args) == 0: raise TypeError("at least two arguments are required") else: if len(args) == 1 and not kwargs and isinstance(args[0], Bundle): bundle = args[0] else: bundle = Bundle(*args, **kwargs) if name in self._named_bundles: if self._named_bundles[name] == bundle: pass # ignore else: raise RegisterError( "Another bundle is already registered " + 'as "%s": %s' % (name, self._named_bundles[name]) ) else: self._named_bundles[name] = bundle bundle.env = self # take ownership return bundle
def main(): i = Invoice() data = i.get_processed_data() b = Bundle() # Create separate files split by sender IBAN for send_iban in settings.SENDER_IBAN: content = b.generate(data, send_iban) b.save_to_disk(send_iban, content)
def addTrxnTransfer(self, workTangle, sendNode, recNode, transAmount=5): tips = workTangle.find_tips() tipObjs = [] for tip in tips: tipObjs.append(workTangle.bundleObjects.get(tip)) value_bundle = Bundle(workTangle.find_tips(), tipObjs, sendNode) # add value transition in Bundle value_bundle.add_value_tx(sendNode, recNode, transAmount) workTangle.add_tx(value_bundle)
def get_bundles_from(yml): bundles = list() for bundle in yml.get('roles', list()): b = Bundle('role', bundle) bundles.append(b) for bundle in yml.get('dependencies', list()): if bundle.get('role', None): b = Bundle('role', bundle) bundles.append(b) return bundles
def addTrxn(self, workTangle, workNode): tips = workTangle.find_tips() tipObjs = [] for tip in tips: tipObjs.append(workTangle.bundleObjects.get(tip)) genBundle = Bundle(tips, tipObjs, workNode) # Generate basic bundle metaTrxn = Trxn(genBundle) genBundle.addTrxn(metaTrxn) # Add non-value trxn workTangle.add_tx( genBundle) # Record bundle with transaction in tangle and do PoW
def upload_openmrs_bundle(self, each_bundle: bundle.Bundle, locations: Dict[str, str]): """Uploads FHIR Bundle to OpenMRS via Patients, Encounters, Observations. As the OpenMRS FHIR Module does not support uploading Bundle transactions, the Bundle is uploaded in 3 steps. First the Patient resource is uploaded, then the encounters, then the observations. Before uploading each resource, we have to manipulate the JSON for that resource into a form OpenMRS will accept. As OpenMRS does not support PUT requests, each time we POST a resource, a new ID for that resource is generated. This means we need to track the new id for each resource. Some resources depend on the other resources' new id. For example, before POSTing Encounter resource, we need to update it with the new Patient id generated by OpenMRS for the Encounter upload to work. Args: each_bundle: a Bundle object locations: dictionary of location_id/location_name """ try: each_bundle.extract_resources() self.logger.info('Uploading %s' % each_bundle.file_name) each_bundle.openmrs_patient.openmrs_convert() each_bundle.openmrs_patient.base.new_id = self._upload_resource( resource='Patient', data=each_bundle.openmrs_patient.base.json) self.logger.debug('New Patient ID is %s' % each_bundle.openmrs_patient.base.new_id) for openmrs_encounter in each_bundle.openmrs_encounters: location = random.choice(list(locations.items())) openmrs_encounter.openmrs_convert( each_bundle.openmrs_patient.base.new_id, location) openmrs_encounter.base.new_id = self._upload_resource( resource='Encounter', data=openmrs_encounter.base.json) for openmrs_observation in each_bundle.openmrs_observations: openmrs_observation.openmrs_convert( each_bundle.openmrs_patient.base.new_id, each_bundle.openmrs_encounters) openmrs_observation.new_id = self._upload_resource( resource='Observation', data=openmrs_observation.base.json) self.logger.info('Successfully uploaded %s' % each_bundle.file_name) each_bundle.save_mapping() except ValueError: self.logger.error('Error uploading %s.\n%s' % (each_bundle.file_name, traceback.format_exc()))
def register(self, name, *args, **kwargs): """Register a :class:`Bundle` with the given ``name``. This can be called in multiple ways: - With a single :class:`Bundle` instance:: env.register('jquery', jquery_bundle) - With a dictionary, registering multiple bundles at once: bundles = {'js': js_bundle, 'css': css_bundle} env.register(bundles) .. note:: This is a convenient way to use a :doc:`loader <loaders>`: env.register(YAMLLoader('assets.yaml').load_bundles()) - With many arguments, creating a new bundle on the fly:: env.register('all_js', jquery_bundle, 'common.js', filters='rjsmin', output='packed.js') """ # Register a dict if isinstance(name, dict) and not args and not kwargs: for name, bundle in name.items(): self.register(name, bundle) return if len(args) == 0: raise TypeError("at least two arguments are required") else: if len(args) == 1 and not kwargs and isinstance(args[0], Bundle): bundle = args[0] else: bundle = Bundle(*args, **kwargs) if name in self._named_bundles: if self._named_bundles[name] == bundle: pass # ignore else: raise RegisterError( "Another bundle is already registered " + 'as "%s": %s' % (name, self._named_bundles[name]) ) else: self._named_bundles[name] = bundle bundle.env = self # take ownership return bundle
def register(self, name, *args, **kwargs): """Register a :class:`Bundle` with the given ``name``. This can be called in multiple ways: - With a single :class:`Bundle` instance:: env.register('jquery', jquery_bundle) - With a dictionary, registering multiple bundles at once: bundles = {'js': js_bundle, 'css': css_bundle} env.register(bundles) .. note:: This is a convenient way to use a :doc:`loader <loaders>`: env.register(YAMLLoader('assets.yaml').load_bundles()) - With many arguments, creating a new bundle on the fly:: env.register('all_js', jquery_bundle, 'common.js', filters='rjsmin', output='packed.js') """ # Register a dict if isinstance(name, dict) and not args and not kwargs: for name, bundle in name.items(): self.register(name, bundle) return if len(args) == 0: raise TypeError('at least two arguments are required') else: if len(args) == 1 and not kwargs and isinstance(args[0], Bundle): bundle = args[0] else: bundle = Bundle(*args, **kwargs) if name in self._named_bundles: if self._named_bundles[name] == bundle: pass # ignore else: raise RegisterError( 'Another bundle is already registered ' + 'as "%s": %s' % (name, self._named_bundles[name])) else: self._named_bundles[name] = bundle bundle.env = self # take ownership return bundle
def load_bundles(self): """Load the user's bundles.""" path = os.path.join(self.user_directory, "bundles") for name in os.listdir(path): if not name.startswith("__") and os.path.isdir(path + "/" + name): bundle = Bundle(self, name) self.bundles[name] = bundle for bundle in self.bundles.values(): bundle.setup(self, self.loader) for model in self.models: type(model).extend(model) for model in self.models: self.data_connector.repository_manager.add_model(model)
def add_tx(self,bundle: Bundle): if bundle.branch in self.tGraph and bundle.trunk in self.tGraph: if bundle.trxns[0].value != 0: if self.check_value_tx(bundle): self.move_money(bundle) logHash = bundle.get_hash() self.tGraph[logHash] = [bundle.branch, bundle.trunk] self.tData[logHash] = {'data_payload': bundle.data_payload, 'value_payloafdd': bundle.outputTrxn.value} self.tValues[logHash] = bundle.data_payload else: logHash = bundle.get_hash() self.tGraph[logHash] = [bundle.branch, bundle.trunk] self.tData[logHash] = bundle.data_payload self.bundleObjects[logHash] = bundle
def process(filename, rtypes=None): if not rtypes: rtypes = ['requiredBrushFile'] def process_kpp(kpp, bundle=None): links = kpp.get_links() for name, value in links.iteritems(): if bundle is not None: if name not in rtypes: continue if name == 'requiredBrushFile': ok = bundle.find_brush(value) if ok: print( "required brush file {} found in the same bundle.". format(value)) continue if not value: continue print(u"{}: {}".format(name, value).encode('utf-8')) if filename.endswith(".bundle"): bundle = Bundle.open(filename) presets = bundle.presets_data else: bundle = None presets = [KPP(filename)] for preset in presets: process_kpp(preset, bundle)
def get_watchkit_paths(root_bundle_path): """ collect sub-bundles of this bundle that have watchkit """ # typical structure: # # app_bundle # ... # some_directory # watchkit_extension <-- this is the watchkit bundle # Info.plist # watchkit_bundle <-- this is the part that runs on the Watch # Info.plist <-- WKWatchKitApp=True # watchkit_paths = [] for path, _, _ in os.walk(root_bundle_path): if path == root_bundle_path: continue try: bundle = Bundle(path) except NotMatched: # this directory is not a bundle continue if bundle.info.get('WKWatchKitApp') is True: # get the *containing* bundle watchkit_paths.append(dirname(path)) return watchkit_paths
def process(filename, rtypes=None): if not rtypes: rtypes = ['requiredBrushFile'] def process_kpp(kpp, bundle=None): links = kpp.get_links() for name, value in links.iteritems(): if bundle is not None: if name not in rtypes: continue if name == 'requiredBrushFile': ok = bundle.find_brush(value) if ok: print("required brush file {} found in the same bundle.".format(value)) continue if not value: continue print(u"{}: {}".format(name, value).encode('utf-8')) if filename.endswith(".bundle"): bundle = Bundle.open(filename) presets = bundle.presets_data else: bundle = None presets = [KPP(filename)] for preset in presets: process_kpp(preset, bundle)
def view(): logger = Logger(mongo) global bundle bundle = Bundle(mongo) if current_user.ID != admin_id: flash(f'This account is not authorised to view logs!','danger') return redirect(url_for('log')) else: form = ViewForm() if request.method == 'POST': log_list = logger.get_log(form.i_field.data, form.b_field.data, form.p_field.data) user_json = logger.get_user(form.i_field.data) if user_json: user = User(user_json) if log_list == []: return render_template('view.html', form=form, no_log="Currently no existing Logs to view", user=user) else: return render_template('view.html', form=form, log_list=log_list, user=user) else: flash(f'User does not Exist!','danger') return redirect(url_for('view')) return render_template('view.html', form=form)
def register(name, *args, **kwargs): """Register a bundle with the given name. There are two possible ways to call this: - With a single ``Bundle`` instance argument: register('jquery', jquery_bundle) - With one or multiple arguments, automatically creating a new bundle inline: register('all.js', jquery_bundle, 'common.js', output='packed.js') """ if len(args) == 0: raise TypeError('at least two arguments are required') else: if len(args) == 1 and not kwargs and isinstance(args[0], Bundle): bundle = args[0] else: bundle = Bundle(*args, **kwargs) global _REGISTRY if name in _REGISTRY: if _REGISTRY[name] == bundle: pass # ignore else: raise RegistryError('Another bundle is already registered '+ 'as "%s": %s' % (name, _REGISTRY[name])) else: _REGISTRY[name] = bundle
def _process_requests(self): if self.mode != Server.Modes.PROCESSING: raise ValueError(f"not ready to process: in state {self.mode}") elif self._bundles: raise ValueError("bundles already exist; can't process") self._bundles = [Bundle() for _ in range(self.SERVER_COUNT)] rsa_priv_keys = [k.export_key() for k in self._keys] # sequentially process up prev_up = list(self._id_map.values()) # initial is direct from client: final is terminal's decrypted for b, pk in zip(self._bundles, rsa_priv_keys): b.load_up(prev_up) prev_up = b.send_up(pk) terminal_raws = prev_up prev_down = self._terminal_process(terminal_raws) for b in reversed(self._bundles): # go in the opposite direction now b.load_down(prev_down) prev_down = b.send_down() self._responses = {id: resp for id, resp in zip(self._id_map.keys(), prev_down)} self.mode = Server.Modes.DISTRIBUTING
def __init__(self): # One trxn with a bundle to start as genesis, random selection with replacement allows for growing tangle # ==> URTS # TGraph key {key: [trnxObject]} self.genBundle = Bundle(None,None, None) # Setup genesis Bundle self.genBundle.addTrxn(self.genBundle) self.tGraph = {'genesis_trxn': [None]} self.bundleObjects = {'genesis_trxn': self.genBundle} # No data to start self.tData = {} # Five nodes for example self.tLedger = {} self.netNodes = [] self.tValues = {}
def process(filename): if filename.endswith(".bundle"): bundle = Bundle.open(filename) presets = bundle.presets_data else: presets = [KPP(filename)] result = [] for kpp in presets: result.extend(process_kpp(kpp)) return result
def __init__(self): super(App, self).__init__() self.bundle = Bundle() self.app = urwid.MainLoop( self.bundle.output, unhandled_input=self.bundle.globle_input_listener) self.signal_flash = True self.app.set_alarm_in(1, self.update_datetime) self.app.set_alarm_in(0.5, self.post_list_status_tracker) self.app.run()
def wildcard_bundle(): return Bundle( '*.common.name', 'e8a7fcfbe48df21daede665d78984dec', KEY, CSR, CRT, '0000000', expiry=EXPIRY, authority=dict(digicert=dict(order_id=1298368)), timestamp=TIMESTAMP)
def execute(self, **kwargs): status = 202 bundle_name_pns = [self.sanitize(bundle_name_pn) for bundle_name_pn in self.args.bundle_name_pns] bundles = Bundle.bundles(bundle_name_pns) blacklist.check(bundles, self.args.blacklist_overrides) bundles = self.authority.revoke_certificates( bundles, self.args.bug) for bundle in bundles: bundle.expiry = Bundle.timestamp bundle.to_disk() json = self.transform(bundles) return json, status
class ViewForm(FlaskForm): b_field = SelectField("Bundle: ", choices=Bundle(Mongo()).get_bundle_names(), default=1) p_field = SelectField("Project: ", choices=[("Project", "Project")], default=1) i_field = SelectField("ID: ", choices=[("ID", "ID")], default=1) submit = SubmitField('Submit')
def execute(self): status = 201 modhash, key, csr = pki.create_modhash_key_and_csr( self.args.common_name, public_exponent=CFG.key.public_exponent, key_size=CFG.key.key_size, key=self.args.key, csr=self.args.csr, oids=self.cfg.csr.oids, sans=self.args.sans) crt, expiry, authority = self.authority.create_certificate( self.args.organization_name, self.args.common_name, self.args.validity_years, csr, self.args.bug, sans=sorted(list(self.args.sans)), repeat_delta=self.args.repeat_delta, whois_check=self.args.whois_check) bundle = Bundle( self.args.common_name, modhash, key, csr, crt, self.args.bug, sans=sorted(list(self.args.sans)), expiry=expiry, authority=authority) bundle.to_disk() if self.args.destinations: note = 'bug ' + self.args.bug for name, dests in self.args.destinations.items(): bundle = self.destinations[name].install_certificates(note, [bundle], dests)[0] json = self.transform([bundle]) return json, status
def test_json_roundtrip(bundle): json = bundle.to_obj() common_name, modhash, key, csr, crt, bug, sans, expiry, authority, destinations, timestamp = Bundle.from_obj(json) bundle2 = Bundle( common_name, modhash, key, csr, crt, bug, sans=sans, expiry=expiry, authority=authority, destinations=destinations, timestamp=timestamp) assert bundle == bundle2
def find_used(bundle_path): def process_kpp(kpp): links = kpp.get_links() requiredBrushFile = links.get('requiredBrushFile', None) if requiredBrushFile: return [requiredBrushFile] else: return [] bundle = Bundle.open(bundle_path) presets = bundle.presets_data used = [] for kpp in presets: used.extend(process_kpp(kpp)) result = [brush for brush in used if not bundle.find_brush(brush)] return set(result)
def execute(self, **kwargs): status = 201 bundle_name_pns = [ self.sanitize(bundle_name_pn) for bundle_name_pn in self.args.bundle_name_pns ] bundles = Bundle.bundles(bundle_name_pns) blacklist.check(bundles, self.args.blacklist_overrides) authority = self.args.get('authority', None) destinations = self.args.get('destinations', None) if authority == None and destinations == None: raise MissingUpdateArgumentsError(self.args) if self.args.get('authority', None): bundles = self.renew(bundles, **kwargs) if self.args.get('destinations', None): bundles = self.deploy(bundles, **kwargs) json = self.transform(bundles) return json, status
def load(tracks_path, cameras_path): bundle = Bundle() bundle.K = K # Read cameras camera_data = np.loadtxt(open(cameras_path)) for row in camera_data: P = row.reshape((3, 4)) bundle.add_camera(Camera(P[:, :3], P[:, 3])) # Read tracks for i, line in enumerate(open(tracks_path)): tokens = line.strip().split() assert len(tokens) % 3 == 0, 'Error at line %d:\n %s' % (i, line) vs = np.array(map(int, tokens)).reshape((-1, 3)) bundle.add_track(Track(list(vs[:, 0].astype(int)), vs[:, 1:])) return bundle
def execute(self, **kwargs): status = 200 bundle_name_pns = [ self.sanitize(bundle_name_pn) for bundle_name_pn in self.args.bundle_name_pns ] bundles = Bundle.bundles(bundle_name_pns, within=self.args.within, expired=self.args.expired) bundles2 = [] if self.verbosity > 1: #FIXME: this should be driven by the yml in the cert tarball bundles1 = self.authorities.digicert.display_certificates(bundles) for name, dests in self.args.destinations.items(): print(f'name={name} dests={dests}') bundles2.extend(self.destinations[name].fetch_certificates( bundles1, dests)) else: bundles2 = bundles json = self.transform(bundles2) return json, status
class LogForm(FlaskForm): b_field = SelectField("Bundle: ", choices=Bundle(Mongo()).get_bundle_names(), default=1) p_field = SelectField("Project: ", choices=[("Project","Project")], default=1) i_field = SelectField("ID: ", choices=[("ID","ID")], default=1) log_text = TextAreaField('log_text', validators=[DataRequired(), Length(min=10, max=1000)]) log_time = StringField('log_time', validators=[DataRequired(), Length(min=1, max=5)]) submit = SubmitField('Submit')
def load(tracks_path, cameras_path): bundle = Bundle() bundle.K = K # Read cameras camera_data = np.loadtxt(open(cameras_path)) for row in camera_data: P = row.reshape((3,4)) bundle.add_camera(Camera(P[:,:3], P[:,3])) # Read tracks for i,line in enumerate(open(tracks_path)): tokens = line.strip().split() assert len(tokens) % 3 == 0, 'Error at line %d:\n %s' % (i,line) vs = np.array(map(int, tokens)).reshape((-1,3)) bundle.add_track(Track(list(vs[:,0].astype(int)), vs[:,1:])) return bundle
def add_projects(): bundle = Bundle(mongo) if current_user.ID != admin_id: flash(f'This account is not authorised to add Projects!','danger') return redirect(url_for('log')) else: f = 0 form = AddProjectForm() bundle_lst = bundle.get_bundle_list() project_lst = bundle.get_project_list() ID_lst = bundle.get_ID_list() if request.method == 'POST': f = bundle.add_project(form.bundle_text.data, form.project_text.data, form.ID_text.data) if f == -1: flash(f'Already Exists!','danger') redirect(url_for('add_projects')) elif f == 1: flash(f'Successfully Added!','success') redirect(url_for('add_projects')) return render_template('add_projects.html', form=form, bundle_lst=bundle_lst, project_lst=project_lst, ID_lst=ID_lst )
brushdir = config.ask("Brushes directory", "brushes") brushmask = config.ask("Brush files mask", "*.gbr;*.gih;*.png") patdir = config.ask("Patterns directory", "patterns") patmask = config.ask("Pattern files mask", "*.pat") presetsdir = config.ask("Presets directory", "paintoppresets") presetmask = config.ask("Preset files mask", "*.kpp") skip_bad = config.ask("Skip presets with broken references", default=False, config_option="Skip bad presets") skip_unused_brushes = config.ask("Skip unused brushes", default=False) autopopulate = config.ask("Automatically add resources from directory", default=None, config_option="Auto add resources") if autopopulate is not None: autopopulate = autopopulate.split(";") autopopulate = map(expanduser, autopopulate) autopopulate = sum(map(glob, autopopulate), []) preview = config.ask("Preview", "preview.png") bundle = Bundle() bundle.prepare(brushdir, brushmask, presetsdir, presetmask, patdir, patmask) ok = bundle.check(skip_bad=skip_bad, resourcedir=autopopulate, skip_unused_brushes=skip_unused_brushes) if not ok: print( "Bundle contains references to resources outside the bundle. You probably need to put required resources to the bundle itself." ) bundle.create(zipname, meta, preview)
meta.initial_creator = config.ask("Initial creator", author) meta.creator = config.ask("Creator", author) meta.date = config.ask("Date") meta.email = config.ask("Email") meta.website = config.ask("Website") meta.license = config.ask("License") zipname = config.ask("Bundle file name") brushdir = config.ask("Brushes directory", "brushes") brushmask = config.ask("Brush files mask", "*.gbr;*.gih;*.png") patdir = config.ask("Patterns directory", "patterns") patmask = config.ask("Pattern files mask", "*.pat") presetsdir = config.ask("Presets directory", "paintoppresets") presetmask = config.ask("Preset files mask", "*.kpp") skip_bad = config.ask("Skip presets with broken references", default=False, config_option="Skip bad presets") skip_unused_brushes = config.ask("Skip unused brushes", default=False) autopopulate = config.ask("Automatically add resources from directory", default=None, config_option="Auto add resources") if autopopulate is not None: autopopulate = autopopulate.split(";") autopopulate = map(expanduser, autopopulate) autopopulate = sum(map(glob, autopopulate), []) preview = config.ask("Preview", "preview.png") bundle = Bundle() bundle.prepare(brushdir, brushmask, presetsdir, presetmask, patdir, patmask) ok = bundle.check(skip_bad=skip_bad, resourcedir=autopopulate, skip_unused_brushes=skip_unused_brushes) if not ok: print("Bundle contains references to resources outside the bundle. You probably need to put required resources to the bundle itself.") bundle.create(zipname, meta, preview)
def __init__(self, path): Bundle.__init__(self, path)
from extractor import KPP from bundle import Bundle def parse_cmdline(): parser = argparse.ArgumentParser(description="Add resource (preset, brush tip or pattern) to the bundle.") parser.add_argument('bundle', metavar='FILE.BUNDLE', help="Path to bundle file to operate on") #subparsers = parser.add_subparsers(help="type of resource to be added") parser.add_argument('type', metavar='TYPE', help="Type of resource to be added: preset, brush or pattern.") parser.add_argument('path', metavar='FILENAME', nargs=argparse.REMAINDER, help="File to be added to the bundle") return parser.parse_args() if __name__ == '__main__': args = parse_cmdline() #print(args) bundle = Bundle.open(args.bundle) shutil.copy(args.bundle, args.bundle+'.bak') if args.type == 'brush': bundle.add_brushes(args.bundle, args.path) elif args.type == 'preset': bundle.add_presets(args.bundle, args.path) elif args.type == 'pattern': bundle.add_patterns(args.bundle, args.path) else: print("Unknown resource type specified. Valid resource types are: brush, preset, pattern.") sys.exit(1)
def publish(dir, id, version, site): b = Bundle(id, version) b.bundle(dir) b.publish(site)
(options,args) = parser.parse_args() h = util.logging.FileHandler(options.logfile) h.setFormatter(util.f) util.log.addHandler(h) if os.path.isfile(util.rawdir+options.scenarioname+'-lines.npy') and options.network=="": options.network=util.rawdir+options.scenarioname+'-lines.npy' if options.cache and os.path.isfile(util.rawdir+options.scenarioname+'-cache.npy'): util.log.info("Using Cached PSD values. This is very dangerous") options.cache=util.rawdir+options.scenarioname+'-cache.npy' util.log.info("Starting Up... logging to %s"%options.logfile) bundle = Bundle(network_file=options.network,K=options.K,scenarioname=options.scenarioname, cachefile=options.cache, useGPU=options.gpu) algos={"OSB":OSB,"MIPB":MIPB,"ISB":ISB} if __name__ == "__main__": if options.algo=="": util.log.info("Generating scenario files %s and exiting"%options.scenarioname) sys.exit(0) ''' Perform algorithm selection and option passing ''' algo = algos[options.algo](bundle,options.gpu, options.rate_search) if options.profiling: