def _get_temp_location(query, settings): location = geocode.lookup(query) name = location['name'] short_name = name.partition(',')[0] if ',' in name else name settings['location'] = { 'name': name, 'short_name': short_name, 'latitude': location['latitude'], 'longitude': location['longitude'] }
def s_open(self, key, lport, rmac, rip, rport): cc, cont = geocode.lookup(rip) cc = cc if cc else "LL" cont = cont if cont else "--" self.numopen += 1 self.new_connection_handler(1, lport, rmac, rip, rport, cc, cont) self.tcp_db[key] = { 'cc': cc, 'cont': cont, 'lport': lport, 'rmac': rmac, 'rip': rip, 'rport': rport, 'close': 0, 'time': datetime.now() }
def _migrate_settings(settings): if 'units' in settings: if settings['units'] == 'US': settings['units'] = 'us' else: settings['units'] = 'si' if 'key' in settings: settings['key.wund'] = settings['key'] del settings['key'] settings['service'] = 'wund' settings['location'] = {} if 'name' in settings: location = geocode.lookup(settings['name']) name = location['name'] short_name = name.partition(',')[0] if ',' in name else name settings['location']['name'] = name settings['location']['short_name'] = short_name settings['location']['latitude'] = location['latitude'] settings['location']['longitude'] = location['longitude'] del settings['name']
def do_location(name): location_data = geocode.lookup(name) short_name = name if re.match('\d+ - .*', name): short_name = name.partition(' - ')[2] if ',' in short_name: short_name = short_name.split(',')[0] location = { 'name': name, 'short_name': short_name, 'latitude': location_data['latitude'], 'longitude': location_data['longitude'] } settings = _load_settings(False) settings['location'] = location _save_settings(settings) _out(u'Using location {}'.format(name))