コード例 #1
0
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']
    }
コード例 #2
0
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']
    }
コード例 #3
0
ファイル: sniffer.py プロジェクト: Hainish/cerealbox
 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()
   }
コード例 #4
0
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']
コード例 #5
0
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))
コード例 #6
0
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']
コード例 #7
0
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))