mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-04-26 04:51:08 -05:00
Add a DB migration script from Weather to NuWeather
This commit is contained in:
parent
e46915b58d
commit
ef35e34ad5
@ -1,4 +1,4 @@
|
||||
## NuWeather
|
||||
# NuWeather
|
||||
|
||||
A weather plugin for Limnoria. It supports multiple backends:
|
||||
|
||||
@ -7,7 +7,7 @@ A weather plugin for Limnoria. It supports multiple backends:
|
||||
|
||||
For the Dark Sky backend, [OpenStreetMap Nominatim](https://nominatim.openstreetmap.org/) is used to translate locations into latitude/longitude pairs.
|
||||
|
||||
### Quick start
|
||||
## Quick start
|
||||
|
||||
1) Pick your preferred backend: `config help plugins.nuweather.defaultbackend`
|
||||
|
||||
@ -18,3 +18,39 @@ For the Dark Sky backend, [OpenStreetMap Nominatim](https://nominatim.openstreet
|
||||
5) Set your default weather location: `setweather <your-preferred-location>`
|
||||
|
||||
6) Obtain weather: `weather [<optional location>]`
|
||||
|
||||
## Migrating from the Weather plugin
|
||||
|
||||
This plugin includes a script to migrate from the [Weather](../Weather) plugin's SQLite DB to NuWeather's binary format.
|
||||
|
||||
```
|
||||
$ ./weather-migrate.py -h
|
||||
usage: weather-migrate [-h] infile outfile
|
||||
|
||||
Migrates user locations from the Weather plugin to NuWeather.
|
||||
|
||||
positional arguments:
|
||||
infile input filename (BOT_DATA_DIR/Weather.db)
|
||||
outfile output filename (e.g. BOT_DATA_DIR/NuWeather.db)
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
```
|
||||
|
||||
### Migration instructions
|
||||
|
||||
1) If you have not loaded NuWeather previously, **load** the plugin for the first time so that config entries are populated.
|
||||
|
||||
2) Then, **unload** the plugin before running the migration script. You may also wish to make a backup of your current `NuWeather.db` if it is of any use.
|
||||
|
||||
3) Run the script on the right files: `./weather-migrate.py BOT_DATA_DIR/Weather.db BOT_DATA_DIR/NuWeather.db`
|
||||
|
||||
4) After performing the migration, set the **`plugins.NuWeather.DBAddressingMode` option to `nicks`** (since the previous database tracks locations by nick):
|
||||
|
||||
```
|
||||
config plugins.NuWeather.DBAddressingMode nicks
|
||||
```
|
||||
|
||||
5) Load the plugin again for these changes to take effect.
|
||||
|
||||
(If you're comfortable with re-creating your database from scratch, the other options tell NuWeather to save location by Supybot account (the default) or ident@host.)
|
||||
|
25
NuWeather/weather-migrate.py
Executable file
25
NuWeather/weather-migrate.py
Executable file
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Migrates user locations from the Weather plugin to NuWeather.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import sqlite3
|
||||
import pickle
|
||||
|
||||
parser = argparse.ArgumentParser(prog='weather-migrate', description=__doc__)
|
||||
parser.add_argument('infile', type=str, help='input filename (BOT_DATA_DIR/Weather.db)')
|
||||
parser.add_argument('outfile', type=str, help='output filename (e.g. BOT_DATA_DIR/NuWeather.db)')
|
||||
args = parser.parse_args()
|
||||
|
||||
conn = sqlite3.connect(args.infile)
|
||||
c = conn.cursor()
|
||||
# We only care about nick and location
|
||||
c.execute('SELECT nick, location from users')
|
||||
out = dict(c.fetchall())
|
||||
print("OK read %d entries from %s" % (len(out), args.infile))
|
||||
c.close() # No need to commit since we only read
|
||||
|
||||
with open(args.outfile, 'wb') as outf:
|
||||
pickle.dump(out, outf)
|
||||
print("OK wrote output to %s" % args.outfile)
|
@ -1,4 +1,6 @@
|
||||
# Limnoria plugin for Weather Underground
|
||||
# [DEPRECATED] Limnoria plugin for Weather Underground
|
||||
|
||||
Update 201903: Weather Underground has shut down free weather access, so this plugin will no longer be maintained. See the [NuWeather](../NuWeather) plugin for an alternative using other backends.
|
||||
|
||||
## Installation
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user