Python config.config.get() Examples
The following are 30
code examples of config.config.get().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
config.config
, or try the search function
.
Example #1
Source File: edsm.py From EDMarketConnector with GNU General Public License v2.0 | 6 votes |
def prefs_changed(cmdr, is_beta): config.set('edsm_out', this.log.get()) if cmdr and not is_beta: cmdrs = config.get('edsm_cmdrs') usernames = config.get('edsm_usernames') or [] apikeys = config.get('edsm_apikeys') or [] if cmdr in cmdrs: idx = cmdrs.index(cmdr) usernames.extend([''] * (1 + idx - len(usernames))) usernames[idx] = this.user.get().strip() apikeys.extend([''] * (1 + idx - len(apikeys))) apikeys[idx] = this.apikey.get().strip() else: config.set('edsm_cmdrs', cmdrs + [cmdr]) usernames.append(this.user.get().strip()) apikeys.append(this.apikey.get().strip()) config.set('edsm_usernames', usernames) config.set('edsm_apikeys', apikeys)
Example #2
Source File: edrclient.py From edr with Apache License 2.0 | 6 votes |
def check_version(self): version_range = self.server.server_version() self.motd = _edr(version_range["l10n_motd"]) if version_range is None: # Translators: this is shown on EDMC's status bar when the version check fails self.status = _(u"check for version update has failed.") return if self.is_obsolete(version_range["min"]): EDRLOG.log(u"Mandatory update! {version} vs. {min}" .format(version=self.edr_version, min=version_range["min"]), "ERROR") self.mandatory_update = True self.autoupdate_pending = version_range.get("autoupdatable", False) self.__status_update_pending() elif self.is_obsolete(version_range["latest"]): EDRLOG.log(u"EDR update available! {version} vs. {latest}" .format(version=self.edr_version, latest=version_range["latest"]), "INFO") self.mandatory_update = False self.autoupdate_pending = version_range.get("autoupdatable", False) self.__status_update_pending()
Example #3
Source File: companion.py From EDMarketConnector with GNU General Public License v2.0 | 6 votes |
def station(self): data = self.query(URL_QUERY) if data['commander'].get('docked'): services = data['lastStarport'].get('services', {}) if services.get('commodities'): marketdata = self.query(URL_MARKET) if (data['lastStarport']['name'] != marketdata['name'] or int(data['lastStarport']['id']) != int(marketdata['id'])): raise ServerLagging() else: data['lastStarport'].update(marketdata) if services.get('outfitting') or services.get('shipyard'): shipdata = self.query(URL_SHIPYARD) if (data['lastStarport']['name'] != shipdata['name'] or int(data['lastStarport']['id']) != int(shipdata['id'])): raise ServerLagging() else: data['lastStarport'].update(shipdata) return data
Example #4
Source File: edrclient.py From edr with Apache License 2.0 | 6 votes |
def prefs_changed(self): set_language(config.get("language")) if self.mandatory_update: EDRLOG.log(u"Out-of-date client, aborting.", "ERROR") self.__status_update_pending() return config.set("EDREmail", self.email) config.set("EDRPassword", self.password) config.set("EDRVisualFeedback", "True" if self.visual_feedback else "False") config.set("EDRAudioFeedback", "True" if self.audio_feedback else "False") config.set("EDRRedactMyInfo", self.anonymous_reports) EDRLOG.log(u"Audio cues: {}, {}".format(config.get("EDRAudioFeedback"), config.get("EDRAudioFeedbackVolume")), "DEBUG") EDRLOG.log(u"Anonymous reports: {}".format(config.get("EDRRedactMyInfo")), "DEBUG") self.login()
Example #5
Source File: loadout.py From EDMarketConnector with GNU General Public License v2.0 | 6 votes |
def export(data, filename=None): string = json.dumps(companion.ship(data), ensure_ascii=False, indent=2, sort_keys=True, separators=(',', ': ')).encode('utf-8') # pretty print if filename: with open(filename, 'wt') as h: h.write(string) return # Look for last ship of this type ship = companion.ship_file_name(data['ship'].get('shipName'), data['ship']['name']) regexp = re.compile(re.escape(ship) + '\.\d\d\d\d\-\d\d\-\d\dT\d\d\.\d\d\.\d\d\.txt') oldfiles = sorted([x for x in os.listdir(config.get('outdir')) if regexp.match(x)]) if oldfiles: with open(join(config.get('outdir'), oldfiles[-1]), 'rU') as h: if h.read() == string: return # same as last time - don't write querytime = config.getint('querytime') or int(time.time()) # Write filename = join(config.get('outdir'), '%s.%s.txt' % (ship, time.strftime('%Y-%m-%dT%H.%M.%S', time.localtime(querytime)))) with open(filename, 'wt') as h: h.write(string)
Example #6
Source File: edrclient.py From edr with Apache License 2.0 | 6 votes |
def noteworthy_about_system(self, fsdjump_event): if fsdjump_event["SystemSecurity"]: self.player.location_security(fsdjump_event["SystemSecurity"]) self.edrsystems.system_id(fsdjump_event['StarSystem'], may_create=True, coords=fsdjump_event.get("StarPos", None)) facts = self.edrresourcefinder.assess_jump(fsdjump_event, self.player.inventory) header = _('Rare materials in {} (USS-HGE/EE, Mission Rewards)'.format(fsdjump_event['StarSystem'])) if not facts: facts = EDRBodiesOfInterest.bodies_of_interest(fsdjump_event['StarSystem']) header = _('Noteworthy stellar bodies in {}').format(fsdjump_event['StarSystem']) if not facts: if self.player.in_bad_neighborhood(): header = _(u"Anarchy system") facts = [_(u"Crimes will not be reported.")] else: return False self.__notify(header, facts, clear_before = True) return True
Example #7
Source File: edrclient.py From edr with Apache License 2.0 | 6 votes |
def show_navigation(self): current = self.player.piloted_vehicle.attitude destination = self.player.planetary_destination if not destination or not current: return if not current.valid() or not destination.valid(): return bearing = destination.bearing(current) body = self.edrsystems.body(self.player.star_system, self.player.place) radius = body.get("radius", None) if body else None distance = destination.distance(current, radius) if radius else None if distance <= 1.0: return pitch = destination.pitch(current, distance) if distance and distance <= 700 else None if self.visual_feedback: self.IN_GAME_MSG.navigation(bearing, destination, distance, pitch) self.status = _(u"> {:03} < for Lat:{:.4f} Lon:{:.4f}".format(bearing, destination.latitude, destination.longitude))
Example #8
Source File: manifesto.py From manifesto with MIT License | 6 votes |
def main(args): tmpdir = tempfile.mkdtemp() zipfile = ZipFile(args.apk_file) zipfile.extractall(tmpdir) import_plugins() processing_modules = Obfuscator.__subclasses__() try: for module in processing_modules: module(tmpdir, config.get(module.__name__, {})).run() except Exception as ex: logging.error('Exception encountered: %s' % str(ex)) shutil.rmtree(tmpdir) return if args.force_overwrite or not os.path.isfile(args.outfile): zipdir(tmpdir, args.outfile, args.keep_meta) else: logging.error('Output file already exists (use -f to overwrite)!') shutil.rmtree(tmpdir)
Example #9
Source File: eddn.py From EDMarketConnector with GNU General Public License v2.0 | 6 votes |
def export_outfitting(self, data, is_beta): economies = data['lastStarport'].get('economies') or {} modules = data['lastStarport'].get('modules') or {} ships = data['lastStarport'].get('ships') or { 'shipyard_list': {}, 'unavailable_list': [] } # Horizons flag - will hit at least Int_PlanetApproachSuite other than at engineer bases ("Colony"), prison or rescue Megaships, or under Pirate Attack etc horizons = (any(economy['name'] == 'Colony' for economy in economies.itervalues()) or any(module.get('sku') == 'ELITE_HORIZONS_V_PLANETARY_LANDINGS' for module in modules.itervalues()) or any(ship.get('sku') == 'ELITE_HORIZONS_V_PLANETARY_LANDINGS' for ship in (ships['shipyard_list'] or {}).values())) outfitting = sorted([self.MODULE_RE.sub(lambda m: m.group(0).capitalize(), module['name'].lower()) for module in modules.itervalues() if self.MODULE_RE.search(module['name']) and module.get('sku') in [None, 'ELITE_HORIZONS_V_PLANETARY_LANDINGS'] and module['name'] != 'Int_PlanetApproachSuite']) if outfitting and this.outfitting != (horizons, outfitting): # Don't send empty modules list - schema won't allow it self.send(data['commander']['name'], { '$schemaRef' : 'https://eddn.edcd.io/schemas/outfitting/2' + (is_beta and '/test' or ''), 'message' : OrderedDict([ ('timestamp', data['timestamp']), ('systemName', data['lastSystem']['name']), ('stationName', data['lastStarport']['name']), ('marketId', data['lastStarport']['id']), ('horizons', horizons), ('modules', outfitting), ]), }) this.outfitting = (horizons, outfitting)
Example #10
Source File: eddn.py From EDMarketConnector with GNU General Public License v2.0 | 6 votes |
def export_journal_commodities(self, cmdr, is_beta, entry): items = entry.get('Items') or [] commodities = sorted([OrderedDict([ ('name', self.canonicalise(commodity['Name'])), ('meanPrice', commodity['MeanPrice']), ('buyPrice', commodity['BuyPrice']), ('stock', commodity['Stock']), ('stockBracket', commodity['StockBracket']), ('sellPrice', commodity['SellPrice']), ('demand', commodity['Demand']), ('demandBracket', commodity['DemandBracket']), ]) for commodity in items], key = lambda c: c['name']) if commodities and this.commodities != commodities: # Don't send empty commodities list - schema won't allow it self.send(cmdr, { '$schemaRef' : 'https://eddn.edcd.io/schemas/commodity/3' + (is_beta and '/test' or ''), 'message' : OrderedDict([ ('timestamp', entry['timestamp']), ('systemName', entry['StarSystem']), ('stationName', entry['StationName']), ('marketId', entry['MarketID']), ('commodities', commodities), ]), }) this.commodities = commodities
Example #11
Source File: eddn.py From EDMarketConnector with GNU General Public License v2.0 | 6 votes |
def export_journal_shipyard(self, cmdr, is_beta, entry): ships = entry.get('PriceList') or [] horizons = entry.get('Horizons', False) shipyard = sorted([ship['ShipType'] for ship in ships]) if shipyard and this.shipyard != (horizons, shipyard): # Don't send empty ships list - shipyard data is only guaranteed present if user has visited the shipyard. self.send(cmdr, { '$schemaRef' : 'https://eddn.edcd.io/schemas/shipyard/2' + (is_beta and '/test' or ''), 'message' : OrderedDict([ ('timestamp', entry['timestamp']), ('systemName', entry['StarSystem']), ('stationName', entry['StationName']), ('marketId', entry['MarketID']), ('horizons', horizons), ('ships', shipyard), ]), }) this.shipyard = (horizons, shipyard)
Example #12
Source File: eddn.py From EDMarketConnector with GNU General Public License v2.0 | 6 votes |
def export_journal_outfitting(self, cmdr, is_beta, entry): modules = entry.get('Items') or [] horizons = entry.get('Horizons', False) outfitting = sorted([self.MODULE_RE.sub(lambda m: m.group(0).capitalize(), module['Name']) for module in modules if module['Name'] != 'int_planetapproachsuite']) if outfitting and this.outfitting != (horizons, outfitting): # Don't send empty modules list - schema won't allow it self.send(cmdr, { '$schemaRef' : 'https://eddn.edcd.io/schemas/outfitting/2' + (is_beta and '/test' or ''), 'message' : OrderedDict([ ('timestamp', entry['timestamp']), ('systemName', entry['StarSystem']), ('stationName', entry['StationName']), ('marketId', entry['MarketID']), ('horizons', horizons), ('modules', outfitting), ]), }) this.outfitting = (horizons, outfitting)
Example #13
Source File: edrclient.py From edr with Apache License 2.0 | 6 votes |
def __staoi_found(self, reference, radius, sc, soi_checker, result): self.searching = False details = [] if result: sc_distance = result['station']['distanceToArrival'] distance = result['distance'] pretty_dist = _(u"{dist:.3g}LY").format(dist=distance) if distance < 50.0 else _(u"{dist}LY").format(dist=int(distance)) pretty_sc_dist = _(u"{dist}LS").format(dist=int(sc_distance)) details.append(_(u"{system}, {dist}").format(system=result['name'], dist=pretty_dist)) details.append(_(u"{station} ({type}), {sc_dist}").format(station=result['station']['name'], type=result['station']['type'], sc_dist=pretty_sc_dist)) details.append(_(u"as of {date} {ci}").format(date=result['station']['updateTime']['information'],ci=result.get('comment', ''))) self.status = u"{item}: {system}, {dist} - {station} ({type}), {sc_dist}".format(item=soi_checker.name, system=result['name'], dist=pretty_dist, station=result['station']['name'], type=result['station']['type'], sc_dist=pretty_sc_dist) copy(result["name"]) else: self.status = _(u"{}: nothing within [{}LY, {}LS] of {}".format(soi_checker.name, int(radius), int(sc), reference)) checked = _("checked {} systems").format(soi_checker.systems_counter) if soi_checker.stations_counter: checked = _("checked {} systems and {} stations").format(soi_checker.systems_counter, soi_checker.stations_counter) details.append(_(u"nothing found within [{}LY, {}LS], {}.").format(int(radius), int(sc), checked)) if soi_checker.hint: details.append(soi_checker.hint) self.__notify(_(u"{} near {}").format(soi_checker.name, reference), details, clear_before = True)
Example #14
Source File: monitor.py From EDMarketConnector with GNU General Public License v2.0 | 6 votes |
def export_ship(self, filename=None): string = json.dumps(self.ship(False), ensure_ascii=False, indent=2, separators=(',', ': ')).encode('utf-8') # pretty print if filename: with open(filename, 'wt') as h: h.write(string) return ship = ship_file_name(self.state['ShipName'], self.state['ShipType']) regexp = re.compile(re.escape(ship) + '\.\d\d\d\d\-\d\d\-\d\dT\d\d\.\d\d\.\d\d\.txt') oldfiles = sorted([x for x in listdir(config.get('outdir')) if regexp.match(x)]) if oldfiles: with open(join(config.get('outdir'), oldfiles[-1]), 'rU') as h: if h.read() == string: return # same as last time - don't write # Write filename = join(config.get('outdir'), '%s.%s.txt' % (ship, strftime('%Y-%m-%dT%H.%M.%S', localtime(time())))) with open(filename, 'wt') as h: h.write(string) # singleton
Example #15
Source File: edsm.py From EDMarketConnector with GNU General Public License v2.0 | 6 votes |
def credentials(cmdr): # Credentials for cmdr if not cmdr: return None cmdrs = config.get('edsm_cmdrs') if not cmdrs: # Migrate from <= 2.25 cmdrs = [cmdr] config.set('edsm_cmdrs', cmdrs) if cmdr in cmdrs and config.get('edsm_usernames') and config.get('edsm_apikeys'): idx = cmdrs.index(cmdr) return (config.get('edsm_usernames')[idx], config.get('edsm_apikeys')[idx]) else: return None
Example #16
Source File: edrclient.py From edr with Apache License 2.0 | 5 votes |
def novel_enough_fight(self, involved_cmdr, fight): last_fight = self.fights_cache.get(involved_cmdr) return self.__novel_enough_fight(fight, last_fight)
Example #17
Source File: edcargoreader.py From edr with Apache License 2.0 | 5 votes |
def __init__(self): self.journal_location = config.get('journaldir') or config.default_journal_dir
Example #18
Source File: edrclient.py From edr with Apache License 2.0 | 5 votes |
def crime(self, star_system, crime): if self.player.in_solo(): EDRLOG.log(u"Skipping crime since the user is in solo (unexpected).", "INFO") return False if not self.crimes_reporting: EDRLOG.log(u"Crimes reporting is off (!crimes on to re-enable).", "INFO") self.status = _(u"Crimes reporting is off (!crimes on to re-enable)") return True if self.player.in_bad_neighborhood(): EDRLOG.log(u"Crime not being reported because the player is in an anarchy.", "INFO") self.status = _(u"Anarchy system (crimes not reported).") return True if self.is_anonymous(): EDRLOG.log(u"Skipping crime report since the user is anonymous.", "INFO") if crime["victim"] == self.player.name: self.advertise_full_account(_(u"You could have helped other EDR users or get help by reporting this crime!")) return True sid = self.edrsystems.system_id(star_system, may_create=True) if sid is None: EDRLOG.log(u"Failed to report crime in system {} : no id found.".format(star_system), "DEBUG") return False if self.server.crime(sid, crime): self.status = _(u"crime reported!") return True return False
Example #19
Source File: edrclient.py From edr with Apache License 2.0 | 5 votes |
def help(self, section): content = self.help_content.get(section) if not content: return False if self.visual_feedback: EDRLOG.log(u"Show help for {} with header: {} and details: {}".format(section, content["header"], content["details"][0]), "DEBUG") self.IN_GAME_MSG.help(content["header"], content["details"]) EDRLOG.log(u"[Alt] Show help for {} with header: {} and details: {}".format(section, content["header"], content["details"][0]), "DEBUG") self.ui.help(_(content["header"]), _(content["details"])) return True
Example #20
Source File: edrclient.py From edr with Apache License 2.0 | 5 votes |
def _summarize_realtime_alert(self, kind, event): summary = [] EDRLOG.log(u"realtime {} alerts, handling {}".format(kind, event), "DEBUG") if not self._worthy_alert(kind, event): EDRLOG.log(u"Skipped realtime {} event because it wasn't worth alerting about: {}.".format(kind, event), "DEBUG") else: location = EDLocation(event["starSystem"], event["place"]) copy(event["starSystem"]) distance = None try: distance = self.edrsystems.distance(self.player.star_system, location.star_system) except ValueError: pass oneliner = _(u"{cmdr} ({ship}) sighted in {location}") if kind is EDROpponents.ENEMIES and event.get("enemy", None): oneliner = _(u"Enemy {cmdr} ({ship}) sighted in {location}") elif kind is EDROpponents.OUTLAWS: oneliner = _(u"Outlaw {cmdr} ({ship}) sighted in {location}") oneliner = oneliner.format(cmdr=event["cmdr"], ship=event["ship"], location=location.pretty_print()) if distance: oneliner += _(u" [{distance:.3g} ly]").format(distance=distance) if distance < 50.0 else _(u" [{distance} ly]").format(distance=int(distance)) if event.get("wanted", None): if event["bounty"] > 0: oneliner += _(u" wanted for {bounty} cr").format(bounty=EDFineOrBounty(event["bounty"]).pretty_print()) else: oneliner += _(u" wanted somewhere") if oneliner: summary.append(oneliner) self.alerts_cache.set(event["cmdr"].lower(), event) return summary
Example #21
Source File: edrclient.py From edr with Apache License 2.0 | 5 votes |
def email(self): return self._email.get()
Example #22
Source File: edrclient.py From edr with Apache License 2.0 | 5 votes |
def audio_feedback(self): return self._audio_feedback.get() == 1
Example #23
Source File: trans_e.py From KBGAN with MIT License | 5 votes |
def __init__(self, n_ent, n_rel, config): super(TransEModule, self).__init__() self.p = config.p self.margin = config.margin self.temp = config.get('temp', 1) self.rel_embed = nn.Embedding(n_rel, config.dim) self.ent_embed = nn.Embedding(n_ent, config.dim) self.init_weight()
Example #24
Source File: trans_d.py From KBGAN with MIT License | 5 votes |
def __init__(self, n_ent, n_rel, config): super(TransDModule, self).__init__() self.margin = config.margin self.p = config.p self.temp = config.get('temp', 1) self.rel_embed = nn.Embedding(n_rel, config.dim) self.ent_embed = nn.Embedding(n_ent, config.dim) self.proj_rel_embed = nn.Embedding(n_rel, config.dim) self.proj_ent_embed = nn.Embedding(n_ent, config.dim) self.init_weight()
Example #25
Source File: edsm.py From EDMarketConnector with GNU General Public License v2.0 | 5 votes |
def edsm_notify_system(reply): if not reply: this.system['image'] = this._IMG_ERROR plug.show_error(_("Error: Can't connect to EDSM")) elif reply['msgnum'] // 100 not in (1,4): this.system['image'] = this._IMG_ERROR plug.show_error(_('Error: EDSM {MSG}').format(MSG=reply['msg'])) elif reply.get('systemCreated'): this.system['image'] = this._IMG_NEW else: this.system['image'] = this._IMG_KNOWN
Example #26
Source File: eddb.py From EDMarketConnector with GNU General Public License v2.0 | 5 votes |
def system_id(system_name): return this.system_ids.get(system_name, [0, False])[0] # system_name -> is_populated
Example #27
Source File: eddb.py From EDMarketConnector with GNU General Public License v2.0 | 5 votes |
def system_populated(system_name): return this.system_ids.get(system_name, [0, False])[1] # (system_name, station_name) -> station_id or 0
Example #28
Source File: eddb.py From EDMarketConnector with GNU General Public License v2.0 | 5 votes |
def cmdr_data(data, is_beta): if config.get('system_provider') == 'eddb': this.system_link['url'] = system_url(data['lastSystem']['name']) # Override standard URL function this.station_link['text'] = data['commander']['docked'] and data['lastStarport']['name'] or (system_populated(data['lastSystem']['name']) and STATION_UNDOCKED or '') this.station_link.update_idletasks()
Example #29
Source File: eddb.py From EDMarketConnector with GNU General Public License v2.0 | 5 votes |
def prefs_changed(cmdr, is_beta): if config.get('system_provider') == 'eddb': this.system_link['url'] = system_url(system_link['text']) # Override standard URL function
Example #30
Source File: eddb.py From EDMarketConnector with GNU General Public License v2.0 | 5 votes |
def station_id(system_name, station_name): return this.station_ids.get((system_id(system_name), station_name), 0)